babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016
  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/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @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
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. 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);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** 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 */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @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)
  7392. * @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)
  7393. * @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)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * 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.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * 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
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * 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)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * 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)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * 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).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @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
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * 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.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @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
  7840. * @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
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the parent skeleton
  7943. * @returns a skeleton
  7944. */
  7945. getSkeleton(): Skeleton;
  7946. /**
  7947. * Gets parent bone
  7948. * @returns a bone or null if the bone is the root of the bone hierarchy
  7949. */
  7950. getParent(): Nullable<Bone>;
  7951. /**
  7952. * Sets the parent bone
  7953. * @param parent defines the parent (can be null if the bone is the root)
  7954. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7955. */
  7956. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7957. /**
  7958. * Gets the local matrix
  7959. * @returns a matrix
  7960. */
  7961. getLocalMatrix(): Matrix;
  7962. /**
  7963. * Gets the base matrix (initial matrix which remains unchanged)
  7964. * @returns a matrix
  7965. */
  7966. getBaseMatrix(): Matrix;
  7967. /**
  7968. * Gets the rest pose matrix
  7969. * @returns a matrix
  7970. */
  7971. getRestPose(): Matrix;
  7972. /**
  7973. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7974. */
  7975. getWorldMatrix(): Matrix;
  7976. /**
  7977. * Sets the local matrix to rest pose matrix
  7978. */
  7979. returnToRest(): void;
  7980. /**
  7981. * Gets the inverse of the absolute transform matrix.
  7982. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7983. * @returns a matrix
  7984. */
  7985. getInvertedAbsoluteTransform(): Matrix;
  7986. /**
  7987. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7988. * @returns a matrix
  7989. */
  7990. getAbsoluteTransform(): Matrix;
  7991. /**
  7992. * Links with the given transform node.
  7993. * The local matrix of this bone is copied from the transform node every frame.
  7994. * @param transformNode defines the transform node to link to
  7995. */
  7996. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7997. /** Gets or sets current position (in local space) */
  7998. position: Vector3;
  7999. /** Gets or sets current rotation (in local space) */
  8000. rotation: Vector3;
  8001. /** Gets or sets current rotation quaternion (in local space) */
  8002. rotationQuaternion: Quaternion;
  8003. /** Gets or sets current scaling (in local space) */
  8004. scaling: Vector3;
  8005. /**
  8006. * Gets the animation properties override
  8007. */
  8008. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8009. private _decompose;
  8010. private _compose;
  8011. /**
  8012. * Update the base and local matrices
  8013. * @param matrix defines the new base or local matrix
  8014. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8015. * @param updateLocalMatrix defines if the local matrix should be updated
  8016. */
  8017. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8018. /** @hidden */
  8019. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8020. /**
  8021. * Flag the bone as dirty (Forcing it to update everything)
  8022. */
  8023. markAsDirty(): void;
  8024. private _markAsDirtyAndCompose;
  8025. private _markAsDirtyAndDecompose;
  8026. /**
  8027. * Translate the bone in local or world space
  8028. * @param vec The amount to translate the bone
  8029. * @param space The space that the translation is in
  8030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8031. */
  8032. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8033. /**
  8034. * Set the postion of the bone in local or world space
  8035. * @param position The position to set the bone
  8036. * @param space The space that the position is in
  8037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8038. */
  8039. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8040. /**
  8041. * Set the absolute position of the bone (world space)
  8042. * @param position The position to set the bone
  8043. * @param mesh The mesh that this bone is attached to
  8044. */
  8045. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8046. /**
  8047. * Scale the bone on the x, y and z axes (in local space)
  8048. * @param x The amount to scale the bone on the x axis
  8049. * @param y The amount to scale the bone on the y axis
  8050. * @param z The amount to scale the bone on the z axis
  8051. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8052. */
  8053. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8054. /**
  8055. * Set the bone scaling in local space
  8056. * @param scale defines the scaling vector
  8057. */
  8058. setScale(scale: Vector3): void;
  8059. /**
  8060. * Gets the current scaling in local space
  8061. * @returns the current scaling vector
  8062. */
  8063. getScale(): Vector3;
  8064. /**
  8065. * Gets the current scaling in local space and stores it in a target vector
  8066. * @param result defines the target vector
  8067. */
  8068. getScaleToRef(result: Vector3): void;
  8069. /**
  8070. * Set the yaw, pitch, and roll of the bone in local or world space
  8071. * @param yaw The rotation of the bone on the y axis
  8072. * @param pitch The rotation of the bone on the x axis
  8073. * @param roll The rotation of the bone on the z axis
  8074. * @param space The space that the axes of rotation are in
  8075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8076. */
  8077. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Add a rotation to the bone on an axis in local or world space
  8080. * @param axis The axis to rotate the bone on
  8081. * @param amount The amount to rotate the bone
  8082. * @param space The space that the axis is in
  8083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8084. */
  8085. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8086. /**
  8087. * Set the rotation of the bone to a particular axis angle in local or world space
  8088. * @param axis The axis to rotate the bone on
  8089. * @param angle The angle that the bone should be rotated to
  8090. * @param space The space that the axis is in
  8091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8092. */
  8093. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8094. /**
  8095. * Set the euler rotation of the bone in local of world space
  8096. * @param rotation The euler rotation that the bone should be set to
  8097. * @param space The space that the rotation is in
  8098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8099. */
  8100. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8101. /**
  8102. * Set the quaternion rotation of the bone in local of world space
  8103. * @param quat The quaternion rotation that the bone should be set to
  8104. * @param space The space that the rotation is in
  8105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8106. */
  8107. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8108. /**
  8109. * Set the rotation matrix of the bone in local of world space
  8110. * @param rotMat The rotation matrix that the bone should be set to
  8111. * @param space The space that the rotation is in
  8112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8113. */
  8114. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8115. private _rotateWithMatrix;
  8116. private _getNegativeRotationToRef;
  8117. /**
  8118. * Get the position of the bone in local or world space
  8119. * @param space The space that the returned position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. * @returns The position of the bone
  8122. */
  8123. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8124. /**
  8125. * Copy the position of the bone to a vector3 in local or world space
  8126. * @param space The space that the returned position is in
  8127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8128. * @param result The vector3 to copy the position to
  8129. */
  8130. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8131. /**
  8132. * Get the absolute position of the bone (world space)
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @returns The absolute position of the bone
  8135. */
  8136. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8137. /**
  8138. * Copy the absolute position of the bone (world space) to the result param
  8139. * @param mesh The mesh that this bone is attached to
  8140. * @param result The vector3 to copy the absolute position to
  8141. */
  8142. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8143. /**
  8144. * Compute the absolute transforms of this bone and its children
  8145. */
  8146. computeAbsoluteTransforms(): void;
  8147. /**
  8148. * Get the world direction from an axis that is in the local space of the bone
  8149. * @param localAxis The local direction that is used to compute the world direction
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @returns The world direction
  8152. */
  8153. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8154. /**
  8155. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8156. * @param localAxis The local direction that is used to compute the world direction
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @param result The vector3 that the world direction will be copied to
  8159. */
  8160. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8161. /**
  8162. * Get the euler rotation of the bone in local or world space
  8163. * @param space The space that the rotation should be in
  8164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8165. * @returns The euler rotation
  8166. */
  8167. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8168. /**
  8169. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8170. * @param space The space that the rotation should be in
  8171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8172. * @param result The vector3 that the rotation should be copied to
  8173. */
  8174. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8175. /**
  8176. * Get the quaternion rotation of the bone in either local or world space
  8177. * @param space The space that the rotation should be in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. * @returns The quaternion rotation
  8180. */
  8181. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8182. /**
  8183. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8184. * @param space The space that the rotation should be in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. * @param result The quaternion that the rotation should be copied to
  8187. */
  8188. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8189. /**
  8190. * Get the rotation matrix of the bone in local or world space
  8191. * @param space The space that the rotation should be in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. * @returns The rotation matrix
  8194. */
  8195. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8196. /**
  8197. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8198. * @param space The space that the rotation should be in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @param result The quaternion that the rotation should be copied to
  8201. */
  8202. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8203. /**
  8204. * Get the world position of a point that is in the local space of the bone
  8205. * @param position The local position
  8206. * @param mesh The mesh that this bone is attached to
  8207. * @returns The world position
  8208. */
  8209. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8210. /**
  8211. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8212. * @param position The local position
  8213. * @param mesh The mesh that this bone is attached to
  8214. * @param result The vector3 that the world position should be copied to
  8215. */
  8216. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8217. /**
  8218. * Get the local position of a point that is in world space
  8219. * @param position The world position
  8220. * @param mesh The mesh that this bone is attached to
  8221. * @returns The local position
  8222. */
  8223. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8224. /**
  8225. * Get the local position of a point that is in world space and copy it to the result param
  8226. * @param position The world position
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @param result The vector3 that the local position should be copied to
  8229. */
  8230. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8231. }
  8232. }
  8233. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8234. import { Nullable } from "babylonjs/types";
  8235. import { Scene } from "babylonjs/scene";
  8236. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8238. /**
  8239. * Class for creating a cube texture
  8240. */
  8241. export class CubeTexture extends BaseTexture {
  8242. private _delayedOnLoad;
  8243. /**
  8244. * The url of the texture
  8245. */
  8246. url: string;
  8247. /**
  8248. * Gets or sets the center of the bounding box associated with the cube texture.
  8249. * It must define where the camera used to render the texture was set
  8250. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8251. */
  8252. boundingBoxPosition: Vector3;
  8253. private _boundingBoxSize;
  8254. /**
  8255. * Gets or sets the size of the bounding box associated with the cube texture
  8256. * When defined, the cubemap will switch to local mode
  8257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8258. * @example https://www.babylonjs-playground.com/#RNASML
  8259. */
  8260. /**
  8261. * Returns the bounding box size
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxSize: Vector3;
  8265. protected _rotationY: number;
  8266. /**
  8267. * Sets texture matrix rotation angle around Y axis in radians.
  8268. */
  8269. /**
  8270. * Gets texture matrix rotation angle around Y axis radians.
  8271. */
  8272. rotationY: number;
  8273. /**
  8274. * Are mip maps generated for this texture or not.
  8275. */
  8276. readonly noMipmap: boolean;
  8277. private _noMipmap;
  8278. private _files;
  8279. private _extensions;
  8280. private _textureMatrix;
  8281. private _format;
  8282. private _createPolynomials;
  8283. /** @hidden */
  8284. _prefiltered: boolean;
  8285. /**
  8286. * Creates a cube texture from an array of image urls
  8287. * @param files defines an array of image urls
  8288. * @param scene defines the hosting scene
  8289. * @param noMipmap specifies if mip maps are not used
  8290. * @returns a cube texture
  8291. */
  8292. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8293. /**
  8294. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8295. * @param url defines the url of the prefiltered texture
  8296. * @param scene defines the scene the texture is attached to
  8297. * @param forcedExtension defines the extension of the file if different from the url
  8298. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8299. * @return the prefiltered texture
  8300. */
  8301. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8302. /**
  8303. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8304. * as prefiltered data.
  8305. * @param rootUrl defines the url of the texture or the root name of the six images
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8308. * @param noMipmap defines if mipmaps should be created or not
  8309. * @param files defines the six files to load for the different faces
  8310. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8311. * @param onError defines a callback triggered in case of error during load
  8312. * @param format defines the internal format to use for the texture once loaded
  8313. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8314. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8315. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8316. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8317. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8318. * @return the cube texture
  8319. */
  8320. 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);
  8321. /**
  8322. * Get the current class name of the texture useful for serialization or dynamic coding.
  8323. * @returns "CubeTexture"
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Update the url (and optional buffer) of this texture if url was null during construction.
  8328. * @param url the url of the texture
  8329. * @param forcedExtension defines the extension to use
  8330. * @param onLoad callback called when the texture is loaded (defaults to null)
  8331. */
  8332. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8333. /**
  8334. * Delays loading of the cube texture
  8335. * @param forcedExtension defines the extension to use
  8336. */
  8337. delayLoad(forcedExtension?: string): void;
  8338. /**
  8339. * Returns the reflection texture matrix
  8340. * @returns the reflection texture matrix
  8341. */
  8342. getReflectionTextureMatrix(): Matrix;
  8343. /**
  8344. * Sets the reflection texture matrix
  8345. * @param value Reflection texture matrix
  8346. */
  8347. setReflectionTextureMatrix(value: Matrix): void;
  8348. /**
  8349. * Parses text to create a cube texture
  8350. * @param parsedTexture define the serialized text to read from
  8351. * @param scene defines the hosting scene
  8352. * @param rootUrl defines the root url of the cube texture
  8353. * @returns a cube texture
  8354. */
  8355. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8356. /**
  8357. * Makes a clone, or deep copy, of the cube texture
  8358. * @returns a new cube texture
  8359. */
  8360. clone(): CubeTexture;
  8361. }
  8362. }
  8363. declare module "babylonjs/Shaders/postprocess.vertex" {
  8364. /** @hidden */
  8365. export var postprocessVertexShader: {
  8366. name: string;
  8367. shader: string;
  8368. };
  8369. }
  8370. declare module "babylonjs/Cameras/targetCamera" {
  8371. import { Nullable } from "babylonjs/types";
  8372. import { Camera } from "babylonjs/Cameras/camera";
  8373. import { Scene } from "babylonjs/scene";
  8374. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8375. /**
  8376. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8377. * This is the base of the follow, arc rotate cameras and Free camera
  8378. * @see http://doc.babylonjs.com/features/cameras
  8379. */
  8380. export class TargetCamera extends Camera {
  8381. private static _RigCamTransformMatrix;
  8382. private static _TargetTransformMatrix;
  8383. private static _TargetFocalPoint;
  8384. /**
  8385. * Define the current direction the camera is moving to
  8386. */
  8387. cameraDirection: Vector3;
  8388. /**
  8389. * Define the current rotation the camera is rotating to
  8390. */
  8391. cameraRotation: Vector2;
  8392. /**
  8393. * When set, the up vector of the camera will be updated by the rotation of the camera
  8394. */
  8395. updateUpVectorFromRotation: boolean;
  8396. private _tmpQuaternion;
  8397. /**
  8398. * Define the current rotation of the camera
  8399. */
  8400. rotation: Vector3;
  8401. /**
  8402. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8403. */
  8404. rotationQuaternion: Quaternion;
  8405. /**
  8406. * Define the current speed of the camera
  8407. */
  8408. speed: number;
  8409. /**
  8410. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8411. * around all axis.
  8412. */
  8413. noRotationConstraint: boolean;
  8414. /**
  8415. * Define the current target of the camera as an object or a position.
  8416. */
  8417. lockedTarget: any;
  8418. /** @hidden */
  8419. _currentTarget: Vector3;
  8420. /** @hidden */
  8421. _initialFocalDistance: number;
  8422. /** @hidden */
  8423. _viewMatrix: Matrix;
  8424. /** @hidden */
  8425. _camMatrix: Matrix;
  8426. /** @hidden */
  8427. _cameraTransformMatrix: Matrix;
  8428. /** @hidden */
  8429. _cameraRotationMatrix: Matrix;
  8430. /** @hidden */
  8431. _referencePoint: Vector3;
  8432. /** @hidden */
  8433. _transformedReferencePoint: Vector3;
  8434. protected _globalCurrentTarget: Vector3;
  8435. protected _globalCurrentUpVector: Vector3;
  8436. /** @hidden */
  8437. _reset: () => void;
  8438. private _defaultUp;
  8439. /**
  8440. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8441. * This is the base of the follow, arc rotate cameras and Free camera
  8442. * @see http://doc.babylonjs.com/features/cameras
  8443. * @param name Defines the name of the camera in the scene
  8444. * @param position Defines the start position of the camera in the scene
  8445. * @param scene Defines the scene the camera belongs to
  8446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8447. */
  8448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8449. /**
  8450. * Gets the position in front of the camera at a given distance.
  8451. * @param distance The distance from the camera we want the position to be
  8452. * @returns the position
  8453. */
  8454. getFrontPosition(distance: number): Vector3;
  8455. /** @hidden */
  8456. _getLockedTargetPosition(): Nullable<Vector3>;
  8457. private _storedPosition;
  8458. private _storedRotation;
  8459. private _storedRotationQuaternion;
  8460. /**
  8461. * Store current camera state of the camera (fov, position, rotation, etc..)
  8462. * @returns the camera
  8463. */
  8464. storeState(): Camera;
  8465. /**
  8466. * Restored camera state. You must call storeState() first
  8467. * @returns whether it was successful or not
  8468. * @hidden
  8469. */
  8470. _restoreStateValues(): boolean;
  8471. /** @hidden */
  8472. _initCache(): void;
  8473. /** @hidden */
  8474. _updateCache(ignoreParentClass?: boolean): void;
  8475. /** @hidden */
  8476. _isSynchronizedViewMatrix(): boolean;
  8477. /** @hidden */
  8478. _computeLocalCameraSpeed(): number;
  8479. /** @hidden */
  8480. setTarget(target: Vector3): void;
  8481. /**
  8482. * Return the current target position of the camera. This value is expressed in local space.
  8483. * @returns the target position
  8484. */
  8485. getTarget(): Vector3;
  8486. /** @hidden */
  8487. _decideIfNeedsToMove(): boolean;
  8488. /** @hidden */
  8489. _updatePosition(): void;
  8490. /** @hidden */
  8491. _checkInputs(): void;
  8492. protected _updateCameraRotationMatrix(): void;
  8493. /**
  8494. * 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)
  8495. * @returns the current camera
  8496. */
  8497. private _rotateUpVectorWithCameraRotationMatrix;
  8498. private _cachedRotationZ;
  8499. private _cachedQuaternionRotationZ;
  8500. /** @hidden */
  8501. _getViewMatrix(): Matrix;
  8502. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8503. /**
  8504. * @hidden
  8505. */
  8506. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8507. /**
  8508. * @hidden
  8509. */
  8510. _updateRigCameras(): void;
  8511. private _getRigCamPositionAndTarget;
  8512. /**
  8513. * Gets the current object class name.
  8514. * @return the class name
  8515. */
  8516. getClassName(): string;
  8517. }
  8518. }
  8519. declare module "babylonjs/Cameras/cameraInputsManager" {
  8520. import { Nullable } from "babylonjs/types";
  8521. import { Camera } from "babylonjs/Cameras/camera";
  8522. /**
  8523. * @ignore
  8524. * This is a list of all the different input types that are available in the application.
  8525. * Fo instance: ArcRotateCameraGamepadInput...
  8526. */
  8527. export var CameraInputTypes: {};
  8528. /**
  8529. * This is the contract to implement in order to create a new input class.
  8530. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8531. */
  8532. export interface ICameraInput<TCamera extends Camera> {
  8533. /**
  8534. * Defines the camera the input is attached to.
  8535. */
  8536. camera: Nullable<TCamera>;
  8537. /**
  8538. * Gets the class name of the current intput.
  8539. * @returns the class name
  8540. */
  8541. getClassName(): string;
  8542. /**
  8543. * Get the friendly name associated with the input class.
  8544. * @returns the input friendly name
  8545. */
  8546. getSimpleName(): string;
  8547. /**
  8548. * Attach the input controls to a specific dom element to get the input from.
  8549. * @param element Defines the element the controls should be listened from
  8550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8551. */
  8552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8553. /**
  8554. * Detach the current controls from the specified dom element.
  8555. * @param element Defines the element to stop listening the inputs from
  8556. */
  8557. detachControl(element: Nullable<HTMLElement>): void;
  8558. /**
  8559. * Update the current camera state depending on the inputs that have been used this frame.
  8560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8561. */
  8562. checkInputs?: () => void;
  8563. }
  8564. /**
  8565. * Represents a map of input types to input instance or input index to input instance.
  8566. */
  8567. export interface CameraInputsMap<TCamera extends Camera> {
  8568. /**
  8569. * Accessor to the input by input type.
  8570. */
  8571. [name: string]: ICameraInput<TCamera>;
  8572. /**
  8573. * Accessor to the input by input index.
  8574. */
  8575. [idx: number]: ICameraInput<TCamera>;
  8576. }
  8577. /**
  8578. * This represents the input manager used within a camera.
  8579. * It helps dealing with all the different kind of input attached to a camera.
  8580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8581. */
  8582. export class CameraInputsManager<TCamera extends Camera> {
  8583. /**
  8584. * Defines the list of inputs attahed to the camera.
  8585. */
  8586. attached: CameraInputsMap<TCamera>;
  8587. /**
  8588. * Defines the dom element the camera is collecting inputs from.
  8589. * This is null if the controls have not been attached.
  8590. */
  8591. attachedElement: Nullable<HTMLElement>;
  8592. /**
  8593. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8594. */
  8595. noPreventDefault: boolean;
  8596. /**
  8597. * Defined the camera the input manager belongs to.
  8598. */
  8599. camera: TCamera;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs: () => void;
  8605. /**
  8606. * Instantiate a new Camera Input Manager.
  8607. * @param camera Defines the camera the input manager blongs to
  8608. */
  8609. constructor(camera: TCamera);
  8610. /**
  8611. * Add an input method to a camera
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. * @param input camera input method
  8614. */
  8615. add(input: ICameraInput<TCamera>): void;
  8616. /**
  8617. * Remove a specific input method from a camera
  8618. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8619. * @param inputToRemove camera input method
  8620. */
  8621. remove(inputToRemove: ICameraInput<TCamera>): void;
  8622. /**
  8623. * Remove a specific input type from a camera
  8624. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8625. * @param inputType the type of the input to remove
  8626. */
  8627. removeByType(inputType: string): void;
  8628. private _addCheckInputs;
  8629. /**
  8630. * Attach the input controls to the currently attached dom element to listen the events from.
  8631. * @param input Defines the input to attach
  8632. */
  8633. attachInput(input: ICameraInput<TCamera>): void;
  8634. /**
  8635. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8636. * @param element Defines the dom element to collect the events from
  8637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8638. */
  8639. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current manager inputs controls from a specific dom element.
  8642. * @param element Defines the dom element to collect the events from
  8643. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8644. */
  8645. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8646. /**
  8647. * Rebuild the dynamic inputCheck function from the current list of
  8648. * defined inputs in the manager.
  8649. */
  8650. rebuildInputCheck(): void;
  8651. /**
  8652. * Remove all attached input methods from a camera
  8653. */
  8654. clear(): void;
  8655. /**
  8656. * Serialize the current input manager attached to a camera.
  8657. * This ensures than once parsed,
  8658. * the input associated to the camera will be identical to the current ones
  8659. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8660. */
  8661. serialize(serializedCamera: any): void;
  8662. /**
  8663. * Parses an input manager serialized JSON to restore the previous list of inputs
  8664. * and states associated to a camera.
  8665. * @param parsedCamera Defines the JSON to parse
  8666. */
  8667. parse(parsedCamera: any): void;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/materialHelper" {
  9052. import { Nullable } from "babylonjs/types";
  9053. import { Scene } from "babylonjs/scene";
  9054. import { Engine } from "babylonjs/Engines/engine";
  9055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9056. import { Light } from "babylonjs/Lights/light";
  9057. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9058. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9060. /**
  9061. * "Static Class" containing the most commonly used helper while dealing with material for
  9062. * rendering purpose.
  9063. *
  9064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9065. *
  9066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9067. */
  9068. export class MaterialHelper {
  9069. /**
  9070. * Bind the current view position to an effect.
  9071. * @param effect The effect to be bound
  9072. * @param scene The scene the eyes position is used from
  9073. */
  9074. static BindEyePosition(effect: Effect, scene: Scene): void;
  9075. /**
  9076. * Helps preparing the defines values about the UVs in used in the effect.
  9077. * UVs are shared as much as we can accross channels in the shaders.
  9078. * @param texture The texture we are preparing the UVs for
  9079. * @param defines The defines to update
  9080. * @param key The channel key "diffuse", "specular"... used in the shader
  9081. */
  9082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9083. /**
  9084. * Binds a texture matrix value to its corrsponding uniform
  9085. * @param texture The texture to bind the matrix for
  9086. * @param uniformBuffer The uniform buffer receivin the data
  9087. * @param key The channel key "diffuse", "specular"... used in the shader
  9088. */
  9089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9090. /**
  9091. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9092. * @param mesh defines the current mesh
  9093. * @param scene defines the current scene
  9094. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9095. * @param pointsCloud defines if point cloud rendering has to be turned on
  9096. * @param fogEnabled defines if fog has to be turned on
  9097. * @param alphaTest defines if alpha testing has to be turned on
  9098. * @param defines defines the current list of defines
  9099. */
  9100. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9101. /**
  9102. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9103. * @param scene defines the current scene
  9104. * @param engine defines the current engine
  9105. * @param defines specifies the list of active defines
  9106. * @param useInstances defines if instances have to be turned on
  9107. * @param useClipPlane defines if clip plane have to be turned on
  9108. */
  9109. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9110. /**
  9111. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9112. * @param mesh The mesh containing the geometry data we will draw
  9113. * @param defines The defines to update
  9114. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9115. * @param useBones Precise whether bones should be used or not (override mesh info)
  9116. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9117. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9118. * @returns false if defines are considered not dirty and have not been checked
  9119. */
  9120. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9121. /**
  9122. * Prepares the defines related to the light information passed in parameter
  9123. * @param scene The scene we are intending to draw
  9124. * @param mesh The mesh the effect is compiling for
  9125. * @param defines The defines to update
  9126. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9127. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9128. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9129. * @returns true if normals will be required for the rest of the effect
  9130. */
  9131. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9132. /**
  9133. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9134. * that won t be acctive due to defines being turned off.
  9135. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9136. * @param samplersList The samplers list
  9137. * @param defines The defines helping in the list generation
  9138. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9139. */
  9140. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9141. /**
  9142. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9143. * @param defines The defines to update while falling back
  9144. * @param fallbacks The authorized effect fallbacks
  9145. * @param maxSimultaneousLights The maximum number of lights allowed
  9146. * @param rank the current rank of the Effect
  9147. * @returns The newly affected rank
  9148. */
  9149. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9150. /**
  9151. * Prepares the list of attributes required for morph targets according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the morph targets attributes for
  9154. * @param defines The current Defines of the effect
  9155. */
  9156. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9157. /**
  9158. * Prepares the list of attributes required for bones according to the effect defines.
  9159. * @param attribs The current list of supported attribs
  9160. * @param mesh The mesh to prepare the bones attributes for
  9161. * @param defines The current Defines of the effect
  9162. * @param fallbacks The current efffect fallback strategy
  9163. */
  9164. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9165. /**
  9166. * Prepares the list of attributes required for instances according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param defines The current Defines of the effect
  9169. */
  9170. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9171. /**
  9172. * Binds the light shadow information to the effect for the given mesh.
  9173. * @param light The light containing the generator
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param lightIndex The light index in the effect used to render the mesh
  9177. * @param effect The effect we are binding the data to
  9178. */
  9179. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9180. /**
  9181. * Binds the light information to the effect.
  9182. * @param light The light containing the generator
  9183. * @param effect The effect we are binding the data to
  9184. * @param lightIndex The light index in the effect used to render
  9185. */
  9186. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. */
  9196. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9197. private static _tempFogColor;
  9198. /**
  9199. * Binds the fog information from the scene to the effect for the given mesh.
  9200. * @param scene The scene the lights belongs to
  9201. * @param mesh The mesh we are binding the information to render
  9202. * @param effect The effect we are binding the data to
  9203. * @param linearSpace Defines if the fog effect is applied in linear space
  9204. */
  9205. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9206. /**
  9207. * Binds the bones information from the mesh to the effect.
  9208. * @param mesh The mesh we are binding the information to render
  9209. * @param effect The effect we are binding the data to
  9210. */
  9211. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9212. /**
  9213. * Binds the morph targets information from the mesh to the effect.
  9214. * @param abstractMesh The mesh we are binding the information to render
  9215. * @param effect The effect we are binding the data to
  9216. */
  9217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9218. /**
  9219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9220. * @param defines The generated defines used in the effect
  9221. * @param effect The effect we are binding the data to
  9222. * @param scene The scene we are willing to render with logarithmic scale for
  9223. */
  9224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9225. /**
  9226. * Binds the clip plane information from the scene to the effect.
  9227. * @param scene The scene the clip plane information are extracted from
  9228. * @param effect The effect we are binding the data to
  9229. */
  9230. static BindClipPlane(effect: Effect, scene: Scene): void;
  9231. }
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9234. /** @hidden */
  9235. export var kernelBlurVaryingDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9241. /** @hidden */
  9242. export var kernelBlurFragment: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9248. /** @hidden */
  9249. export var kernelBlurFragment2: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9255. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9256. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9257. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9258. /** @hidden */
  9259. export var kernelBlurPixelShader: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9265. /** @hidden */
  9266. export var kernelBlurVertex: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9274. /** @hidden */
  9275. export var kernelBlurVertexShader: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9281. import { Vector2 } from "babylonjs/Maths/math";
  9282. import { Nullable } from "babylonjs/types";
  9283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9284. import { Camera } from "babylonjs/Cameras/camera";
  9285. import { Effect } from "babylonjs/Materials/effect";
  9286. import { Engine } from "babylonjs/Engines/engine";
  9287. import "babylonjs/Shaders/kernelBlur.fragment";
  9288. import "babylonjs/Shaders/kernelBlur.vertex";
  9289. /**
  9290. * The Blur Post Process which blurs an image based on a kernel and direction.
  9291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9292. */
  9293. export class BlurPostProcess extends PostProcess {
  9294. /** The direction in which to blur the image. */
  9295. direction: Vector2;
  9296. private blockCompilation;
  9297. protected _kernel: number;
  9298. protected _idealKernel: number;
  9299. protected _packedFloat: boolean;
  9300. private _staticDefines;
  9301. /**
  9302. * Sets the length in pixels of the blur sample region
  9303. */
  9304. /**
  9305. * Gets the length in pixels of the blur sample region
  9306. */
  9307. kernel: number;
  9308. /**
  9309. * Sets wether or not the blur needs to unpack/repack floats
  9310. */
  9311. /**
  9312. * Gets wether or not the blur is unpacking/repacking floats
  9313. */
  9314. packedFloat: boolean;
  9315. /**
  9316. * Creates a new instance BlurPostProcess
  9317. * @param name The name of the effect.
  9318. * @param direction The direction in which to blur the image.
  9319. * @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.
  9320. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9321. * @param camera The camera to apply the render pass to.
  9322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9323. * @param engine The engine which the post process will be applied. (default: current engine)
  9324. * @param reusable If the post process can be reused on the same frame. (default: false)
  9325. * @param textureType Type of textures used when performing the post process. (default: 0)
  9326. * @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)
  9327. */
  9328. constructor(name: string,
  9329. /** The direction in which to blur the image. */
  9330. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9331. /**
  9332. * Updates the effect with the current post process compile time values and recompiles the shader.
  9333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9336. * @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
  9337. * @param onCompiled Called when the shader has been compiled.
  9338. * @param onError Called if there is an error when compiling a shader.
  9339. */
  9340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9341. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9342. /**
  9343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9347. * The gaps between physical kernels are compensated for in the weighting of the samples
  9348. * @param idealKernel Ideal blur kernel.
  9349. * @return Nearest best kernel.
  9350. */
  9351. protected _nearestBestKernel(idealKernel: number): number;
  9352. /**
  9353. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9354. * @param x The point on the Gaussian distribution to sample.
  9355. * @return the value of the Gaussian function at x.
  9356. */
  9357. protected _gaussianWeight(x: number): number;
  9358. /**
  9359. * Generates a string that can be used as a floating point number in GLSL.
  9360. * @param x Value to print.
  9361. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9362. * @return GLSL float string.
  9363. */
  9364. protected _glslFloat(x: number, decimalFigures?: number): string;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9368. /** @hidden */
  9369. export var shadowMapPixelShader: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9375. /** @hidden */
  9376. export var bonesDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9382. /** @hidden */
  9383. export var morphTargetsVertexGlobalDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9389. /** @hidden */
  9390. export var morphTargetsVertexDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9396. /** @hidden */
  9397. export var instancesDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9403. /** @hidden */
  9404. export var helperFunctions: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9410. /** @hidden */
  9411. export var morphTargetsVertex: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9417. /** @hidden */
  9418. export var instancesVertex: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9424. /** @hidden */
  9425. export var bonesVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9431. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9439. /** @hidden */
  9440. export var shadowMapVertexShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9446. /** @hidden */
  9447. export var depthBoxBlurPixelShader: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9453. import { Nullable } from "babylonjs/types";
  9454. import { Scene } from "babylonjs/scene";
  9455. import { Matrix } from "babylonjs/Maths/math";
  9456. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9458. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9459. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9460. import { Effect } from "babylonjs/Materials/effect";
  9461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9462. import "babylonjs/Shaders/shadowMap.fragment";
  9463. import "babylonjs/Shaders/shadowMap.vertex";
  9464. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9465. import { Observable } from "babylonjs/Misc/observable";
  9466. /**
  9467. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9468. */
  9469. export interface ICustomShaderOptions {
  9470. /**
  9471. * Gets or sets the custom shader name to use
  9472. */
  9473. shaderName: string;
  9474. /**
  9475. * The list of attribute names used in the shader
  9476. */
  9477. attributes?: string[];
  9478. /**
  9479. * The list of unifrom names used in the shader
  9480. */
  9481. uniforms?: string[];
  9482. /**
  9483. * The list of sampler names used in the shader
  9484. */
  9485. samplers?: string[];
  9486. /**
  9487. * The list of defines used in the shader
  9488. */
  9489. defines?: string[];
  9490. }
  9491. /**
  9492. * Interface to implement to create a shadow generator compatible with BJS.
  9493. */
  9494. export interface IShadowGenerator {
  9495. /**
  9496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9497. * @returns The render target texture if present otherwise, null
  9498. */
  9499. getShadowMap(): Nullable<RenderTargetTexture>;
  9500. /**
  9501. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9502. * @returns The render target texture if the shadow map is present otherwise, null
  9503. */
  9504. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9505. /**
  9506. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9507. * @param subMesh The submesh we want to render in the shadow map
  9508. * @param useInstances Defines wether will draw in the map using instances
  9509. * @returns true if ready otherwise, false
  9510. */
  9511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9512. /**
  9513. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9514. * @param defines Defines of the material we want to update
  9515. * @param lightIndex Index of the light in the enabled light list of the material
  9516. */
  9517. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9518. /**
  9519. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9520. * defined in the generator but impacting the effect).
  9521. * It implies the unifroms available on the materials are the standard BJS ones.
  9522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9523. * @param effect The effect we are binfing the information for
  9524. */
  9525. bindShadowLight(lightIndex: string, effect: Effect): void;
  9526. /**
  9527. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9528. * (eq to shadow prjection matrix * light transform matrix)
  9529. * @returns The transform matrix used to create the shadow map
  9530. */
  9531. getTransformMatrix(): Matrix;
  9532. /**
  9533. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9534. * Cube and 2D textures for instance.
  9535. */
  9536. recreateShadowMap(): void;
  9537. /**
  9538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9539. * @param onCompiled Callback triggered at the and of the effects compilation
  9540. * @param options Sets of optional options forcing the compilation with different modes
  9541. */
  9542. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9543. useInstances: boolean;
  9544. }>): void;
  9545. /**
  9546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9547. * @param options Sets of optional options forcing the compilation with different modes
  9548. * @returns A promise that resolves when the compilation completes
  9549. */
  9550. forceCompilationAsync(options?: Partial<{
  9551. useInstances: boolean;
  9552. }>): Promise<void>;
  9553. /**
  9554. * Serializes the shadow generator setup to a json object.
  9555. * @returns The serialized JSON object
  9556. */
  9557. serialize(): any;
  9558. /**
  9559. * Disposes the Shadow map and related Textures and effects.
  9560. */
  9561. dispose(): void;
  9562. }
  9563. /**
  9564. * Default implementation IShadowGenerator.
  9565. * This is the main object responsible of generating shadows in the framework.
  9566. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9567. */
  9568. export class ShadowGenerator implements IShadowGenerator {
  9569. /**
  9570. * Shadow generator mode None: no filtering applied.
  9571. */
  9572. static readonly FILTER_NONE: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9576. */
  9577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9578. /**
  9579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9581. */
  9582. static readonly FILTER_POISSONSAMPLING: number;
  9583. /**
  9584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9590. * edge artifacts on steep falloff.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9596. * edge artifacts on steep falloff.
  9597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9598. */
  9599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9600. /**
  9601. * Shadow generator mode PCF: Percentage Closer Filtering
  9602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9604. */
  9605. static readonly FILTER_PCF: number;
  9606. /**
  9607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9609. * Contact Hardening
  9610. */
  9611. static readonly FILTER_PCSS: number;
  9612. /**
  9613. * Reserved for PCF and PCSS
  9614. * Highest Quality.
  9615. *
  9616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9617. *
  9618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9619. */
  9620. static readonly QUALITY_HIGH: number;
  9621. /**
  9622. * Reserved for PCF and PCSS
  9623. * Good tradeoff for quality/perf cross devices
  9624. *
  9625. * Execute PCF on a 3*3 kernel.
  9626. *
  9627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9628. */
  9629. static readonly QUALITY_MEDIUM: number;
  9630. /**
  9631. * Reserved for PCF and PCSS
  9632. * The lowest quality but the fastest.
  9633. *
  9634. * Execute PCF on a 1*1 kernel.
  9635. *
  9636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9637. */
  9638. static readonly QUALITY_LOW: number;
  9639. /** Gets or sets the custom shader name to use */
  9640. customShaderOptions: ICustomShaderOptions;
  9641. /**
  9642. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9643. */
  9644. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9645. private _bias;
  9646. /**
  9647. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9648. */
  9649. /**
  9650. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9651. */
  9652. bias: number;
  9653. private _normalBias;
  9654. /**
  9655. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9656. */
  9657. /**
  9658. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9659. */
  9660. normalBias: number;
  9661. private _blurBoxOffset;
  9662. /**
  9663. * Gets the blur box offset: offset applied during the blur pass.
  9664. * Only useful if useKernelBlur = false
  9665. */
  9666. /**
  9667. * Sets the blur box offset: offset applied during the blur pass.
  9668. * Only useful if useKernelBlur = false
  9669. */
  9670. blurBoxOffset: number;
  9671. private _blurScale;
  9672. /**
  9673. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9674. * 2 means half of the size.
  9675. */
  9676. /**
  9677. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9678. * 2 means half of the size.
  9679. */
  9680. blurScale: number;
  9681. private _blurKernel;
  9682. /**
  9683. * Gets the blur kernel: kernel size of the blur pass.
  9684. * Only useful if useKernelBlur = true
  9685. */
  9686. /**
  9687. * Sets the blur kernel: kernel size of the blur pass.
  9688. * Only useful if useKernelBlur = true
  9689. */
  9690. blurKernel: number;
  9691. private _useKernelBlur;
  9692. /**
  9693. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9694. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9695. */
  9696. /**
  9697. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9699. */
  9700. useKernelBlur: boolean;
  9701. private _depthScale;
  9702. /**
  9703. * Gets the depth scale used in ESM mode.
  9704. */
  9705. /**
  9706. * Sets the depth scale used in ESM mode.
  9707. * This can override the scale stored on the light.
  9708. */
  9709. depthScale: number;
  9710. private _filter;
  9711. /**
  9712. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9713. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9714. */
  9715. /**
  9716. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9717. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9718. */
  9719. filter: number;
  9720. /**
  9721. * Gets if the current filter is set to Poisson Sampling.
  9722. */
  9723. /**
  9724. * Sets the current filter to Poisson Sampling.
  9725. */
  9726. usePoissonSampling: boolean;
  9727. /**
  9728. * Gets if the current filter is set to ESM.
  9729. */
  9730. /**
  9731. * Sets the current filter is to ESM.
  9732. */
  9733. useExponentialShadowMap: boolean;
  9734. /**
  9735. * Gets if the current filter is set to filtered ESM.
  9736. */
  9737. /**
  9738. * Gets if the current filter is set to filtered ESM.
  9739. */
  9740. useBlurExponentialShadowMap: boolean;
  9741. /**
  9742. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9743. * exponential to prevent steep falloff artifacts).
  9744. */
  9745. /**
  9746. * Sets the current filter to "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. useCloseExponentialShadowMap: boolean;
  9750. /**
  9751. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9752. * exponential to prevent steep falloff artifacts).
  9753. */
  9754. /**
  9755. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9756. * exponential to prevent steep falloff artifacts).
  9757. */
  9758. useBlurCloseExponentialShadowMap: boolean;
  9759. /**
  9760. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9761. */
  9762. /**
  9763. * Sets the current filter to "PCF" (percentage closer filtering).
  9764. */
  9765. usePercentageCloserFiltering: boolean;
  9766. private _filteringQuality;
  9767. /**
  9768. * Gets the PCF or PCSS Quality.
  9769. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9770. */
  9771. /**
  9772. * Sets the PCF or PCSS Quality.
  9773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9774. */
  9775. filteringQuality: number;
  9776. /**
  9777. * Gets if the current filter is set to "PCSS" (contact hardening).
  9778. */
  9779. /**
  9780. * Sets the current filter to "PCSS" (contact hardening).
  9781. */
  9782. useContactHardeningShadow: boolean;
  9783. private _contactHardeningLightSizeUVRatio;
  9784. /**
  9785. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9786. * Using a ratio helps keeping shape stability independently of the map size.
  9787. *
  9788. * It does not account for the light projection as it was having too much
  9789. * instability during the light setup or during light position changes.
  9790. *
  9791. * Only valid if useContactHardeningShadow is true.
  9792. */
  9793. /**
  9794. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9795. * Using a ratio helps keeping shape stability independently of the map size.
  9796. *
  9797. * It does not account for the light projection as it was having too much
  9798. * instability during the light setup or during light position changes.
  9799. *
  9800. * Only valid if useContactHardeningShadow is true.
  9801. */
  9802. contactHardeningLightSizeUVRatio: number;
  9803. private _darkness;
  9804. /**
  9805. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9806. * 0 means strongest and 1 would means no shadow.
  9807. * @returns the darkness.
  9808. */
  9809. getDarkness(): number;
  9810. /**
  9811. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9812. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9813. * @returns the shadow generator allowing fluent coding.
  9814. */
  9815. setDarkness(darkness: number): ShadowGenerator;
  9816. private _transparencyShadow;
  9817. /**
  9818. * Sets the ability to have transparent shadow (boolean).
  9819. * @param transparent True if transparent else False
  9820. * @returns the shadow generator allowing fluent coding
  9821. */
  9822. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9823. private _shadowMap;
  9824. private _shadowMap2;
  9825. /**
  9826. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9827. * @returns The render target texture if present otherwise, null
  9828. */
  9829. getShadowMap(): Nullable<RenderTargetTexture>;
  9830. /**
  9831. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9832. * @returns The render target texture if the shadow map is present otherwise, null
  9833. */
  9834. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9835. /**
  9836. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9837. * @param mesh Mesh to add
  9838. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9839. * @returns the Shadow Generator itself
  9840. */
  9841. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9842. /**
  9843. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9844. * @param mesh Mesh to remove
  9845. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9846. * @returns the Shadow Generator itself
  9847. */
  9848. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9849. /**
  9850. * Controls the extent to which the shadows fade out at the edge of the frustum
  9851. * Used only by directionals and spots
  9852. */
  9853. frustumEdgeFalloff: number;
  9854. private _light;
  9855. /**
  9856. * Returns the associated light object.
  9857. * @returns the light generating the shadow
  9858. */
  9859. getLight(): IShadowLight;
  9860. /**
  9861. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9862. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9863. * It might on the other hand introduce peter panning.
  9864. */
  9865. forceBackFacesOnly: boolean;
  9866. private _scene;
  9867. private _lightDirection;
  9868. private _effect;
  9869. private _viewMatrix;
  9870. private _projectionMatrix;
  9871. private _transformMatrix;
  9872. private _cachedPosition;
  9873. private _cachedDirection;
  9874. private _cachedDefines;
  9875. private _currentRenderID;
  9876. private _boxBlurPostprocess;
  9877. private _kernelBlurXPostprocess;
  9878. private _kernelBlurYPostprocess;
  9879. private _blurPostProcesses;
  9880. private _mapSize;
  9881. private _currentFaceIndex;
  9882. private _currentFaceIndexCache;
  9883. private _textureType;
  9884. private _defaultTextureMatrix;
  9885. /** @hidden */
  9886. static _SceneComponentInitialization: (scene: Scene) => void;
  9887. /**
  9888. * Creates a ShadowGenerator object.
  9889. * A ShadowGenerator is the required tool to use the shadows.
  9890. * Each light casting shadows needs to use its own ShadowGenerator.
  9891. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9892. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9893. * @param light The light object generating the shadows.
  9894. * @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.
  9895. */
  9896. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9897. private _initializeGenerator;
  9898. private _initializeShadowMap;
  9899. private _initializeBlurRTTAndPostProcesses;
  9900. private _renderForShadowMap;
  9901. private _renderSubMeshForShadowMap;
  9902. private _applyFilterValues;
  9903. /**
  9904. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9905. * @param onCompiled Callback triggered at the and of the effects compilation
  9906. * @param options Sets of optional options forcing the compilation with different modes
  9907. */
  9908. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9909. useInstances: boolean;
  9910. }>): void;
  9911. /**
  9912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9913. * @param options Sets of optional options forcing the compilation with different modes
  9914. * @returns A promise that resolves when the compilation completes
  9915. */
  9916. forceCompilationAsync(options?: Partial<{
  9917. useInstances: boolean;
  9918. }>): Promise<void>;
  9919. /**
  9920. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9921. * @param subMesh The submesh we want to render in the shadow map
  9922. * @param useInstances Defines wether will draw in the map using instances
  9923. * @returns true if ready otherwise, false
  9924. */
  9925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9926. /**
  9927. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9928. * @param defines Defines of the material we want to update
  9929. * @param lightIndex Index of the light in the enabled light list of the material
  9930. */
  9931. prepareDefines(defines: any, lightIndex: number): void;
  9932. /**
  9933. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9934. * defined in the generator but impacting the effect).
  9935. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9936. * @param effect The effect we are binfing the information for
  9937. */
  9938. bindShadowLight(lightIndex: string, effect: Effect): void;
  9939. /**
  9940. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9941. * (eq to shadow prjection matrix * light transform matrix)
  9942. * @returns The transform matrix used to create the shadow map
  9943. */
  9944. getTransformMatrix(): Matrix;
  9945. /**
  9946. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9947. * Cube and 2D textures for instance.
  9948. */
  9949. recreateShadowMap(): void;
  9950. private _disposeBlurPostProcesses;
  9951. private _disposeRTTandPostProcesses;
  9952. /**
  9953. * Disposes the ShadowGenerator.
  9954. * Returns nothing.
  9955. */
  9956. dispose(): void;
  9957. /**
  9958. * Serializes the shadow generator setup to a json object.
  9959. * @returns The serialized JSON object
  9960. */
  9961. serialize(): any;
  9962. /**
  9963. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9964. * @param parsedShadowGenerator The JSON object to parse
  9965. * @param scene The scene to create the shadow map for
  9966. * @returns The parsed shadow generator
  9967. */
  9968. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9969. }
  9970. }
  9971. declare module "babylonjs/Lights/light" {
  9972. import { Nullable } from "babylonjs/types";
  9973. import { Scene } from "babylonjs/scene";
  9974. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9975. import { Node } from "babylonjs/node";
  9976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9977. import { Effect } from "babylonjs/Materials/effect";
  9978. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9979. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9980. /**
  9981. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9982. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9983. * 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.
  9984. */
  9985. export abstract class Light extends Node {
  9986. /**
  9987. * Falloff Default: light is falling off following the material specification:
  9988. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9989. */
  9990. static readonly FALLOFF_DEFAULT: number;
  9991. /**
  9992. * Falloff Physical: light is falling off following the inverse squared distance law.
  9993. */
  9994. static readonly FALLOFF_PHYSICAL: number;
  9995. /**
  9996. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9997. * to enhance interoperability with other engines.
  9998. */
  9999. static readonly FALLOFF_GLTF: number;
  10000. /**
  10001. * Falloff Standard: light is falling off like in the standard material
  10002. * to enhance interoperability with other materials.
  10003. */
  10004. static readonly FALLOFF_STANDARD: number;
  10005. /**
  10006. * If every light affecting the material is in this lightmapMode,
  10007. * material.lightmapTexture adds or multiplies
  10008. * (depends on material.useLightmapAsShadowmap)
  10009. * after every other light calculations.
  10010. */
  10011. static readonly LIGHTMAP_DEFAULT: number;
  10012. /**
  10013. * material.lightmapTexture as only diffuse lighting from this light
  10014. * adds only specular lighting from this light
  10015. * adds dynamic shadows
  10016. */
  10017. static readonly LIGHTMAP_SPECULAR: number;
  10018. /**
  10019. * material.lightmapTexture as only lighting
  10020. * no light calculation from this light
  10021. * only adds dynamic shadows from this light
  10022. */
  10023. static readonly LIGHTMAP_SHADOWSONLY: number;
  10024. /**
  10025. * Each light type uses the default quantity according to its type:
  10026. * point/spot lights use luminous intensity
  10027. * directional lights use illuminance
  10028. */
  10029. static readonly INTENSITYMODE_AUTOMATIC: number;
  10030. /**
  10031. * lumen (lm)
  10032. */
  10033. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10034. /**
  10035. * candela (lm/sr)
  10036. */
  10037. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10038. /**
  10039. * lux (lm/m^2)
  10040. */
  10041. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10042. /**
  10043. * nit (cd/m^2)
  10044. */
  10045. static readonly INTENSITYMODE_LUMINANCE: number;
  10046. /**
  10047. * Light type const id of the point light.
  10048. */
  10049. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10050. /**
  10051. * Light type const id of the directional light.
  10052. */
  10053. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10054. /**
  10055. * Light type const id of the spot light.
  10056. */
  10057. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10058. /**
  10059. * Light type const id of the hemispheric light.
  10060. */
  10061. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10062. /**
  10063. * Diffuse gives the basic color to an object.
  10064. */
  10065. diffuse: Color3;
  10066. /**
  10067. * Specular produces a highlight color on an object.
  10068. * Note: This is note affecting PBR materials.
  10069. */
  10070. specular: Color3;
  10071. /**
  10072. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10073. * falling off base on range or angle.
  10074. * This can be set to any values in Light.FALLOFF_x.
  10075. *
  10076. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10077. * other types of materials.
  10078. */
  10079. falloffType: number;
  10080. /**
  10081. * Strength of the light.
  10082. * Note: By default it is define in the framework own unit.
  10083. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10084. */
  10085. intensity: number;
  10086. private _range;
  10087. protected _inverseSquaredRange: number;
  10088. /**
  10089. * Defines how far from the source the light is impacting in scene units.
  10090. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10091. */
  10092. /**
  10093. * Defines how far from the source the light is impacting in scene units.
  10094. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10095. */
  10096. range: number;
  10097. /**
  10098. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10099. * of light.
  10100. */
  10101. private _photometricScale;
  10102. private _intensityMode;
  10103. /**
  10104. * Gets the photometric scale used to interpret the intensity.
  10105. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10106. */
  10107. /**
  10108. * Sets the photometric scale used to interpret the intensity.
  10109. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10110. */
  10111. intensityMode: number;
  10112. private _radius;
  10113. /**
  10114. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10115. */
  10116. /**
  10117. * sets the light radius used by PBR Materials to simulate soft area lights.
  10118. */
  10119. radius: number;
  10120. private _renderPriority;
  10121. /**
  10122. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10123. * exceeding the number allowed of the materials.
  10124. */
  10125. renderPriority: number;
  10126. private _shadowEnabled;
  10127. /**
  10128. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10129. * the current shadow generator.
  10130. */
  10131. /**
  10132. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10133. * the current shadow generator.
  10134. */
  10135. shadowEnabled: boolean;
  10136. private _includedOnlyMeshes;
  10137. /**
  10138. * Gets the only meshes impacted by this light.
  10139. */
  10140. /**
  10141. * Sets the only meshes impacted by this light.
  10142. */
  10143. includedOnlyMeshes: AbstractMesh[];
  10144. private _excludedMeshes;
  10145. /**
  10146. * Gets the meshes not impacted by this light.
  10147. */
  10148. /**
  10149. * Sets the meshes not impacted by this light.
  10150. */
  10151. excludedMeshes: AbstractMesh[];
  10152. private _excludeWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are not impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are not impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. excludeWithLayerMask: number;
  10162. private _includeOnlyWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. includeOnlyWithLayerMask: number;
  10172. private _lightmapMode;
  10173. /**
  10174. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10175. */
  10176. /**
  10177. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10178. */
  10179. lightmapMode: number;
  10180. /**
  10181. * Shadow generator associted to the light.
  10182. * @hidden Internal use only.
  10183. */
  10184. _shadowGenerator: Nullable<IShadowGenerator>;
  10185. /**
  10186. * @hidden Internal use only.
  10187. */
  10188. _excludedMeshesIds: string[];
  10189. /**
  10190. * @hidden Internal use only.
  10191. */
  10192. _includedOnlyMeshesIds: string[];
  10193. /**
  10194. * The current light unifom buffer.
  10195. * @hidden Internal use only.
  10196. */
  10197. _uniformBuffer: UniformBuffer;
  10198. /**
  10199. * Creates a Light object in the scene.
  10200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10201. * @param name The firendly name of the light
  10202. * @param scene The scene the light belongs too
  10203. */
  10204. constructor(name: string, scene: Scene);
  10205. protected abstract _buildUniformLayout(): void;
  10206. /**
  10207. * Sets the passed Effect "effect" with the Light information.
  10208. * @param effect The effect to update
  10209. * @param lightIndex The index of the light in the effect to update
  10210. * @returns The light
  10211. */
  10212. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10213. /**
  10214. * Returns the string "Light".
  10215. * @returns the class name
  10216. */
  10217. getClassName(): string;
  10218. /** @hidden */
  10219. readonly _isLight: boolean;
  10220. /**
  10221. * Converts the light information to a readable string for debug purpose.
  10222. * @param fullDetails Supports for multiple levels of logging within scene loading
  10223. * @returns the human readable light info
  10224. */
  10225. toString(fullDetails?: boolean): string;
  10226. /** @hidden */
  10227. protected _syncParentEnabledState(): void;
  10228. /**
  10229. * Set the enabled state of this node.
  10230. * @param value - the new enabled state
  10231. */
  10232. setEnabled(value: boolean): void;
  10233. /**
  10234. * Returns the Light associated shadow generator if any.
  10235. * @return the associated shadow generator.
  10236. */
  10237. getShadowGenerator(): Nullable<IShadowGenerator>;
  10238. /**
  10239. * Returns a Vector3, the absolute light position in the World.
  10240. * @returns the world space position of the light
  10241. */
  10242. getAbsolutePosition(): Vector3;
  10243. /**
  10244. * Specifies if the light will affect the passed mesh.
  10245. * @param mesh The mesh to test against the light
  10246. * @return true the mesh is affected otherwise, false.
  10247. */
  10248. canAffectMesh(mesh: AbstractMesh): boolean;
  10249. /**
  10250. * Sort function to order lights for rendering.
  10251. * @param a First Light object to compare to second.
  10252. * @param b Second Light object to compare first.
  10253. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10254. */
  10255. static CompareLightsPriority(a: Light, b: Light): number;
  10256. /**
  10257. * Releases resources associated with this node.
  10258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10260. */
  10261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10262. /**
  10263. * Returns the light type ID (integer).
  10264. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10265. */
  10266. getTypeID(): number;
  10267. /**
  10268. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10269. * @returns the scaled intensity in intensity mode unit
  10270. */
  10271. getScaledIntensity(): number;
  10272. /**
  10273. * Returns a new Light object, named "name", from the current one.
  10274. * @param name The name of the cloned light
  10275. * @returns the new created light
  10276. */
  10277. clone(name: string): Nullable<Light>;
  10278. /**
  10279. * Serializes the current light into a Serialization object.
  10280. * @returns the serialized object.
  10281. */
  10282. serialize(): any;
  10283. /**
  10284. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10285. * This new light is named "name" and added to the passed scene.
  10286. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10287. * @param name The friendly name of the light
  10288. * @param scene The scene the new light will belong to
  10289. * @returns the constructor function
  10290. */
  10291. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10292. /**
  10293. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10294. * @param parsedLight The JSON representation of the light
  10295. * @param scene The scene to create the parsed light in
  10296. * @returns the created light after parsing
  10297. */
  10298. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10299. private _hookArrayForExcluded;
  10300. private _hookArrayForIncludedOnly;
  10301. private _resyncMeshes;
  10302. /**
  10303. * Forces the meshes to update their light related information in their rendering used effects
  10304. * @hidden Internal Use Only
  10305. */
  10306. _markMeshesAsLightDirty(): void;
  10307. /**
  10308. * Recomputes the cached photometric scale if needed.
  10309. */
  10310. private _computePhotometricScale;
  10311. /**
  10312. * Returns the Photometric Scale according to the light type and intensity mode.
  10313. */
  10314. private _getPhotometricScale;
  10315. /**
  10316. * Reorder the light in the scene according to their defined priority.
  10317. * @hidden Internal Use Only
  10318. */
  10319. _reorderLightsInScene(): void;
  10320. /**
  10321. * Prepares the list of defines specific to the light type.
  10322. * @param defines the list of defines
  10323. * @param lightIndex defines the index of the light for the effect
  10324. */
  10325. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10326. }
  10327. }
  10328. declare module "babylonjs/Actions/action" {
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Condition } from "babylonjs/Actions/condition";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. }
  10360. /**
  10361. * The action to be carried out following a trigger
  10362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10363. */
  10364. export class Action implements IAction {
  10365. /** the trigger, with or without parameters, for the action */
  10366. triggerOptions: any;
  10367. /**
  10368. * Trigger for the action
  10369. */
  10370. trigger: number;
  10371. /**
  10372. * Internal only - manager for action
  10373. * @hidden
  10374. */
  10375. _actionManager: ActionManager;
  10376. private _nextActiveAction;
  10377. private _child;
  10378. private _condition?;
  10379. private _triggerParameter;
  10380. /**
  10381. * An event triggered prior to action being executed.
  10382. */
  10383. onBeforeExecuteObservable: Observable<Action>;
  10384. /**
  10385. * Creates a new Action
  10386. * @param triggerOptions the trigger, with or without parameters, for the action
  10387. * @param condition an optional determinant of action
  10388. */
  10389. constructor(
  10390. /** the trigger, with or without parameters, for the action */
  10391. triggerOptions: any, condition?: Condition);
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _prepare(): void;
  10397. /**
  10398. * Gets the trigger parameters
  10399. * @returns the trigger parameters
  10400. */
  10401. getTriggerParameter(): any;
  10402. /**
  10403. * Internal only - executes current action event
  10404. * @hidden
  10405. */
  10406. _executeCurrent(evt?: ActionEvent): void;
  10407. /**
  10408. * Execute placeholder for child classes
  10409. * @param evt optional action event
  10410. */
  10411. execute(evt?: ActionEvent): void;
  10412. /**
  10413. * Skips to next active action
  10414. */
  10415. skipToNextActiveAction(): void;
  10416. /**
  10417. * Adds action to chain of actions, may be a DoNothingAction
  10418. * @param action defines the next action to execute
  10419. * @returns The action passed in
  10420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10421. */
  10422. then(action: Action): Action;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. _getProperty(propertyPath: string): string;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. _getEffectiveTarget(target: any, propertyPath: string): any;
  10433. /**
  10434. * Serialize placeholder for child classes
  10435. * @param parent of child
  10436. * @returns the serialized object
  10437. */
  10438. serialize(parent: any): any;
  10439. /**
  10440. * Internal only called by serialize
  10441. * @hidden
  10442. */
  10443. protected _serialize(serializedAction: any, parent?: any): any;
  10444. /**
  10445. * Internal only
  10446. * @hidden
  10447. */
  10448. static _SerializeValueAsString: (value: any) => string;
  10449. /**
  10450. * Internal only
  10451. * @hidden
  10452. */
  10453. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10454. name: string;
  10455. targetType: string;
  10456. value: string;
  10457. };
  10458. }
  10459. }
  10460. declare module "babylonjs/Actions/condition" {
  10461. import { ActionManager } from "babylonjs/Actions/actionManager";
  10462. /**
  10463. * A Condition applied to an Action
  10464. */
  10465. export class Condition {
  10466. /**
  10467. * Internal only - manager for action
  10468. * @hidden
  10469. */
  10470. _actionManager: ActionManager;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _evaluationId: number;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. _currentResult: boolean;
  10481. /**
  10482. * Creates a new Condition
  10483. * @param actionManager the manager of the action the condition is applied to
  10484. */
  10485. constructor(actionManager: ActionManager);
  10486. /**
  10487. * Check if the current condition is valid
  10488. * @returns a boolean
  10489. */
  10490. isValid(): boolean;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _getProperty(propertyPath: string): string;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _getEffectiveTarget(target: any, propertyPath: string): any;
  10501. /**
  10502. * Serialize placeholder for child classes
  10503. * @returns the serialized object
  10504. */
  10505. serialize(): any;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. protected _serialize(serializedCondition: any): any;
  10511. }
  10512. /**
  10513. * Defines specific conditional operators as extensions of Condition
  10514. */
  10515. export class ValueCondition extends Condition {
  10516. /** path to specify the property of the target the conditional operator uses */
  10517. propertyPath: string;
  10518. /** the value compared by the conditional operator against the current value of the property */
  10519. value: any;
  10520. /** the conditional operator, default ValueCondition.IsEqual */
  10521. operator: number;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. private static _IsEqual;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private static _IsDifferent;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsGreater;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private static _IsLesser;
  10542. /**
  10543. * returns the number for IsEqual
  10544. */
  10545. static readonly IsEqual: number;
  10546. /**
  10547. * Returns the number for IsDifferent
  10548. */
  10549. static readonly IsDifferent: number;
  10550. /**
  10551. * Returns the number for IsGreater
  10552. */
  10553. static readonly IsGreater: number;
  10554. /**
  10555. * Returns the number for IsLesser
  10556. */
  10557. static readonly IsLesser: number;
  10558. /**
  10559. * Internal only The action manager for the condition
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. /**
  10564. * Internal only
  10565. * @hidden
  10566. */
  10567. private _target;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */
  10572. private _effectiveTarget;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _property;
  10578. /**
  10579. * Creates a new ValueCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target for the action
  10582. * @param propertyPath path to specify the property of the target the conditional operator uses
  10583. * @param value the value compared by the conditional operator against the current value of the property
  10584. * @param operator the conditional operator, default ValueCondition.IsEqual
  10585. */
  10586. constructor(actionManager: ActionManager, target: any,
  10587. /** path to specify the property of the target the conditional operator uses */
  10588. propertyPath: string,
  10589. /** the value compared by the conditional operator against the current value of the property */
  10590. value: any,
  10591. /** the conditional operator, default ValueCondition.IsEqual */
  10592. operator?: number);
  10593. /**
  10594. * Compares the given value with the property value for the specified conditional operator
  10595. * @returns the result of the comparison
  10596. */
  10597. isValid(): boolean;
  10598. /**
  10599. * Serialize the ValueCondition into a JSON compatible object
  10600. * @returns serialization object
  10601. */
  10602. serialize(): any;
  10603. /**
  10604. * Gets the name of the conditional operator for the ValueCondition
  10605. * @param operator the conditional operator
  10606. * @returns the name
  10607. */
  10608. static GetOperatorName(operator: number): string;
  10609. }
  10610. /**
  10611. * Defines a predicate condition as an extension of Condition
  10612. */
  10613. export class PredicateCondition extends Condition {
  10614. /** defines the predicate function used to validate the condition */
  10615. predicate: () => boolean;
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */
  10620. _actionManager: ActionManager;
  10621. /**
  10622. * Creates a new PredicateCondition
  10623. * @param actionManager manager for the action the condition applies to
  10624. * @param predicate defines the predicate function used to validate the condition
  10625. */
  10626. constructor(actionManager: ActionManager,
  10627. /** defines the predicate function used to validate the condition */
  10628. predicate: () => boolean);
  10629. /**
  10630. * @returns the validity of the predicate condition
  10631. */
  10632. isValid(): boolean;
  10633. }
  10634. /**
  10635. * Defines a state condition as an extension of Condition
  10636. */
  10637. export class StateCondition extends Condition {
  10638. /** Value to compare with target state */
  10639. value: string;
  10640. /**
  10641. * Internal only - manager for action
  10642. * @hidden
  10643. */
  10644. _actionManager: ActionManager;
  10645. /**
  10646. * Internal only
  10647. * @hidden
  10648. */
  10649. private _target;
  10650. /**
  10651. * Creates a new StateCondition
  10652. * @param actionManager manager for the action the condition applies to
  10653. * @param target of the condition
  10654. * @param value to compare with target state
  10655. */
  10656. constructor(actionManager: ActionManager, target: any,
  10657. /** Value to compare with target state */
  10658. value: string);
  10659. /**
  10660. * Gets a boolean indicating if the current condition is met
  10661. * @returns the validity of the state
  10662. */
  10663. isValid(): boolean;
  10664. /**
  10665. * Serialize the StateCondition into a JSON compatible object
  10666. * @returns serialization object
  10667. */
  10668. serialize(): any;
  10669. }
  10670. }
  10671. declare module "babylonjs/Actions/directActions" {
  10672. import { Action } from "babylonjs/Actions/action";
  10673. import { Condition } from "babylonjs/Actions/condition";
  10674. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10675. /**
  10676. * This defines an action responsible to toggle a boolean once triggered.
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10678. */
  10679. export class SwitchBooleanAction extends Action {
  10680. /**
  10681. * The path to the boolean property in the target object
  10682. */
  10683. propertyPath: string;
  10684. private _target;
  10685. private _effectiveTarget;
  10686. private _property;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the object containing the boolean
  10691. * @param propertyPath defines the path to the boolean property in the target object
  10692. * @param condition defines the trigger related conditions
  10693. */
  10694. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10695. /** @hidden */
  10696. _prepare(): void;
  10697. /**
  10698. * Execute the action toggle the boolean value.
  10699. */
  10700. execute(): void;
  10701. /**
  10702. * Serializes the actions and its related information.
  10703. * @param parent defines the object to serialize in
  10704. * @returns the serialized object
  10705. */
  10706. serialize(parent: any): any;
  10707. }
  10708. /**
  10709. * This defines an action responsible to set a the state field of the target
  10710. * to a desired value once triggered.
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10712. */
  10713. export class SetStateAction extends Action {
  10714. /**
  10715. * The value to store in the state field.
  10716. */
  10717. value: string;
  10718. private _target;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the state property
  10723. * @param value defines the value to store in the state field
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10727. /**
  10728. * Execute the action and store the value on the target state property.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to set a property of the target
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class SetValueAction extends Action {
  10744. /**
  10745. * The path of the property to set in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value to set in the property
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to set in the target
  10760. * @param value defines the value to set in the property
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and set the targetted property to the desired value.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to increment the target value
  10779. * to a desired value once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class IncrementValueAction extends Action {
  10783. /**
  10784. * The path of the property to increment in the target.
  10785. */
  10786. propertyPath: string;
  10787. /**
  10788. * The value we should increment the property by.
  10789. */
  10790. value: any;
  10791. private _target;
  10792. private _effectiveTarget;
  10793. private _property;
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param target defines the object containing the property
  10798. * @param propertyPath defines the path of the property to increment in the target
  10799. * @param value defines the value value we should increment the property by
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10803. /** @hidden */
  10804. _prepare(): void;
  10805. /**
  10806. * Execute the action and increment the target of the value amount.
  10807. */
  10808. execute(): void;
  10809. /**
  10810. * Serializes the actions and its related information.
  10811. * @param parent defines the object to serialize in
  10812. * @returns the serialized object
  10813. */
  10814. serialize(parent: any): any;
  10815. }
  10816. /**
  10817. * This defines an action responsible to start an animation once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class PlayAnimationAction extends Action {
  10821. /**
  10822. * Where the animation should start (animation frame)
  10823. */
  10824. from: number;
  10825. /**
  10826. * Where the animation should stop (animation frame)
  10827. */
  10828. to: number;
  10829. /**
  10830. * Define if the animation should loop or stop after the first play.
  10831. */
  10832. loop?: boolean;
  10833. private _target;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the target animation or animation name
  10838. * @param from defines from where the animation should start (animation frame)
  10839. * @param end defines where the animation should stop (animation frame)
  10840. * @param loop defines if the animation should loop or stop after the first play
  10841. * @param condition defines the trigger related conditions
  10842. */
  10843. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10844. /** @hidden */
  10845. _prepare(): void;
  10846. /**
  10847. * Execute the action and play the animation.
  10848. */
  10849. execute(): void;
  10850. /**
  10851. * Serializes the actions and its related information.
  10852. * @param parent defines the object to serialize in
  10853. * @returns the serialized object
  10854. */
  10855. serialize(parent: any): any;
  10856. }
  10857. /**
  10858. * This defines an action responsible to stop an animation once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class StopAnimationAction extends Action {
  10862. private _target;
  10863. /**
  10864. * Instantiate the action
  10865. * @param triggerOptions defines the trigger options
  10866. * @param target defines the target animation or animation name
  10867. * @param condition defines the trigger related conditions
  10868. */
  10869. constructor(triggerOptions: any, target: any, condition?: Condition);
  10870. /** @hidden */
  10871. _prepare(): void;
  10872. /**
  10873. * Execute the action and stop the animation.
  10874. */
  10875. execute(): void;
  10876. /**
  10877. * Serializes the actions and its related information.
  10878. * @param parent defines the object to serialize in
  10879. * @returns the serialized object
  10880. */
  10881. serialize(parent: any): any;
  10882. }
  10883. /**
  10884. * This defines an action responsible that does nothing once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class DoNothingAction extends Action {
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param condition defines the trigger related conditions
  10892. */
  10893. constructor(triggerOptions?: any, condition?: Condition);
  10894. /**
  10895. * Execute the action and do nothing.
  10896. */
  10897. execute(): void;
  10898. /**
  10899. * Serializes the actions and its related information.
  10900. * @param parent defines the object to serialize in
  10901. * @returns the serialized object
  10902. */
  10903. serialize(parent: any): any;
  10904. }
  10905. /**
  10906. * This defines an action responsible to trigger several actions once triggered.
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10908. */
  10909. export class CombineAction extends Action {
  10910. /**
  10911. * The list of aggregated animations to run.
  10912. */
  10913. children: Action[];
  10914. /**
  10915. * Instantiate the action
  10916. * @param triggerOptions defines the trigger options
  10917. * @param children defines the list of aggregated animations to run
  10918. * @param condition defines the trigger related conditions
  10919. */
  10920. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10921. /** @hidden */
  10922. _prepare(): void;
  10923. /**
  10924. * Execute the action and executes all the aggregated actions.
  10925. */
  10926. execute(evt: ActionEvent): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to run code (external event) once triggered.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class ExecuteCodeAction extends Action {
  10939. /**
  10940. * The callback function to run.
  10941. */
  10942. func: (evt: ActionEvent) => void;
  10943. /**
  10944. * Instantiate the action
  10945. * @param triggerOptions defines the trigger options
  10946. * @param func defines the callback function to run
  10947. * @param condition defines the trigger related conditions
  10948. */
  10949. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10950. /**
  10951. * Execute the action and run the attached code.
  10952. */
  10953. execute(evt: ActionEvent): void;
  10954. }
  10955. /**
  10956. * This defines an action responsible to set the parent property of the target once triggered.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10958. */
  10959. export class SetParentAction extends Action {
  10960. private _parent;
  10961. private _target;
  10962. /**
  10963. * Instantiate the action
  10964. * @param triggerOptions defines the trigger options
  10965. * @param target defines the target containing the parent property
  10966. * @param parent defines from where the animation should start (animation frame)
  10967. * @param condition defines the trigger related conditions
  10968. */
  10969. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10970. /** @hidden */
  10971. _prepare(): void;
  10972. /**
  10973. * Execute the action and set the parent property.
  10974. */
  10975. execute(): void;
  10976. /**
  10977. * Serializes the actions and its related information.
  10978. * @param parent defines the object to serialize in
  10979. * @returns the serialized object
  10980. */
  10981. serialize(parent: any): any;
  10982. }
  10983. }
  10984. declare module "babylonjs/Actions/actionManager" {
  10985. import { Nullable } from "babylonjs/types";
  10986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10987. import { Scene } from "babylonjs/scene";
  10988. import { Action } from "babylonjs/Actions/action";
  10989. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10990. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10991. /**
  10992. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10993. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class ActionManager extends AbstractActionManager {
  10997. /**
  10998. * Nothing
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly NothingTrigger: number;
  11002. /**
  11003. * On pick
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnPickTrigger: number;
  11007. /**
  11008. * On left pick
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnLeftPickTrigger: number;
  11012. /**
  11013. * On right pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnRightPickTrigger: number;
  11017. /**
  11018. * On center pick
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnCenterPickTrigger: number;
  11022. /**
  11023. * On pick down
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickDownTrigger: number;
  11027. /**
  11028. * On double pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnDoublePickTrigger: number;
  11032. /**
  11033. * On pick up
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPickUpTrigger: number;
  11037. /**
  11038. * On pick out.
  11039. * This trigger will only be raised if you also declared a OnPickDown
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnPickOutTrigger: number;
  11043. /**
  11044. * On long press
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnLongPressTrigger: number;
  11048. /**
  11049. * On pointer over
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPointerOverTrigger: number;
  11053. /**
  11054. * On pointer out
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnPointerOutTrigger: number;
  11058. /**
  11059. * On every frame
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnEveryFrameTrigger: number;
  11063. /**
  11064. * On intersection enter
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnIntersectionEnterTrigger: number;
  11068. /**
  11069. * On intersection exit
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnIntersectionExitTrigger: number;
  11073. /**
  11074. * On key down
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnKeyDownTrigger: number;
  11078. /**
  11079. * On key up
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnKeyUpTrigger: number;
  11083. private _scene;
  11084. /**
  11085. * Creates a new action manager
  11086. * @param scene defines the hosting scene
  11087. */
  11088. constructor(scene: Scene);
  11089. /**
  11090. * Releases all associated resources
  11091. */
  11092. dispose(): void;
  11093. /**
  11094. * Gets hosting scene
  11095. * @returns the hosting scene
  11096. */
  11097. getScene(): Scene;
  11098. /**
  11099. * Does this action manager handles actions of any of the given triggers
  11100. * @param triggers defines the triggers to be tested
  11101. * @return a boolean indicating whether one (or more) of the triggers is handled
  11102. */
  11103. hasSpecificTriggers(triggers: number[]): boolean;
  11104. /**
  11105. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11106. * speed.
  11107. * @param triggerA defines the trigger to be tested
  11108. * @param triggerB defines the trigger to be tested
  11109. * @return a boolean indicating whether one (or more) of the triggers is handled
  11110. */
  11111. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11112. /**
  11113. * Does this action manager handles actions of a given trigger
  11114. * @param trigger defines the trigger to be tested
  11115. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11116. * @return whether the trigger is handled
  11117. */
  11118. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11119. /**
  11120. * Does this action manager has pointer triggers
  11121. */
  11122. readonly hasPointerTriggers: boolean;
  11123. /**
  11124. * Does this action manager has pick triggers
  11125. */
  11126. readonly hasPickTriggers: boolean;
  11127. /**
  11128. * Registers an action to this action manager
  11129. * @param action defines the action to be registered
  11130. * @return the action amended (prepared) after registration
  11131. */
  11132. registerAction(action: Action): Nullable<Action>;
  11133. /**
  11134. * Unregisters an action to this action manager
  11135. * @param action defines the action to be unregistered
  11136. * @return a boolean indicating whether the action has been unregistered
  11137. */
  11138. unregisterAction(action: Action): Boolean;
  11139. /**
  11140. * Process a specific trigger
  11141. * @param trigger defines the trigger to process
  11142. * @param evt defines the event details to be processed
  11143. */
  11144. processTrigger(trigger: number, evt?: IActionEvent): void;
  11145. /** @hidden */
  11146. _getEffectiveTarget(target: any, propertyPath: string): any;
  11147. /** @hidden */
  11148. _getProperty(propertyPath: string): string;
  11149. /**
  11150. * Serialize this manager to a JSON object
  11151. * @param name defines the property name to store this manager
  11152. * @returns a JSON representation of this manager
  11153. */
  11154. serialize(name: string): any;
  11155. /**
  11156. * Creates a new ActionManager from a JSON data
  11157. * @param parsedActions defines the JSON data to read from
  11158. * @param object defines the hosting mesh
  11159. * @param scene defines the hosting scene
  11160. */
  11161. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11162. /**
  11163. * Get a trigger name by index
  11164. * @param trigger defines the trigger index
  11165. * @returns a trigger name
  11166. */
  11167. static GetTriggerName(trigger: number): string;
  11168. }
  11169. }
  11170. declare module "babylonjs/Culling/ray" {
  11171. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11172. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11175. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11178. /**
  11179. * Class representing a ray with position and direction
  11180. */
  11181. export class Ray {
  11182. /** origin point */
  11183. origin: Vector3;
  11184. /** direction */
  11185. direction: Vector3;
  11186. /** length of the ray */
  11187. length: number;
  11188. private static readonly TmpVector3;
  11189. private _tmpRay;
  11190. /**
  11191. * Creates a new ray
  11192. * @param origin origin point
  11193. * @param direction direction
  11194. * @param length length of the ray
  11195. */
  11196. constructor(
  11197. /** origin point */
  11198. origin: Vector3,
  11199. /** direction */
  11200. direction: Vector3,
  11201. /** length of the ray */
  11202. length?: number);
  11203. /**
  11204. * Checks if the ray intersects a box
  11205. * @param minimum bound of the box
  11206. * @param maximum bound of the box
  11207. * @param intersectionTreshold extra extend to be added to the box in all direction
  11208. * @returns if the box was hit
  11209. */
  11210. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11211. /**
  11212. * Checks if the ray intersects a box
  11213. * @param box the bounding box to check
  11214. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11215. * @returns if the box was hit
  11216. */
  11217. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11218. /**
  11219. * If the ray hits a sphere
  11220. * @param sphere the bounding sphere to check
  11221. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11222. * @returns true if it hits the sphere
  11223. */
  11224. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11225. /**
  11226. * If the ray hits a triange
  11227. * @param vertex0 triangle vertex
  11228. * @param vertex1 triangle vertex
  11229. * @param vertex2 triangle vertex
  11230. * @returns intersection information if hit
  11231. */
  11232. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11233. /**
  11234. * Checks if ray intersects a plane
  11235. * @param plane the plane to check
  11236. * @returns the distance away it was hit
  11237. */
  11238. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11239. /**
  11240. * Checks if ray intersects a mesh
  11241. * @param mesh the mesh to check
  11242. * @param fastCheck if only the bounding box should checked
  11243. * @returns picking info of the intersecton
  11244. */
  11245. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11246. /**
  11247. * Checks if ray intersects a mesh
  11248. * @param meshes the meshes to check
  11249. * @param fastCheck if only the bounding box should checked
  11250. * @param results array to store result in
  11251. * @returns Array of picking infos
  11252. */
  11253. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11254. private _comparePickingInfo;
  11255. private static smallnum;
  11256. private static rayl;
  11257. /**
  11258. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11259. * @param sega the first point of the segment to test the intersection against
  11260. * @param segb the second point of the segment to test the intersection against
  11261. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11262. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11263. */
  11264. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11265. /**
  11266. * Update the ray from viewport position
  11267. * @param x position
  11268. * @param y y position
  11269. * @param viewportWidth viewport width
  11270. * @param viewportHeight viewport height
  11271. * @param world world matrix
  11272. * @param view view matrix
  11273. * @param projection projection matrix
  11274. * @returns this ray updated
  11275. */
  11276. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11277. /**
  11278. * Creates a ray with origin and direction of 0,0,0
  11279. * @returns the new ray
  11280. */
  11281. static Zero(): Ray;
  11282. /**
  11283. * Creates a new ray from screen space and viewport
  11284. * @param x position
  11285. * @param y y position
  11286. * @param viewportWidth viewport width
  11287. * @param viewportHeight viewport height
  11288. * @param world world matrix
  11289. * @param view view matrix
  11290. * @param projection projection matrix
  11291. * @returns new ray
  11292. */
  11293. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11294. /**
  11295. * 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
  11296. * transformed to the given world matrix.
  11297. * @param origin The origin point
  11298. * @param end The end point
  11299. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11300. * @returns the new ray
  11301. */
  11302. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Transforms a ray by a matrix
  11305. * @param ray ray to transform
  11306. * @param matrix matrix to apply
  11307. * @returns the resulting new ray
  11308. */
  11309. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Transforms a ray by a matrix
  11312. * @param ray ray to transform
  11313. * @param matrix matrix to apply
  11314. * @param result ray to store result in
  11315. */
  11316. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11317. /**
  11318. * Unproject a ray from screen space to object space
  11319. * @param sourceX defines the screen space x coordinate to use
  11320. * @param sourceY defines the screen space y coordinate to use
  11321. * @param viewportWidth defines the current width of the viewport
  11322. * @param viewportHeight defines the current height of the viewport
  11323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11324. * @param view defines the view matrix to use
  11325. * @param projection defines the projection matrix to use
  11326. */
  11327. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11328. }
  11329. module "babylonjs/scene" {
  11330. interface Scene {
  11331. /** @hidden */
  11332. _tempPickingRay: Nullable<Ray>;
  11333. /** @hidden */
  11334. _cachedRayForTransform: Ray;
  11335. /** @hidden */
  11336. _pickWithRayInverseMatrix: Matrix;
  11337. /** @hidden */
  11338. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /** @hidden */
  11340. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11341. }
  11342. }
  11343. }
  11344. declare module "babylonjs/sceneComponent" {
  11345. import { Scene } from "babylonjs/scene";
  11346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11348. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11349. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Camera } from "babylonjs/Cameras/camera";
  11352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11354. import { AbstractScene } from "babylonjs/abstractScene";
  11355. /**
  11356. * Groups all the scene component constants in one place to ease maintenance.
  11357. * @hidden
  11358. */
  11359. export class SceneComponentConstants {
  11360. static readonly NAME_EFFECTLAYER: string;
  11361. static readonly NAME_LAYER: string;
  11362. static readonly NAME_LENSFLARESYSTEM: string;
  11363. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11364. static readonly NAME_PARTICLESYSTEM: string;
  11365. static readonly NAME_GAMEPAD: string;
  11366. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11367. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11368. static readonly NAME_DEPTHRENDERER: string;
  11369. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11370. static readonly NAME_SPRITE: string;
  11371. static readonly NAME_OUTLINERENDERER: string;
  11372. static readonly NAME_PROCEDURALTEXTURE: string;
  11373. static readonly NAME_SHADOWGENERATOR: string;
  11374. static readonly NAME_OCTREE: string;
  11375. static readonly NAME_PHYSICSENGINE: string;
  11376. static readonly NAME_AUDIO: string;
  11377. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11378. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11379. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11380. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11381. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11382. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11383. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11384. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11385. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11386. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11387. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11388. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11389. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11390. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11391. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11392. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11393. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11394. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11395. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11396. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11397. static readonly STEP_AFTERRENDER_AUDIO: number;
  11398. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11399. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11400. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11401. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11402. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11403. static readonly STEP_POINTERMOVE_SPRITE: number;
  11404. static readonly STEP_POINTERDOWN_SPRITE: number;
  11405. static readonly STEP_POINTERUP_SPRITE: number;
  11406. }
  11407. /**
  11408. * This represents a scene component.
  11409. *
  11410. * This is used to decouple the dependency the scene is having on the different workloads like
  11411. * layers, post processes...
  11412. */
  11413. export interface ISceneComponent {
  11414. /**
  11415. * The name of the component. Each component must have a unique name.
  11416. */
  11417. name: string;
  11418. /**
  11419. * The scene the component belongs to.
  11420. */
  11421. scene: Scene;
  11422. /**
  11423. * Register the component to one instance of a scene.
  11424. */
  11425. register(): void;
  11426. /**
  11427. * Rebuilds the elements related to this component in case of
  11428. * context lost for instance.
  11429. */
  11430. rebuild(): void;
  11431. /**
  11432. * Disposes the component and the associated ressources.
  11433. */
  11434. dispose(): void;
  11435. }
  11436. /**
  11437. * This represents a SERIALIZABLE scene component.
  11438. *
  11439. * This extends Scene Component to add Serialization methods on top.
  11440. */
  11441. export interface ISceneSerializableComponent extends ISceneComponent {
  11442. /**
  11443. * Adds all the element from the container to the scene
  11444. * @param container the container holding the elements
  11445. */
  11446. addFromContainer(container: AbstractScene): void;
  11447. /**
  11448. * Removes all the elements in the container from the scene
  11449. * @param container contains the elements to remove
  11450. */
  11451. removeFromContainer(container: AbstractScene): void;
  11452. /**
  11453. * Serializes the component data to the specified json object
  11454. * @param serializationObject The object to serialize to
  11455. */
  11456. serialize(serializationObject: any): void;
  11457. }
  11458. /**
  11459. * Strong typing of a Mesh related stage step action
  11460. */
  11461. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11462. /**
  11463. * Strong typing of a Evaluate Sub Mesh related stage step action
  11464. */
  11465. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11466. /**
  11467. * Strong typing of a Active Mesh related stage step action
  11468. */
  11469. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11470. /**
  11471. * Strong typing of a Camera related stage step action
  11472. */
  11473. export type CameraStageAction = (camera: Camera) => void;
  11474. /**
  11475. * Strong typing of a Render Target related stage step action
  11476. */
  11477. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11478. /**
  11479. * Strong typing of a RenderingGroup related stage step action
  11480. */
  11481. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11482. /**
  11483. * Strong typing of a Mesh Render related stage step action
  11484. */
  11485. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11486. /**
  11487. * Strong typing of a simple stage step action
  11488. */
  11489. export type SimpleStageAction = () => void;
  11490. /**
  11491. * Strong typing of a render target action.
  11492. */
  11493. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11494. /**
  11495. * Strong typing of a pointer move action.
  11496. */
  11497. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11498. /**
  11499. * Strong typing of a pointer up/down action.
  11500. */
  11501. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11502. /**
  11503. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11504. * @hidden
  11505. */
  11506. export class Stage<T extends Function> extends Array<{
  11507. index: number;
  11508. component: ISceneComponent;
  11509. action: T;
  11510. }> {
  11511. /**
  11512. * Hide ctor from the rest of the world.
  11513. * @param items The items to add.
  11514. */
  11515. private constructor();
  11516. /**
  11517. * Creates a new Stage.
  11518. * @returns A new instance of a Stage
  11519. */
  11520. static Create<T extends Function>(): Stage<T>;
  11521. /**
  11522. * Registers a step in an ordered way in the targeted stage.
  11523. * @param index Defines the position to register the step in
  11524. * @param component Defines the component attached to the step
  11525. * @param action Defines the action to launch during the step
  11526. */
  11527. registerStep(index: number, component: ISceneComponent, action: T): void;
  11528. /**
  11529. * Clears all the steps from the stage.
  11530. */
  11531. clear(): void;
  11532. }
  11533. }
  11534. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11535. import { Nullable } from "babylonjs/types";
  11536. import { Observable } from "babylonjs/Misc/observable";
  11537. import { Scene } from "babylonjs/scene";
  11538. import { Sprite } from "babylonjs/Sprites/sprite";
  11539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11540. import { Ray } from "babylonjs/Culling/ray";
  11541. import { Camera } from "babylonjs/Cameras/camera";
  11542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11543. import { ISceneComponent } from "babylonjs/sceneComponent";
  11544. module "babylonjs/scene" {
  11545. interface Scene {
  11546. /** @hidden */
  11547. _pointerOverSprite: Nullable<Sprite>;
  11548. /** @hidden */
  11549. _pickedDownSprite: Nullable<Sprite>;
  11550. /** @hidden */
  11551. _tempSpritePickingRay: Nullable<Ray>;
  11552. /**
  11553. * All of the sprite managers added to this scene
  11554. * @see http://doc.babylonjs.com/babylon101/sprites
  11555. */
  11556. spriteManagers: Array<ISpriteManager>;
  11557. /**
  11558. * An event triggered when sprites rendering is about to start
  11559. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11560. */
  11561. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11562. /**
  11563. * An event triggered when sprites rendering is done
  11564. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11565. */
  11566. onAfterSpritesRenderingObservable: Observable<Scene>;
  11567. /** @hidden */
  11568. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11569. /** Launch a ray to try to pick a sprite in the scene
  11570. * @param x position on screen
  11571. * @param y position on screen
  11572. * @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
  11573. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11575. * @returns a PickingInfo
  11576. */
  11577. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11578. /** Use the given ray to pick a sprite in the scene
  11579. * @param ray The ray (in world space) to use to pick meshes
  11580. * @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
  11581. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11582. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11583. * @returns a PickingInfo
  11584. */
  11585. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11586. /**
  11587. * Force the sprite under the pointer
  11588. * @param sprite defines the sprite to use
  11589. */
  11590. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11591. /**
  11592. * Gets the sprite under the pointer
  11593. * @returns a Sprite or null if no sprite is under the pointer
  11594. */
  11595. getPointerOverSprite(): Nullable<Sprite>;
  11596. }
  11597. }
  11598. /**
  11599. * Defines the sprite scene component responsible to manage sprites
  11600. * in a given scene.
  11601. */
  11602. export class SpriteSceneComponent implements ISceneComponent {
  11603. /**
  11604. * The component name helpfull to identify the component in the list of scene components.
  11605. */
  11606. readonly name: string;
  11607. /**
  11608. * The scene the component belongs to.
  11609. */
  11610. scene: Scene;
  11611. /** @hidden */
  11612. private _spritePredicate;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _pickSpriteButKeepRay;
  11632. private _pointerMove;
  11633. private _pointerDown;
  11634. private _pointerUp;
  11635. }
  11636. }
  11637. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11638. /** @hidden */
  11639. export var fogFragmentDeclaration: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11645. /** @hidden */
  11646. export var fogFragment: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module "babylonjs/Shaders/sprites.fragment" {
  11652. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11653. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11654. /** @hidden */
  11655. export var spritesPixelShader: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11661. /** @hidden */
  11662. export var fogVertexDeclaration: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module "babylonjs/Shaders/sprites.vertex" {
  11668. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11669. /** @hidden */
  11670. export var spritesVertexShader: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module "babylonjs/Sprites/spriteManager" {
  11676. import { IDisposable, Scene } from "babylonjs/scene";
  11677. import { Nullable } from "babylonjs/types";
  11678. import { Observable } from "babylonjs/Misc/observable";
  11679. import { Sprite } from "babylonjs/Sprites/sprite";
  11680. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11681. import { Camera } from "babylonjs/Cameras/camera";
  11682. import { Texture } from "babylonjs/Materials/Textures/texture";
  11683. import "babylonjs/Shaders/sprites.fragment";
  11684. import "babylonjs/Shaders/sprites.vertex";
  11685. import { Ray } from "babylonjs/Culling/ray";
  11686. /**
  11687. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11688. */
  11689. export interface ISpriteManager extends IDisposable {
  11690. /**
  11691. * Restricts the camera to viewing objects with the same layerMask.
  11692. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11693. */
  11694. layerMask: number;
  11695. /**
  11696. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11697. */
  11698. isPickable: boolean;
  11699. /**
  11700. * Specifies the rendering group id for this mesh (0 by default)
  11701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11702. */
  11703. renderingGroupId: number;
  11704. /**
  11705. * Defines the list of sprites managed by the manager.
  11706. */
  11707. sprites: Array<Sprite>;
  11708. /**
  11709. * Tests the intersection of a sprite with a specific ray.
  11710. * @param ray The ray we are sending to test the collision
  11711. * @param camera The camera space we are sending rays in
  11712. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11713. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11714. * @returns picking info or null.
  11715. */
  11716. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11717. /**
  11718. * Renders the list of sprites on screen.
  11719. */
  11720. render(): void;
  11721. }
  11722. /**
  11723. * Class used to manage multiple sprites on the same spritesheet
  11724. * @see http://doc.babylonjs.com/babylon101/sprites
  11725. */
  11726. export class SpriteManager implements ISpriteManager {
  11727. /** defines the manager's name */
  11728. name: string;
  11729. /** Gets the list of sprites */
  11730. sprites: Sprite[];
  11731. /** Gets or sets the rendering group id (0 by default) */
  11732. renderingGroupId: number;
  11733. /** Gets or sets camera layer mask */
  11734. layerMask: number;
  11735. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11736. fogEnabled: boolean;
  11737. /** Gets or sets a boolean indicating if the sprites are pickable */
  11738. isPickable: boolean;
  11739. /** Defines the default width of a cell in the spritesheet */
  11740. cellWidth: number;
  11741. /** Defines the default height of a cell in the spritesheet */
  11742. cellHeight: number;
  11743. /**
  11744. * An event triggered when the manager is disposed.
  11745. */
  11746. onDisposeObservable: Observable<SpriteManager>;
  11747. private _onDisposeObserver;
  11748. /**
  11749. * Callback called when the manager is disposed
  11750. */
  11751. onDispose: () => void;
  11752. private _capacity;
  11753. private _spriteTexture;
  11754. private _epsilon;
  11755. private _scene;
  11756. private _vertexData;
  11757. private _buffer;
  11758. private _vertexBuffers;
  11759. private _indexBuffer;
  11760. private _effectBase;
  11761. private _effectFog;
  11762. /**
  11763. * Gets or sets the spritesheet texture
  11764. */
  11765. texture: Texture;
  11766. /**
  11767. * Creates a new sprite manager
  11768. * @param name defines the manager's name
  11769. * @param imgUrl defines the sprite sheet url
  11770. * @param capacity defines the maximum allowed number of sprites
  11771. * @param cellSize defines the size of a sprite cell
  11772. * @param scene defines the hosting scene
  11773. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11774. * @param samplingMode defines the smapling mode to use with spritesheet
  11775. */
  11776. constructor(
  11777. /** defines the manager's name */
  11778. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11779. private _appendSpriteVertex;
  11780. /**
  11781. * Intersects the sprites with a ray
  11782. * @param ray defines the ray to intersect with
  11783. * @param camera defines the current active camera
  11784. * @param predicate defines a predicate used to select candidate sprites
  11785. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11786. * @returns null if no hit or a PickingInfo
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Render all child sprites
  11791. */
  11792. render(): void;
  11793. /**
  11794. * Release associated resources
  11795. */
  11796. dispose(): void;
  11797. }
  11798. }
  11799. declare module "babylonjs/Sprites/sprite" {
  11800. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11801. import { Nullable } from "babylonjs/types";
  11802. import { ActionManager } from "babylonjs/Actions/actionManager";
  11803. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11804. /**
  11805. * Class used to represent a sprite
  11806. * @see http://doc.babylonjs.com/babylon101/sprites
  11807. */
  11808. export class Sprite {
  11809. /** defines the name */
  11810. name: string;
  11811. /** Gets or sets the current world position */
  11812. position: Vector3;
  11813. /** Gets or sets the main color */
  11814. color: Color4;
  11815. /** Gets or sets the width */
  11816. width: number;
  11817. /** Gets or sets the height */
  11818. height: number;
  11819. /** Gets or sets rotation angle */
  11820. angle: number;
  11821. /** Gets or sets the cell index in the sprite sheet */
  11822. cellIndex: number;
  11823. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11824. invertU: number;
  11825. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11826. invertV: number;
  11827. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11828. disposeWhenFinishedAnimating: boolean;
  11829. /** Gets the list of attached animations */
  11830. animations: Animation[];
  11831. /** Gets or sets a boolean indicating if the sprite can be picked */
  11832. isPickable: boolean;
  11833. /**
  11834. * Gets or sets the associated action manager
  11835. */
  11836. actionManager: Nullable<ActionManager>;
  11837. private _animationStarted;
  11838. private _loopAnimation;
  11839. private _fromIndex;
  11840. private _toIndex;
  11841. private _delay;
  11842. private _direction;
  11843. private _manager;
  11844. private _time;
  11845. private _onAnimationEnd;
  11846. /**
  11847. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11848. */
  11849. isVisible: boolean;
  11850. /**
  11851. * Gets or sets the sprite size
  11852. */
  11853. size: number;
  11854. /**
  11855. * Creates a new Sprite
  11856. * @param name defines the name
  11857. * @param manager defines the manager
  11858. */
  11859. constructor(
  11860. /** defines the name */
  11861. name: string, manager: ISpriteManager);
  11862. /**
  11863. * Starts an animation
  11864. * @param from defines the initial key
  11865. * @param to defines the end key
  11866. * @param loop defines if the animation must loop
  11867. * @param delay defines the start delay (in ms)
  11868. * @param onAnimationEnd defines a callback to call when animation ends
  11869. */
  11870. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11871. /** Stops current animation (if any) */
  11872. stopAnimation(): void;
  11873. /** @hidden */
  11874. _animate(deltaTime: number): void;
  11875. /** Release associated resources */
  11876. dispose(): void;
  11877. }
  11878. }
  11879. declare module "babylonjs/Collisions/pickingInfo" {
  11880. import { Nullable } from "babylonjs/types";
  11881. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11883. import { Sprite } from "babylonjs/Sprites/sprite";
  11884. import { Ray } from "babylonjs/Culling/ray";
  11885. /**
  11886. * Information about the result of picking within a scene
  11887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11888. */
  11889. export class PickingInfo {
  11890. /** @hidden */
  11891. _pickingUnavailable: boolean;
  11892. /**
  11893. * If the pick collided with an object
  11894. */
  11895. hit: boolean;
  11896. /**
  11897. * Distance away where the pick collided
  11898. */
  11899. distance: number;
  11900. /**
  11901. * The location of pick collision
  11902. */
  11903. pickedPoint: Nullable<Vector3>;
  11904. /**
  11905. * The mesh corresponding the the pick collision
  11906. */
  11907. pickedMesh: Nullable<AbstractMesh>;
  11908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11909. bu: number;
  11910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bv: number;
  11912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11913. faceId: number;
  11914. /** Id of the the submesh that was picked */
  11915. subMeshId: number;
  11916. /** If a sprite was picked, this will be the sprite the pick collided with */
  11917. pickedSprite: Nullable<Sprite>;
  11918. /**
  11919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11920. */
  11921. originMesh: Nullable<AbstractMesh>;
  11922. /**
  11923. * The ray that was used to perform the picking.
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Gets the normal correspodning to the face the pick collided with
  11928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11930. * @returns The normal correspodning to the face the pick collided with
  11931. */
  11932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11933. /**
  11934. * Gets the texture coordinates of where the pick occured
  11935. * @returns the vector containing the coordnates of the texture
  11936. */
  11937. getTextureCoordinates(): Nullable<Vector2>;
  11938. }
  11939. }
  11940. declare module "babylonjs/Events/pointerEvents" {
  11941. import { Nullable } from "babylonjs/types";
  11942. import { Vector2 } from "babylonjs/Maths/math";
  11943. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11944. import { Ray } from "babylonjs/Culling/ray";
  11945. /**
  11946. * Gather the list of pointer event types as constants.
  11947. */
  11948. export class PointerEventTypes {
  11949. /**
  11950. * 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.
  11951. */
  11952. static readonly POINTERDOWN: number;
  11953. /**
  11954. * The pointerup event is fired when a pointer is no longer active.
  11955. */
  11956. static readonly POINTERUP: number;
  11957. /**
  11958. * The pointermove event is fired when a pointer changes coordinates.
  11959. */
  11960. static readonly POINTERMOVE: number;
  11961. /**
  11962. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11963. */
  11964. static readonly POINTERWHEEL: number;
  11965. /**
  11966. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11967. */
  11968. static readonly POINTERPICK: number;
  11969. /**
  11970. * The pointertap event is fired when a the object has been touched and released without drag.
  11971. */
  11972. static readonly POINTERTAP: number;
  11973. /**
  11974. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11975. */
  11976. static readonly POINTERDOUBLETAP: number;
  11977. }
  11978. /**
  11979. * Base class of pointer info types.
  11980. */
  11981. export class PointerInfoBase {
  11982. /**
  11983. * Defines the type of event (PointerEventTypes)
  11984. */
  11985. type: number;
  11986. /**
  11987. * Defines the related dom event
  11988. */
  11989. event: PointerEvent | MouseWheelEvent;
  11990. /**
  11991. * Instantiates the base class of pointers info.
  11992. * @param type Defines the type of event (PointerEventTypes)
  11993. * @param event Defines the related dom event
  11994. */
  11995. constructor(
  11996. /**
  11997. * Defines the type of event (PointerEventTypes)
  11998. */
  11999. type: number,
  12000. /**
  12001. * Defines the related dom event
  12002. */
  12003. event: PointerEvent | MouseWheelEvent);
  12004. }
  12005. /**
  12006. * This class is used to store pointer related info for the onPrePointerObservable event.
  12007. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12008. */
  12009. export class PointerInfoPre extends PointerInfoBase {
  12010. /**
  12011. * Ray from a pointer if availible (eg. 6dof controller)
  12012. */
  12013. ray: Nullable<Ray>;
  12014. /**
  12015. * Defines the local position of the pointer on the canvas.
  12016. */
  12017. localPosition: Vector2;
  12018. /**
  12019. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12020. */
  12021. skipOnPointerObservable: boolean;
  12022. /**
  12023. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12024. * @param type Defines the type of event (PointerEventTypes)
  12025. * @param event Defines the related dom event
  12026. * @param localX Defines the local x coordinates of the pointer when the event occured
  12027. * @param localY Defines the local y coordinates of the pointer when the event occured
  12028. */
  12029. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12030. }
  12031. /**
  12032. * This type contains all the data related to a pointer event in Babylon.js.
  12033. * 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.
  12034. */
  12035. export class PointerInfo extends PointerInfoBase {
  12036. /**
  12037. * Defines the picking info associated to the info (if any)\
  12038. */
  12039. pickInfo: Nullable<PickingInfo>;
  12040. /**
  12041. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12042. * @param type Defines the type of event (PointerEventTypes)
  12043. * @param event Defines the related dom event
  12044. * @param pickInfo Defines the picking info associated to the info (if any)\
  12045. */
  12046. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12047. /**
  12048. * Defines the picking info associated to the info (if any)\
  12049. */
  12050. pickInfo: Nullable<PickingInfo>);
  12051. }
  12052. }
  12053. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12054. import { Nullable } from "babylonjs/types";
  12055. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12057. /**
  12058. * Manage the mouse inputs to control the movement of a free camera.
  12059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12060. */
  12061. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12062. /**
  12063. * Define if touch is enabled in the mouse input
  12064. */
  12065. touchEnabled: boolean;
  12066. /**
  12067. * Defines the camera the input is attached to.
  12068. */
  12069. camera: FreeCamera;
  12070. /**
  12071. * Defines the buttons associated with the input to handle camera move.
  12072. */
  12073. buttons: number[];
  12074. /**
  12075. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12076. */
  12077. angularSensibility: number;
  12078. private _pointerInput;
  12079. private _onMouseMove;
  12080. private _observer;
  12081. private previousPosition;
  12082. /**
  12083. * Manage the mouse inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. * @param touchEnabled Defines if touch is enabled or not
  12086. */
  12087. constructor(
  12088. /**
  12089. * Define if touch is enabled in the mouse input
  12090. */
  12091. touchEnabled?: boolean);
  12092. /**
  12093. * Attach the input controls to a specific dom element to get the input from.
  12094. * @param element Defines the element the controls should be listened from
  12095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12096. */
  12097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12098. /**
  12099. * Detach the current controls from the specified dom element.
  12100. * @param element Defines the element to stop listening the inputs from
  12101. */
  12102. detachControl(element: Nullable<HTMLElement>): void;
  12103. /**
  12104. * Gets the class name of the current intput.
  12105. * @returns the class name
  12106. */
  12107. getClassName(): string;
  12108. /**
  12109. * Get the friendly name associated with the input class.
  12110. * @returns the input friendly name
  12111. */
  12112. getSimpleName(): string;
  12113. }
  12114. }
  12115. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12116. import { Nullable } from "babylonjs/types";
  12117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12119. /**
  12120. * Manage the touch inputs to control the movement of a free camera.
  12121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12122. */
  12123. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12124. /**
  12125. * Defines the camera the input is attached to.
  12126. */
  12127. camera: FreeCamera;
  12128. /**
  12129. * Defines the touch sensibility for rotation.
  12130. * The higher the faster.
  12131. */
  12132. touchAngularSensibility: number;
  12133. /**
  12134. * Defines the touch sensibility for move.
  12135. * The higher the faster.
  12136. */
  12137. touchMoveSensibility: number;
  12138. private _offsetX;
  12139. private _offsetY;
  12140. private _pointerPressed;
  12141. private _pointerInput;
  12142. private _observer;
  12143. private _onLostFocus;
  12144. /**
  12145. * Attach the input controls to a specific dom element to get the input from.
  12146. * @param element Defines the element the controls should be listened from
  12147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12148. */
  12149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12150. /**
  12151. * Detach the current controls from the specified dom element.
  12152. * @param element Defines the element to stop listening the inputs from
  12153. */
  12154. detachControl(element: Nullable<HTMLElement>): void;
  12155. /**
  12156. * Update the current camera state depending on the inputs that have been used this frame.
  12157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12158. */
  12159. checkInputs(): void;
  12160. /**
  12161. * Gets the class name of the current intput.
  12162. * @returns the class name
  12163. */
  12164. getClassName(): string;
  12165. /**
  12166. * Get the friendly name associated with the input class.
  12167. * @returns the input friendly name
  12168. */
  12169. getSimpleName(): string;
  12170. }
  12171. }
  12172. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12174. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12175. /**
  12176. * Default Inputs manager for the FreeCamera.
  12177. * It groups all the default supported inputs for ease of use.
  12178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12179. */
  12180. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12181. /**
  12182. * Instantiates a new FreeCameraInputsManager.
  12183. * @param camera Defines the camera the inputs belong to
  12184. */
  12185. constructor(camera: FreeCamera);
  12186. /**
  12187. * Add keyboard input support to the input manager.
  12188. * @returns the current input manager
  12189. */
  12190. addKeyboard(): FreeCameraInputsManager;
  12191. /**
  12192. * Add mouse input support to the input manager.
  12193. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12194. * @returns the current input manager
  12195. */
  12196. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12197. /**
  12198. * Add touch input support to the input manager.
  12199. * @returns the current input manager
  12200. */
  12201. addTouch(): FreeCameraInputsManager;
  12202. }
  12203. }
  12204. declare module "babylonjs/Cameras/freeCamera" {
  12205. import { Vector3 } from "babylonjs/Maths/math";
  12206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12207. import { Scene } from "babylonjs/scene";
  12208. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12209. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. /**
  12245. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12246. * Higher values reduce sensitivity.
  12247. */
  12248. angularSensibility: number;
  12249. /**
  12250. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12251. */
  12252. keysUp: number[];
  12253. /**
  12254. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12255. */
  12256. keysDown: number[];
  12257. /**
  12258. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12259. */
  12260. keysLeft: number[];
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12263. */
  12264. keysRight: number[];
  12265. /**
  12266. * Event raised when the camera collide with a mesh in the scene.
  12267. */
  12268. onCollide: (collidedMesh: AbstractMesh) => void;
  12269. private _collider;
  12270. private _needMoveForGravity;
  12271. private _oldPosition;
  12272. private _diffPosition;
  12273. private _newPosition;
  12274. /** @hidden */
  12275. _localDirection: Vector3;
  12276. /** @hidden */
  12277. _transformedDirection: Vector3;
  12278. /**
  12279. * Instantiates a Free Camera.
  12280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12281. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12283. * @param name Define the name of the camera in the scene
  12284. * @param position Define the start position of the camera in the scene
  12285. * @param scene Define the scene the camera belongs to
  12286. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12287. */
  12288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12289. /**
  12290. * Attached controls to the current camera.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Detach the current controls from the camera.
  12297. * The camera will stop reacting to inputs.
  12298. * @param element Defines the element to stop listening the inputs from
  12299. */
  12300. detachControl(element: HTMLElement): void;
  12301. private _collisionMask;
  12302. /**
  12303. * Define a collision mask to limit the list of object the camera can collide with
  12304. */
  12305. collisionMask: number;
  12306. /** @hidden */
  12307. _collideWithWorld(displacement: Vector3): void;
  12308. private _onCollisionPositionChange;
  12309. /** @hidden */
  12310. _checkInputs(): void;
  12311. /** @hidden */
  12312. _decideIfNeedsToMove(): boolean;
  12313. /** @hidden */
  12314. _updatePosition(): void;
  12315. /**
  12316. * Destroy the camera and release the current resources hold by it.
  12317. */
  12318. dispose(): void;
  12319. /**
  12320. * Gets the current object class name.
  12321. * @return the class name
  12322. */
  12323. getClassName(): string;
  12324. }
  12325. }
  12326. declare module "babylonjs/Gamepads/gamepad" {
  12327. import { Observable } from "babylonjs/Misc/observable";
  12328. /**
  12329. * Represents a gamepad control stick position
  12330. */
  12331. export class StickValues {
  12332. /**
  12333. * The x component of the control stick
  12334. */
  12335. x: number;
  12336. /**
  12337. * The y component of the control stick
  12338. */
  12339. y: number;
  12340. /**
  12341. * Initializes the gamepad x and y control stick values
  12342. * @param x The x component of the gamepad control stick value
  12343. * @param y The y component of the gamepad control stick value
  12344. */
  12345. constructor(
  12346. /**
  12347. * The x component of the control stick
  12348. */
  12349. x: number,
  12350. /**
  12351. * The y component of the control stick
  12352. */
  12353. y: number);
  12354. }
  12355. /**
  12356. * An interface which manages callbacks for gamepad button changes
  12357. */
  12358. export interface GamepadButtonChanges {
  12359. /**
  12360. * Called when a gamepad has been changed
  12361. */
  12362. changed: boolean;
  12363. /**
  12364. * Called when a gamepad press event has been triggered
  12365. */
  12366. pressChanged: boolean;
  12367. /**
  12368. * Called when a touch event has been triggered
  12369. */
  12370. touchChanged: boolean;
  12371. /**
  12372. * Called when a value has changed
  12373. */
  12374. valueChanged: boolean;
  12375. }
  12376. /**
  12377. * Represents a gamepad
  12378. */
  12379. export class Gamepad {
  12380. /**
  12381. * The id of the gamepad
  12382. */
  12383. id: string;
  12384. /**
  12385. * The index of the gamepad
  12386. */
  12387. index: number;
  12388. /**
  12389. * The browser gamepad
  12390. */
  12391. browserGamepad: any;
  12392. /**
  12393. * Specifies what type of gamepad this represents
  12394. */
  12395. type: number;
  12396. private _leftStick;
  12397. private _rightStick;
  12398. /** @hidden */
  12399. _isConnected: boolean;
  12400. private _leftStickAxisX;
  12401. private _leftStickAxisY;
  12402. private _rightStickAxisX;
  12403. private _rightStickAxisY;
  12404. /**
  12405. * Triggered when the left control stick has been changed
  12406. */
  12407. private _onleftstickchanged;
  12408. /**
  12409. * Triggered when the right control stick has been changed
  12410. */
  12411. private _onrightstickchanged;
  12412. /**
  12413. * Represents a gamepad controller
  12414. */
  12415. static GAMEPAD: number;
  12416. /**
  12417. * Represents a generic controller
  12418. */
  12419. static GENERIC: number;
  12420. /**
  12421. * Represents an XBox controller
  12422. */
  12423. static XBOX: number;
  12424. /**
  12425. * Represents a pose-enabled controller
  12426. */
  12427. static POSE_ENABLED: number;
  12428. /**
  12429. * Specifies whether the left control stick should be Y-inverted
  12430. */
  12431. protected _invertLeftStickY: boolean;
  12432. /**
  12433. * Specifies if the gamepad has been connected
  12434. */
  12435. readonly isConnected: boolean;
  12436. /**
  12437. * Initializes the gamepad
  12438. * @param id The id of the gamepad
  12439. * @param index The index of the gamepad
  12440. * @param browserGamepad The browser gamepad
  12441. * @param leftStickX The x component of the left joystick
  12442. * @param leftStickY The y component of the left joystick
  12443. * @param rightStickX The x component of the right joystick
  12444. * @param rightStickY The y component of the right joystick
  12445. */
  12446. constructor(
  12447. /**
  12448. * The id of the gamepad
  12449. */
  12450. id: string,
  12451. /**
  12452. * The index of the gamepad
  12453. */
  12454. index: number,
  12455. /**
  12456. * The browser gamepad
  12457. */
  12458. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12459. /**
  12460. * Callback triggered when the left joystick has changed
  12461. * @param callback
  12462. */
  12463. onleftstickchanged(callback: (values: StickValues) => void): void;
  12464. /**
  12465. * Callback triggered when the right joystick has changed
  12466. * @param callback
  12467. */
  12468. onrightstickchanged(callback: (values: StickValues) => void): void;
  12469. /**
  12470. * Gets the left joystick
  12471. */
  12472. /**
  12473. * Sets the left joystick values
  12474. */
  12475. leftStick: StickValues;
  12476. /**
  12477. * Gets the right joystick
  12478. */
  12479. /**
  12480. * Sets the right joystick value
  12481. */
  12482. rightStick: StickValues;
  12483. /**
  12484. * Updates the gamepad joystick positions
  12485. */
  12486. update(): void;
  12487. /**
  12488. * Disposes the gamepad
  12489. */
  12490. dispose(): void;
  12491. }
  12492. /**
  12493. * Represents a generic gamepad
  12494. */
  12495. export class GenericPad extends Gamepad {
  12496. private _buttons;
  12497. private _onbuttondown;
  12498. private _onbuttonup;
  12499. /**
  12500. * Observable triggered when a button has been pressed
  12501. */
  12502. onButtonDownObservable: Observable<number>;
  12503. /**
  12504. * Observable triggered when a button has been released
  12505. */
  12506. onButtonUpObservable: Observable<number>;
  12507. /**
  12508. * Callback triggered when a button has been pressed
  12509. * @param callback Called when a button has been pressed
  12510. */
  12511. onbuttondown(callback: (buttonPressed: number) => void): void;
  12512. /**
  12513. * Callback triggered when a button has been released
  12514. * @param callback Called when a button has been released
  12515. */
  12516. onbuttonup(callback: (buttonReleased: number) => void): void;
  12517. /**
  12518. * Initializes the generic gamepad
  12519. * @param id The id of the generic gamepad
  12520. * @param index The index of the generic gamepad
  12521. * @param browserGamepad The browser gamepad
  12522. */
  12523. constructor(id: string, index: number, browserGamepad: any);
  12524. private _setButtonValue;
  12525. /**
  12526. * Updates the generic gamepad
  12527. */
  12528. update(): void;
  12529. /**
  12530. * Disposes the generic gamepad
  12531. */
  12532. dispose(): void;
  12533. }
  12534. }
  12535. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12536. import { Observable } from "babylonjs/Misc/observable";
  12537. import { Nullable } from "babylonjs/types";
  12538. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12541. import { Ray } from "babylonjs/Culling/ray";
  12542. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12543. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12544. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12545. /**
  12546. * Defines the types of pose enabled controllers that are supported
  12547. */
  12548. export enum PoseEnabledControllerType {
  12549. /**
  12550. * HTC Vive
  12551. */
  12552. VIVE = 0,
  12553. /**
  12554. * Oculus Rift
  12555. */
  12556. OCULUS = 1,
  12557. /**
  12558. * Windows mixed reality
  12559. */
  12560. WINDOWS = 2,
  12561. /**
  12562. * Samsung gear VR
  12563. */
  12564. GEAR_VR = 3,
  12565. /**
  12566. * Google Daydream
  12567. */
  12568. DAYDREAM = 4,
  12569. /**
  12570. * Generic
  12571. */
  12572. GENERIC = 5
  12573. }
  12574. /**
  12575. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12576. */
  12577. export interface MutableGamepadButton {
  12578. /**
  12579. * Value of the button/trigger
  12580. */
  12581. value: number;
  12582. /**
  12583. * If the button/trigger is currently touched
  12584. */
  12585. touched: boolean;
  12586. /**
  12587. * If the button/trigger is currently pressed
  12588. */
  12589. pressed: boolean;
  12590. }
  12591. /**
  12592. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12593. * @hidden
  12594. */
  12595. export interface ExtendedGamepadButton extends GamepadButton {
  12596. /**
  12597. * If the button/trigger is currently pressed
  12598. */
  12599. readonly pressed: boolean;
  12600. /**
  12601. * If the button/trigger is currently touched
  12602. */
  12603. readonly touched: boolean;
  12604. /**
  12605. * Value of the button/trigger
  12606. */
  12607. readonly value: number;
  12608. }
  12609. /** @hidden */
  12610. export interface _GamePadFactory {
  12611. /**
  12612. * Returns wether or not the current gamepad can be created for this type of controller.
  12613. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12614. * @returns true if it can be created, otherwise false
  12615. */
  12616. canCreate(gamepadInfo: any): boolean;
  12617. /**
  12618. * Creates a new instance of the Gamepad.
  12619. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12620. * @returns the new gamepad instance
  12621. */
  12622. create(gamepadInfo: any): Gamepad;
  12623. }
  12624. /**
  12625. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12626. */
  12627. export class PoseEnabledControllerHelper {
  12628. /** @hidden */
  12629. static _ControllerFactories: _GamePadFactory[];
  12630. /** @hidden */
  12631. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12632. /**
  12633. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12634. * @param vrGamepad the gamepad to initialized
  12635. * @returns a vr controller of the type the gamepad identified as
  12636. */
  12637. static InitiateController(vrGamepad: any): Gamepad;
  12638. }
  12639. /**
  12640. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12641. */
  12642. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12643. private _deviceRoomPosition;
  12644. private _deviceRoomRotationQuaternion;
  12645. /**
  12646. * The device position in babylon space
  12647. */
  12648. devicePosition: Vector3;
  12649. /**
  12650. * The device rotation in babylon space
  12651. */
  12652. deviceRotationQuaternion: Quaternion;
  12653. /**
  12654. * The scale factor of the device in babylon space
  12655. */
  12656. deviceScaleFactor: number;
  12657. /**
  12658. * (Likely devicePosition should be used instead) The device position in its room space
  12659. */
  12660. position: Vector3;
  12661. /**
  12662. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12663. */
  12664. rotationQuaternion: Quaternion;
  12665. /**
  12666. * The type of controller (Eg. Windows mixed reality)
  12667. */
  12668. controllerType: PoseEnabledControllerType;
  12669. protected _calculatedPosition: Vector3;
  12670. private _calculatedRotation;
  12671. /**
  12672. * The raw pose from the device
  12673. */
  12674. rawPose: DevicePose;
  12675. private _trackPosition;
  12676. private _maxRotationDistFromHeadset;
  12677. private _draggedRoomRotation;
  12678. /**
  12679. * @hidden
  12680. */
  12681. _disableTrackPosition(fixedPosition: Vector3): void;
  12682. /**
  12683. * Internal, the mesh attached to the controller
  12684. * @hidden
  12685. */
  12686. _mesh: Nullable<AbstractMesh>;
  12687. private _poseControlledCamera;
  12688. private _leftHandSystemQuaternion;
  12689. /**
  12690. * Internal, matrix used to convert room space to babylon space
  12691. * @hidden
  12692. */
  12693. _deviceToWorld: Matrix;
  12694. /**
  12695. * Node to be used when casting a ray from the controller
  12696. * @hidden
  12697. */
  12698. _pointingPoseNode: Nullable<TransformNode>;
  12699. /**
  12700. * Name of the child mesh that can be used to cast a ray from the controller
  12701. */
  12702. static readonly POINTING_POSE: string;
  12703. /**
  12704. * Creates a new PoseEnabledController from a gamepad
  12705. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12706. */
  12707. constructor(browserGamepad: any);
  12708. private _workingMatrix;
  12709. /**
  12710. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12711. */
  12712. update(): void;
  12713. /**
  12714. * Updates only the pose device and mesh without doing any button event checking
  12715. */
  12716. protected _updatePoseAndMesh(): void;
  12717. /**
  12718. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12719. * @param poseData raw pose fromthe device
  12720. */
  12721. updateFromDevice(poseData: DevicePose): void;
  12722. /**
  12723. * @hidden
  12724. */
  12725. _meshAttachedObservable: Observable<AbstractMesh>;
  12726. /**
  12727. * Attaches a mesh to the controller
  12728. * @param mesh the mesh to be attached
  12729. */
  12730. attachToMesh(mesh: AbstractMesh): void;
  12731. /**
  12732. * Attaches the controllers mesh to a camera
  12733. * @param camera the camera the mesh should be attached to
  12734. */
  12735. attachToPoseControlledCamera(camera: TargetCamera): void;
  12736. /**
  12737. * Disposes of the controller
  12738. */
  12739. dispose(): void;
  12740. /**
  12741. * The mesh that is attached to the controller
  12742. */
  12743. readonly mesh: Nullable<AbstractMesh>;
  12744. /**
  12745. * Gets the ray of the controller in the direction the controller is pointing
  12746. * @param length the length the resulting ray should be
  12747. * @returns a ray in the direction the controller is pointing
  12748. */
  12749. getForwardRay(length?: number): Ray;
  12750. }
  12751. }
  12752. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12753. import { Observable } from "babylonjs/Misc/observable";
  12754. import { Scene } from "babylonjs/scene";
  12755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12756. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12757. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12758. /**
  12759. * Defines the WebVRController object that represents controllers tracked in 3D space
  12760. */
  12761. export abstract class WebVRController extends PoseEnabledController {
  12762. /**
  12763. * Internal, the default controller model for the controller
  12764. */
  12765. protected _defaultModel: AbstractMesh;
  12766. /**
  12767. * Fired when the trigger state has changed
  12768. */
  12769. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12770. /**
  12771. * Fired when the main button state has changed
  12772. */
  12773. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12774. /**
  12775. * Fired when the secondary button state has changed
  12776. */
  12777. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12778. /**
  12779. * Fired when the pad state has changed
  12780. */
  12781. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12782. /**
  12783. * Fired when controllers stick values have changed
  12784. */
  12785. onPadValuesChangedObservable: Observable<StickValues>;
  12786. /**
  12787. * Array of button availible on the controller
  12788. */
  12789. protected _buttons: Array<MutableGamepadButton>;
  12790. private _onButtonStateChange;
  12791. /**
  12792. * Fired when a controller button's state has changed
  12793. * @param callback the callback containing the button that was modified
  12794. */
  12795. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12796. /**
  12797. * X and Y axis corrisponding to the controllers joystick
  12798. */
  12799. pad: StickValues;
  12800. /**
  12801. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12802. */
  12803. hand: string;
  12804. /**
  12805. * The default controller model for the controller
  12806. */
  12807. readonly defaultModel: AbstractMesh;
  12808. /**
  12809. * Creates a new WebVRController from a gamepad
  12810. * @param vrGamepad the gamepad that the WebVRController should be created from
  12811. */
  12812. constructor(vrGamepad: any);
  12813. /**
  12814. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12815. */
  12816. update(): void;
  12817. /**
  12818. * Function to be called when a button is modified
  12819. */
  12820. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12821. /**
  12822. * Loads a mesh and attaches it to the controller
  12823. * @param scene the scene the mesh should be added to
  12824. * @param meshLoaded callback for when the mesh has been loaded
  12825. */
  12826. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12827. private _setButtonValue;
  12828. private _changes;
  12829. private _checkChanges;
  12830. /**
  12831. * Disposes of th webVRCOntroller
  12832. */
  12833. dispose(): void;
  12834. }
  12835. }
  12836. declare module "babylonjs/Lights/hemisphericLight" {
  12837. import { Nullable } from "babylonjs/types";
  12838. import { Scene } from "babylonjs/scene";
  12839. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12840. import { Effect } from "babylonjs/Materials/effect";
  12841. import { Light } from "babylonjs/Lights/light";
  12842. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12843. /**
  12844. * The HemisphericLight simulates the ambient environment light,
  12845. * so the passed direction is the light reflection direction, not the incoming direction.
  12846. */
  12847. export class HemisphericLight extends Light {
  12848. /**
  12849. * The groundColor is the light in the opposite direction to the one specified during creation.
  12850. * 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.
  12851. */
  12852. groundColor: Color3;
  12853. /**
  12854. * The light reflection direction, not the incoming direction.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12859. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12860. * The HemisphericLight can't cast shadows.
  12861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12862. * @param name The friendly name of the light
  12863. * @param direction The direction of the light reflection
  12864. * @param scene The scene the light belongs to
  12865. */
  12866. constructor(name: string, direction: Vector3, scene: Scene);
  12867. protected _buildUniformLayout(): void;
  12868. /**
  12869. * Returns the string "HemisphericLight".
  12870. * @return The class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12875. * Returns the updated direction.
  12876. * @param target The target the direction should point to
  12877. * @return The computed direction
  12878. */
  12879. setDirectionToTarget(target: Vector3): Vector3;
  12880. /**
  12881. * Returns the shadow generator associated to the light.
  12882. * @returns Always null for hemispheric lights because it does not support shadows.
  12883. */
  12884. getShadowGenerator(): Nullable<IShadowGenerator>;
  12885. /**
  12886. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12887. * @param effect The effect to update
  12888. * @param lightIndex The index of the light in the effect to update
  12889. * @returns The hemispheric light
  12890. */
  12891. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12892. /**
  12893. * Computes the world matrix of the node
  12894. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12895. * @param useWasUpdatedFlag defines a reserved property
  12896. * @returns the world matrix
  12897. */
  12898. computeWorldMatrix(): Matrix;
  12899. /**
  12900. * Returns the integer 3.
  12901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12902. */
  12903. getTypeID(): number;
  12904. /**
  12905. * Prepares the list of defines specific to the light type.
  12906. * @param defines the list of defines
  12907. * @param lightIndex defines the index of the light for the effect
  12908. */
  12909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12910. }
  12911. }
  12912. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12913. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12914. import { Nullable } from "babylonjs/types";
  12915. import { Observable } from "babylonjs/Misc/observable";
  12916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12917. import { Scene } from "babylonjs/scene";
  12918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12920. import { Node } from "babylonjs/node";
  12921. import { Ray } from "babylonjs/Culling/ray";
  12922. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12923. /**
  12924. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12925. * IMPORTANT!! The data is right-hand data.
  12926. * @export
  12927. * @interface DevicePose
  12928. */
  12929. export interface DevicePose {
  12930. /**
  12931. * The position of the device, values in array are [x,y,z].
  12932. */
  12933. readonly position: Nullable<Float32Array>;
  12934. /**
  12935. * The linearVelocity of the device, values in array are [x,y,z].
  12936. */
  12937. readonly linearVelocity: Nullable<Float32Array>;
  12938. /**
  12939. * The linearAcceleration of the device, values in array are [x,y,z].
  12940. */
  12941. readonly linearAcceleration: Nullable<Float32Array>;
  12942. /**
  12943. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12944. */
  12945. readonly orientation: Nullable<Float32Array>;
  12946. /**
  12947. * The angularVelocity of the device, values in array are [x,y,z].
  12948. */
  12949. readonly angularVelocity: Nullable<Float32Array>;
  12950. /**
  12951. * The angularAcceleration of the device, values in array are [x,y,z].
  12952. */
  12953. readonly angularAcceleration: Nullable<Float32Array>;
  12954. }
  12955. /**
  12956. * Interface representing a pose controlled object in Babylon.
  12957. * A pose controlled object has both regular pose values as well as pose values
  12958. * from an external device such as a VR head mounted display
  12959. */
  12960. export interface PoseControlled {
  12961. /**
  12962. * The position of the object in babylon space.
  12963. */
  12964. position: Vector3;
  12965. /**
  12966. * The rotation quaternion of the object in babylon space.
  12967. */
  12968. rotationQuaternion: Quaternion;
  12969. /**
  12970. * The position of the device in babylon space.
  12971. */
  12972. devicePosition?: Vector3;
  12973. /**
  12974. * The rotation quaternion of the device in babylon space.
  12975. */
  12976. deviceRotationQuaternion: Quaternion;
  12977. /**
  12978. * The raw pose coming from the device.
  12979. */
  12980. rawPose: Nullable<DevicePose>;
  12981. /**
  12982. * The scale of the device to be used when translating from device space to babylon space.
  12983. */
  12984. deviceScaleFactor: number;
  12985. /**
  12986. * Updates the poseControlled values based on the input device pose.
  12987. * @param poseData the pose data to update the object with
  12988. */
  12989. updateFromDevice(poseData: DevicePose): void;
  12990. }
  12991. /**
  12992. * Set of options to customize the webVRCamera
  12993. */
  12994. export interface WebVROptions {
  12995. /**
  12996. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12997. */
  12998. trackPosition?: boolean;
  12999. /**
  13000. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13001. */
  13002. positionScale?: number;
  13003. /**
  13004. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13005. */
  13006. displayName?: string;
  13007. /**
  13008. * Should the native controller meshes be initialized. (default: true)
  13009. */
  13010. controllerMeshes?: boolean;
  13011. /**
  13012. * Creating a default HemiLight only on controllers. (default: true)
  13013. */
  13014. defaultLightingOnControllers?: boolean;
  13015. /**
  13016. * If you don't want to use the default VR button of the helper. (default: false)
  13017. */
  13018. useCustomVRButton?: boolean;
  13019. /**
  13020. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13021. */
  13022. customVRButton?: HTMLButtonElement;
  13023. /**
  13024. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13025. */
  13026. rayLength?: number;
  13027. /**
  13028. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13029. */
  13030. defaultHeight?: number;
  13031. }
  13032. /**
  13033. * This represents a WebVR camera.
  13034. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13035. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13036. */
  13037. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13038. private webVROptions;
  13039. /**
  13040. * @hidden
  13041. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13042. */
  13043. _vrDevice: any;
  13044. /**
  13045. * The rawPose of the vrDevice.
  13046. */
  13047. rawPose: Nullable<DevicePose>;
  13048. private _onVREnabled;
  13049. private _specsVersion;
  13050. private _attached;
  13051. private _frameData;
  13052. protected _descendants: Array<Node>;
  13053. private _deviceRoomPosition;
  13054. /** @hidden */
  13055. _deviceRoomRotationQuaternion: Quaternion;
  13056. private _standingMatrix;
  13057. /**
  13058. * Represents device position in babylon space.
  13059. */
  13060. devicePosition: Vector3;
  13061. /**
  13062. * Represents device rotation in babylon space.
  13063. */
  13064. deviceRotationQuaternion: Quaternion;
  13065. /**
  13066. * The scale of the device to be used when translating from device space to babylon space.
  13067. */
  13068. deviceScaleFactor: number;
  13069. private _deviceToWorld;
  13070. private _worldToDevice;
  13071. /**
  13072. * References to the webVR controllers for the vrDevice.
  13073. */
  13074. controllers: Array<WebVRController>;
  13075. /**
  13076. * Emits an event when a controller is attached.
  13077. */
  13078. onControllersAttachedObservable: Observable<WebVRController[]>;
  13079. /**
  13080. * Emits an event when a controller's mesh has been loaded;
  13081. */
  13082. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13083. /**
  13084. * Emits an event when the HMD's pose has been updated.
  13085. */
  13086. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13087. private _poseSet;
  13088. /**
  13089. * If the rig cameras be used as parent instead of this camera.
  13090. */
  13091. rigParenting: boolean;
  13092. private _lightOnControllers;
  13093. private _defaultHeight?;
  13094. /**
  13095. * Instantiates a WebVRFreeCamera.
  13096. * @param name The name of the WebVRFreeCamera
  13097. * @param position The starting anchor position for the camera
  13098. * @param scene The scene the camera belongs to
  13099. * @param webVROptions a set of customizable options for the webVRCamera
  13100. */
  13101. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13102. /**
  13103. * Gets the device distance from the ground in meters.
  13104. * @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.
  13105. */
  13106. deviceDistanceToRoomGround(): number;
  13107. /**
  13108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13109. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13110. */
  13111. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13112. /**
  13113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13114. * @returns A promise with a boolean set to if the standing matrix is supported.
  13115. */
  13116. useStandingMatrixAsync(): Promise<boolean>;
  13117. /**
  13118. * Disposes the camera
  13119. */
  13120. dispose(): void;
  13121. /**
  13122. * Gets a vrController by name.
  13123. * @param name The name of the controller to retreive
  13124. * @returns the controller matching the name specified or null if not found
  13125. */
  13126. getControllerByName(name: string): Nullable<WebVRController>;
  13127. private _leftController;
  13128. /**
  13129. * The controller corrisponding to the users left hand.
  13130. */
  13131. readonly leftController: Nullable<WebVRController>;
  13132. private _rightController;
  13133. /**
  13134. * The controller corrisponding to the users right hand.
  13135. */
  13136. readonly rightController: Nullable<WebVRController>;
  13137. /**
  13138. * Casts a ray forward from the vrCamera's gaze.
  13139. * @param length Length of the ray (default: 100)
  13140. * @returns the ray corrisponding to the gaze
  13141. */
  13142. getForwardRay(length?: number): Ray;
  13143. /**
  13144. * @hidden
  13145. * Updates the camera based on device's frame data
  13146. */
  13147. _checkInputs(): void;
  13148. /**
  13149. * Updates the poseControlled values based on the input device pose.
  13150. * @param poseData Pose coming from the device
  13151. */
  13152. updateFromDevice(poseData: DevicePose): void;
  13153. private _htmlElementAttached;
  13154. private _detachIfAttached;
  13155. /**
  13156. * WebVR's attach control will start broadcasting frames to the device.
  13157. * Note that in certain browsers (chrome for example) this function must be called
  13158. * within a user-interaction callback. Example:
  13159. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13160. *
  13161. * @param element html element to attach the vrDevice to
  13162. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13163. */
  13164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13165. /**
  13166. * Detaches the camera from the html element and disables VR
  13167. *
  13168. * @param element html element to detach from
  13169. */
  13170. detachControl(element: HTMLElement): void;
  13171. /**
  13172. * @returns the name of this class
  13173. */
  13174. getClassName(): string;
  13175. /**
  13176. * Calls resetPose on the vrDisplay
  13177. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13178. */
  13179. resetToCurrentRotation(): void;
  13180. /**
  13181. * @hidden
  13182. * Updates the rig cameras (left and right eye)
  13183. */
  13184. _updateRigCameras(): void;
  13185. private _workingVector;
  13186. private _oneVector;
  13187. private _workingMatrix;
  13188. private updateCacheCalled;
  13189. private _correctPositionIfNotTrackPosition;
  13190. /**
  13191. * @hidden
  13192. * Updates the cached values of the camera
  13193. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13194. */
  13195. _updateCache(ignoreParentClass?: boolean): void;
  13196. /**
  13197. * @hidden
  13198. * Get current device position in babylon world
  13199. */
  13200. _computeDevicePosition(): void;
  13201. /**
  13202. * Updates the current device position and rotation in the babylon world
  13203. */
  13204. update(): void;
  13205. /**
  13206. * @hidden
  13207. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13208. * @returns an identity matrix
  13209. */
  13210. _getViewMatrix(): Matrix;
  13211. private _tmpMatrix;
  13212. /**
  13213. * This function is called by the two RIG cameras.
  13214. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13215. * @hidden
  13216. */
  13217. _getWebVRViewMatrix(): Matrix;
  13218. /** @hidden */
  13219. _getWebVRProjectionMatrix(): Matrix;
  13220. private _onGamepadConnectedObserver;
  13221. private _onGamepadDisconnectedObserver;
  13222. private _updateCacheWhenTrackingDisabledObserver;
  13223. /**
  13224. * Initializes the controllers and their meshes
  13225. */
  13226. initControllers(): void;
  13227. }
  13228. }
  13229. declare module "babylonjs/PostProcesses/postProcess" {
  13230. import { Nullable } from "babylonjs/types";
  13231. import { SmartArray } from "babylonjs/Misc/smartArray";
  13232. import { Observable } from "babylonjs/Misc/observable";
  13233. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13234. import { Camera } from "babylonjs/Cameras/camera";
  13235. import { Effect } from "babylonjs/Materials/effect";
  13236. import "babylonjs/Shaders/postprocess.vertex";
  13237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13238. import { Engine } from "babylonjs/Engines/engine";
  13239. /**
  13240. * Size options for a post process
  13241. */
  13242. export type PostProcessOptions = {
  13243. width: number;
  13244. height: number;
  13245. };
  13246. /**
  13247. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13248. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13249. */
  13250. export class PostProcess {
  13251. /** Name of the PostProcess. */
  13252. name: string;
  13253. /**
  13254. * Gets or sets the unique id of the post process
  13255. */
  13256. uniqueId: number;
  13257. /**
  13258. * Width of the texture to apply the post process on
  13259. */
  13260. width: number;
  13261. /**
  13262. * Height of the texture to apply the post process on
  13263. */
  13264. height: number;
  13265. /**
  13266. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13267. * @hidden
  13268. */
  13269. _outputTexture: Nullable<InternalTexture>;
  13270. /**
  13271. * Sampling mode used by the shader
  13272. * See https://doc.babylonjs.com/classes/3.1/texture
  13273. */
  13274. renderTargetSamplingMode: number;
  13275. /**
  13276. * Clear color to use when screen clearing
  13277. */
  13278. clearColor: Color4;
  13279. /**
  13280. * If the buffer needs to be cleared before applying the post process. (default: true)
  13281. * Should be set to false if shader will overwrite all previous pixels.
  13282. */
  13283. autoClear: boolean;
  13284. /**
  13285. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13286. */
  13287. alphaMode: number;
  13288. /**
  13289. * Sets the setAlphaBlendConstants of the babylon engine
  13290. */
  13291. alphaConstants: Color4;
  13292. /**
  13293. * Animations to be used for the post processing
  13294. */
  13295. animations: import("babylonjs/Animations/animation").Animation[];
  13296. /**
  13297. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13298. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13299. */
  13300. enablePixelPerfectMode: boolean;
  13301. /**
  13302. * Force the postprocess to be applied without taking in account viewport
  13303. */
  13304. forceFullscreenViewport: boolean;
  13305. /**
  13306. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13307. *
  13308. * | Value | Type | Description |
  13309. * | ----- | ----------------------------------- | ----------- |
  13310. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13311. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13312. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13313. *
  13314. */
  13315. scaleMode: number;
  13316. /**
  13317. * Force textures to be a power of two (default: false)
  13318. */
  13319. alwaysForcePOT: boolean;
  13320. private _samples;
  13321. /**
  13322. * Number of sample textures (default: 1)
  13323. */
  13324. samples: number;
  13325. /**
  13326. * Modify the scale of the post process to be the same as the viewport (default: false)
  13327. */
  13328. adaptScaleToCurrentViewport: boolean;
  13329. private _camera;
  13330. private _scene;
  13331. private _engine;
  13332. private _options;
  13333. private _reusable;
  13334. private _textureType;
  13335. /**
  13336. * Smart array of input and output textures for the post process.
  13337. * @hidden
  13338. */
  13339. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13340. /**
  13341. * The index in _textures that corresponds to the output texture.
  13342. * @hidden
  13343. */
  13344. _currentRenderTextureInd: number;
  13345. private _effect;
  13346. private _samplers;
  13347. private _fragmentUrl;
  13348. private _vertexUrl;
  13349. private _parameters;
  13350. private _scaleRatio;
  13351. protected _indexParameters: any;
  13352. private _shareOutputWithPostProcess;
  13353. private _texelSize;
  13354. private _forcedOutputTexture;
  13355. /**
  13356. * Returns the fragment url or shader name used in the post process.
  13357. * @returns the fragment url or name in the shader store.
  13358. */
  13359. getEffectName(): string;
  13360. /**
  13361. * An event triggered when the postprocess is activated.
  13362. */
  13363. onActivateObservable: Observable<Camera>;
  13364. private _onActivateObserver;
  13365. /**
  13366. * A function that is added to the onActivateObservable
  13367. */
  13368. onActivate: Nullable<(camera: Camera) => void>;
  13369. /**
  13370. * An event triggered when the postprocess changes its size.
  13371. */
  13372. onSizeChangedObservable: Observable<PostProcess>;
  13373. private _onSizeChangedObserver;
  13374. /**
  13375. * A function that is added to the onSizeChangedObservable
  13376. */
  13377. onSizeChanged: (postProcess: PostProcess) => void;
  13378. /**
  13379. * An event triggered when the postprocess applies its effect.
  13380. */
  13381. onApplyObservable: Observable<Effect>;
  13382. private _onApplyObserver;
  13383. /**
  13384. * A function that is added to the onApplyObservable
  13385. */
  13386. onApply: (effect: Effect) => void;
  13387. /**
  13388. * An event triggered before rendering the postprocess
  13389. */
  13390. onBeforeRenderObservable: Observable<Effect>;
  13391. private _onBeforeRenderObserver;
  13392. /**
  13393. * A function that is added to the onBeforeRenderObservable
  13394. */
  13395. onBeforeRender: (effect: Effect) => void;
  13396. /**
  13397. * An event triggered after rendering the postprocess
  13398. */
  13399. onAfterRenderObservable: Observable<Effect>;
  13400. private _onAfterRenderObserver;
  13401. /**
  13402. * A function that is added to the onAfterRenderObservable
  13403. */
  13404. onAfterRender: (efect: Effect) => void;
  13405. /**
  13406. * 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
  13407. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13408. */
  13409. inputTexture: InternalTexture;
  13410. /**
  13411. * Gets the camera which post process is applied to.
  13412. * @returns The camera the post process is applied to.
  13413. */
  13414. getCamera(): Camera;
  13415. /**
  13416. * Gets the texel size of the postprocess.
  13417. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13418. */
  13419. readonly texelSize: Vector2;
  13420. /**
  13421. * Creates a new instance PostProcess
  13422. * @param name The name of the PostProcess.
  13423. * @param fragmentUrl The url of the fragment shader to be used.
  13424. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13425. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13426. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13427. * @param camera The camera to apply the render pass to.
  13428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13429. * @param engine The engine which the post process will be applied. (default: current engine)
  13430. * @param reusable If the post process can be reused on the same frame. (default: false)
  13431. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13432. * @param textureType Type of textures used when performing the post process. (default: 0)
  13433. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13434. * @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
  13435. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13436. */
  13437. constructor(
  13438. /** Name of the PostProcess. */
  13439. 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);
  13440. /**
  13441. * Gets a string idenfifying the name of the class
  13442. * @returns "PostProcess" string
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Gets the engine which this post process belongs to.
  13447. * @returns The engine the post process was enabled with.
  13448. */
  13449. getEngine(): Engine;
  13450. /**
  13451. * The effect that is created when initializing the post process.
  13452. * @returns The created effect corrisponding the the postprocess.
  13453. */
  13454. getEffect(): Effect;
  13455. /**
  13456. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13457. * @param postProcess The post process to share the output with.
  13458. * @returns This post process.
  13459. */
  13460. shareOutputWith(postProcess: PostProcess): PostProcess;
  13461. /**
  13462. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13463. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13464. */
  13465. useOwnOutput(): void;
  13466. /**
  13467. * Updates the effect with the current post process compile time values and recompiles the shader.
  13468. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13469. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13470. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13471. * @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
  13472. * @param onCompiled Called when the shader has been compiled.
  13473. * @param onError Called if there is an error when compiling a shader.
  13474. */
  13475. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13476. /**
  13477. * The post process is reusable if it can be used multiple times within one frame.
  13478. * @returns If the post process is reusable
  13479. */
  13480. isReusable(): boolean;
  13481. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13482. markTextureDirty(): void;
  13483. /**
  13484. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13485. * 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.
  13486. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13487. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13488. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13489. * @returns The target texture that was bound to be written to.
  13490. */
  13491. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13492. /**
  13493. * If the post process is supported.
  13494. */
  13495. readonly isSupported: boolean;
  13496. /**
  13497. * The aspect ratio of the output texture.
  13498. */
  13499. readonly aspectRatio: number;
  13500. /**
  13501. * Get a value indicating if the post-process is ready to be used
  13502. * @returns true if the post-process is ready (shader is compiled)
  13503. */
  13504. isReady(): boolean;
  13505. /**
  13506. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13507. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13508. */
  13509. apply(): Nullable<Effect>;
  13510. private _disposeTextures;
  13511. /**
  13512. * Disposes the post process.
  13513. * @param camera The camera to dispose the post process on.
  13514. */
  13515. dispose(camera?: Camera): void;
  13516. }
  13517. }
  13518. declare module "babylonjs/PostProcesses/postProcessManager" {
  13519. import { Nullable } from "babylonjs/types";
  13520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13522. import { Scene } from "babylonjs/scene";
  13523. /**
  13524. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13525. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13526. */
  13527. export class PostProcessManager {
  13528. private _scene;
  13529. private _indexBuffer;
  13530. private _vertexBuffers;
  13531. /**
  13532. * Creates a new instance PostProcess
  13533. * @param scene The scene that the post process is associated with.
  13534. */
  13535. constructor(scene: Scene);
  13536. private _prepareBuffers;
  13537. private _buildIndexBuffer;
  13538. /**
  13539. * Rebuilds the vertex buffers of the manager.
  13540. * @hidden
  13541. */
  13542. _rebuild(): void;
  13543. /**
  13544. * Prepares a frame to be run through a post process.
  13545. * @param sourceTexture The input texture to the post procesess. (default: null)
  13546. * @param postProcesses An array of post processes to be run. (default: null)
  13547. * @returns True if the post processes were able to be run.
  13548. * @hidden
  13549. */
  13550. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13551. /**
  13552. * Manually render a set of post processes to a texture.
  13553. * @param postProcesses An array of post processes to be run.
  13554. * @param targetTexture The target texture to render to.
  13555. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13556. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13557. * @param lodLevel defines which lod of the texture to render to
  13558. */
  13559. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13560. /**
  13561. * Finalize the result of the output of the postprocesses.
  13562. * @param doNotPresent If true the result will not be displayed to the screen.
  13563. * @param targetTexture The target texture to render to.
  13564. * @param faceIndex The index of the face to bind the target texture to.
  13565. * @param postProcesses The array of post processes to render.
  13566. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13567. * @hidden
  13568. */
  13569. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13570. /**
  13571. * Disposes of the post process manager.
  13572. */
  13573. dispose(): void;
  13574. }
  13575. }
  13576. declare module "babylonjs/Layers/layerSceneComponent" {
  13577. import { Scene } from "babylonjs/scene";
  13578. import { ISceneComponent } from "babylonjs/sceneComponent";
  13579. import { Layer } from "babylonjs/Layers/layer";
  13580. module "babylonjs/abstractScene" {
  13581. interface AbstractScene {
  13582. /**
  13583. * The list of layers (background and foreground) of the scene
  13584. */
  13585. layers: Array<Layer>;
  13586. }
  13587. }
  13588. /**
  13589. * Defines the layer scene component responsible to manage any layers
  13590. * in a given scene.
  13591. */
  13592. export class LayerSceneComponent implements ISceneComponent {
  13593. /**
  13594. * The component name helpfull to identify the component in the list of scene components.
  13595. */
  13596. readonly name: string;
  13597. /**
  13598. * The scene the component belongs to.
  13599. */
  13600. scene: Scene;
  13601. private _engine;
  13602. /**
  13603. * Creates a new instance of the component for the given scene
  13604. * @param scene Defines the scene to register the component in
  13605. */
  13606. constructor(scene: Scene);
  13607. /**
  13608. * Registers the component in a given scene
  13609. */
  13610. register(): void;
  13611. /**
  13612. * Rebuilds the elements related to this component in case of
  13613. * context lost for instance.
  13614. */
  13615. rebuild(): void;
  13616. /**
  13617. * Disposes the component and the associated ressources.
  13618. */
  13619. dispose(): void;
  13620. private _draw;
  13621. private _drawCameraPredicate;
  13622. private _drawCameraBackground;
  13623. private _drawCameraForeground;
  13624. private _drawRenderTargetPredicate;
  13625. private _drawRenderTargetBackground;
  13626. private _drawRenderTargetForeground;
  13627. }
  13628. }
  13629. declare module "babylonjs/Shaders/layer.fragment" {
  13630. /** @hidden */
  13631. export var layerPixelShader: {
  13632. name: string;
  13633. shader: string;
  13634. };
  13635. }
  13636. declare module "babylonjs/Shaders/layer.vertex" {
  13637. /** @hidden */
  13638. export var layerVertexShader: {
  13639. name: string;
  13640. shader: string;
  13641. };
  13642. }
  13643. declare module "babylonjs/Layers/layer" {
  13644. import { Observable } from "babylonjs/Misc/observable";
  13645. import { Nullable } from "babylonjs/types";
  13646. import { Scene } from "babylonjs/scene";
  13647. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13648. import { Texture } from "babylonjs/Materials/Textures/texture";
  13649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13650. import "babylonjs/Shaders/layer.fragment";
  13651. import "babylonjs/Shaders/layer.vertex";
  13652. /**
  13653. * This represents a full screen 2d layer.
  13654. * This can be useful to display a picture in the background of your scene for instance.
  13655. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13656. */
  13657. export class Layer {
  13658. /**
  13659. * Define the name of the layer.
  13660. */
  13661. name: string;
  13662. /**
  13663. * Define the texture the layer should display.
  13664. */
  13665. texture: Nullable<Texture>;
  13666. /**
  13667. * Is the layer in background or foreground.
  13668. */
  13669. isBackground: boolean;
  13670. /**
  13671. * Define the color of the layer (instead of texture).
  13672. */
  13673. color: Color4;
  13674. /**
  13675. * Define the scale of the layer in order to zoom in out of the texture.
  13676. */
  13677. scale: Vector2;
  13678. /**
  13679. * Define an offset for the layer in order to shift the texture.
  13680. */
  13681. offset: Vector2;
  13682. /**
  13683. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13684. */
  13685. alphaBlendingMode: number;
  13686. /**
  13687. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13688. * Alpha test will not mix with the background color in case of transparency.
  13689. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13690. */
  13691. alphaTest: boolean;
  13692. /**
  13693. * Define a mask to restrict the layer to only some of the scene cameras.
  13694. */
  13695. layerMask: number;
  13696. /**
  13697. * Define the list of render target the layer is visible into.
  13698. */
  13699. renderTargetTextures: RenderTargetTexture[];
  13700. /**
  13701. * Define if the layer is only used in renderTarget or if it also
  13702. * renders in the main frame buffer of the canvas.
  13703. */
  13704. renderOnlyInRenderTargetTextures: boolean;
  13705. private _scene;
  13706. private _vertexBuffers;
  13707. private _indexBuffer;
  13708. private _effect;
  13709. private _alphaTestEffect;
  13710. /**
  13711. * An event triggered when the layer is disposed.
  13712. */
  13713. onDisposeObservable: Observable<Layer>;
  13714. private _onDisposeObserver;
  13715. /**
  13716. * Back compatibility with callback before the onDisposeObservable existed.
  13717. * The set callback will be triggered when the layer has been disposed.
  13718. */
  13719. onDispose: () => void;
  13720. /**
  13721. * An event triggered before rendering the scene
  13722. */
  13723. onBeforeRenderObservable: Observable<Layer>;
  13724. private _onBeforeRenderObserver;
  13725. /**
  13726. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13727. * The set callback will be triggered just before rendering the layer.
  13728. */
  13729. onBeforeRender: () => void;
  13730. /**
  13731. * An event triggered after rendering the scene
  13732. */
  13733. onAfterRenderObservable: Observable<Layer>;
  13734. private _onAfterRenderObserver;
  13735. /**
  13736. * Back compatibility with callback before the onAfterRenderObservable existed.
  13737. * The set callback will be triggered just after rendering the layer.
  13738. */
  13739. onAfterRender: () => void;
  13740. /**
  13741. * Instantiates a new layer.
  13742. * This represents a full screen 2d layer.
  13743. * This can be useful to display a picture in the background of your scene for instance.
  13744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13745. * @param name Define the name of the layer in the scene
  13746. * @param imgUrl Define the url of the texture to display in the layer
  13747. * @param scene Define the scene the layer belongs to
  13748. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13749. * @param color Defines a color for the layer
  13750. */
  13751. constructor(
  13752. /**
  13753. * Define the name of the layer.
  13754. */
  13755. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13756. private _createIndexBuffer;
  13757. /** @hidden */
  13758. _rebuild(): void;
  13759. /**
  13760. * Renders the layer in the scene.
  13761. */
  13762. render(): void;
  13763. /**
  13764. * Disposes and releases the associated ressources.
  13765. */
  13766. dispose(): void;
  13767. }
  13768. }
  13769. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13770. import { Scene } from "babylonjs/scene";
  13771. import { ISceneComponent } from "babylonjs/sceneComponent";
  13772. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13773. module "babylonjs/abstractScene" {
  13774. interface AbstractScene {
  13775. /**
  13776. * The list of procedural textures added to the scene
  13777. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13778. */
  13779. proceduralTextures: Array<ProceduralTexture>;
  13780. }
  13781. }
  13782. /**
  13783. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13784. * in a given scene.
  13785. */
  13786. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13787. /**
  13788. * The component name helpfull to identify the component in the list of scene components.
  13789. */
  13790. readonly name: string;
  13791. /**
  13792. * The scene the component belongs to.
  13793. */
  13794. scene: Scene;
  13795. /**
  13796. * Creates a new instance of the component for the given scene
  13797. * @param scene Defines the scene to register the component in
  13798. */
  13799. constructor(scene: Scene);
  13800. /**
  13801. * Registers the component in a given scene
  13802. */
  13803. register(): void;
  13804. /**
  13805. * Rebuilds the elements related to this component in case of
  13806. * context lost for instance.
  13807. */
  13808. rebuild(): void;
  13809. /**
  13810. * Disposes the component and the associated ressources.
  13811. */
  13812. dispose(): void;
  13813. private _beforeClear;
  13814. }
  13815. }
  13816. declare module "babylonjs/Shaders/procedural.vertex" {
  13817. /** @hidden */
  13818. export var proceduralVertexShader: {
  13819. name: string;
  13820. shader: string;
  13821. };
  13822. }
  13823. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13824. import { Observable } from "babylonjs/Misc/observable";
  13825. import { Nullable } from "babylonjs/types";
  13826. import { Scene } from "babylonjs/scene";
  13827. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13828. import { Effect } from "babylonjs/Materials/effect";
  13829. import { Texture } from "babylonjs/Materials/Textures/texture";
  13830. import "babylonjs/Shaders/procedural.vertex";
  13831. /**
  13832. * 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.
  13833. * This is the base class of any Procedural texture and contains most of the shareable code.
  13834. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13835. */
  13836. export class ProceduralTexture extends Texture {
  13837. isCube: boolean;
  13838. /**
  13839. * Define if the texture is enabled or not (disabled texture will not render)
  13840. */
  13841. isEnabled: boolean;
  13842. /**
  13843. * Define if the texture must be cleared before rendering (default is true)
  13844. */
  13845. autoClear: boolean;
  13846. /**
  13847. * Callback called when the texture is generated
  13848. */
  13849. onGenerated: () => void;
  13850. /**
  13851. * Event raised when the texture is generated
  13852. */
  13853. onGeneratedObservable: Observable<ProceduralTexture>;
  13854. /** @hidden */
  13855. _generateMipMaps: boolean;
  13856. /** @hidden **/
  13857. _effect: Effect;
  13858. /** @hidden */
  13859. _textures: {
  13860. [key: string]: Texture;
  13861. };
  13862. private _size;
  13863. private _currentRefreshId;
  13864. private _refreshRate;
  13865. private _vertexBuffers;
  13866. private _indexBuffer;
  13867. private _uniforms;
  13868. private _samplers;
  13869. private _fragment;
  13870. private _floats;
  13871. private _ints;
  13872. private _floatsArrays;
  13873. private _colors3;
  13874. private _colors4;
  13875. private _vectors2;
  13876. private _vectors3;
  13877. private _matrices;
  13878. private _fallbackTexture;
  13879. private _fallbackTextureUsed;
  13880. private _engine;
  13881. private _cachedDefines;
  13882. private _contentUpdateId;
  13883. private _contentData;
  13884. /**
  13885. * Instantiates a new procedural texture.
  13886. * 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.
  13887. * This is the base class of any Procedural texture and contains most of the shareable code.
  13888. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13889. * @param name Define the name of the texture
  13890. * @param size Define the size of the texture to create
  13891. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13892. * @param scene Define the scene the texture belongs to
  13893. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13894. * @param generateMipMaps Define if the texture should creates mip maps or not
  13895. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13896. */
  13897. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13898. /**
  13899. * The effect that is created when initializing the post process.
  13900. * @returns The created effect corrisponding the the postprocess.
  13901. */
  13902. getEffect(): Effect;
  13903. /**
  13904. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13905. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13906. */
  13907. getContent(): Nullable<ArrayBufferView>;
  13908. private _createIndexBuffer;
  13909. /** @hidden */
  13910. _rebuild(): void;
  13911. /**
  13912. * Resets the texture in order to recreate its associated resources.
  13913. * This can be called in case of context loss
  13914. */
  13915. reset(): void;
  13916. protected _getDefines(): string;
  13917. /**
  13918. * Is the texture ready to be used ? (rendered at least once)
  13919. * @returns true if ready, otherwise, false.
  13920. */
  13921. isReady(): boolean;
  13922. /**
  13923. * Resets the refresh counter of the texture and start bak from scratch.
  13924. * Could be useful to regenerate the texture if it is setup to render only once.
  13925. */
  13926. resetRefreshCounter(): void;
  13927. /**
  13928. * Set the fragment shader to use in order to render the texture.
  13929. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13930. */
  13931. setFragment(fragment: any): void;
  13932. /**
  13933. * Define the refresh rate of the texture or the rendering frequency.
  13934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13935. */
  13936. refreshRate: number;
  13937. /** @hidden */
  13938. _shouldRender(): boolean;
  13939. /**
  13940. * Get the size the texture is rendering at.
  13941. * @returns the size (texture is always squared)
  13942. */
  13943. getRenderSize(): number;
  13944. /**
  13945. * Resize the texture to new value.
  13946. * @param size Define the new size the texture should have
  13947. * @param generateMipMaps Define whether the new texture should create mip maps
  13948. */
  13949. resize(size: number, generateMipMaps: boolean): void;
  13950. private _checkUniform;
  13951. /**
  13952. * Set a texture in the shader program used to render.
  13953. * @param name Define the name of the uniform samplers as defined in the shader
  13954. * @param texture Define the texture to bind to this sampler
  13955. * @return the texture itself allowing "fluent" like uniform updates
  13956. */
  13957. setTexture(name: string, texture: Texture): ProceduralTexture;
  13958. /**
  13959. * Set a float in the shader.
  13960. * @param name Define the name of the uniform as defined in the shader
  13961. * @param value Define the value to give to the uniform
  13962. * @return the texture itself allowing "fluent" like uniform updates
  13963. */
  13964. setFloat(name: string, value: number): ProceduralTexture;
  13965. /**
  13966. * Set a int in the shader.
  13967. * @param name Define the name of the uniform as defined in the shader
  13968. * @param value Define the value to give to the uniform
  13969. * @return the texture itself allowing "fluent" like uniform updates
  13970. */
  13971. setInt(name: string, value: number): ProceduralTexture;
  13972. /**
  13973. * Set an array of floats in the shader.
  13974. * @param name Define the name of the uniform as defined in the shader
  13975. * @param value Define the value to give to the uniform
  13976. * @return the texture itself allowing "fluent" like uniform updates
  13977. */
  13978. setFloats(name: string, value: number[]): ProceduralTexture;
  13979. /**
  13980. * Set a vec3 in the shader from a Color3.
  13981. * @param name Define the name of the uniform as defined in the shader
  13982. * @param value Define the value to give to the uniform
  13983. * @return the texture itself allowing "fluent" like uniform updates
  13984. */
  13985. setColor3(name: string, value: Color3): ProceduralTexture;
  13986. /**
  13987. * Set a vec4 in the shader from a Color4.
  13988. * @param name Define the name of the uniform as defined in the shader
  13989. * @param value Define the value to give to the uniform
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setColor4(name: string, value: Color4): ProceduralTexture;
  13993. /**
  13994. * Set a vec2 in the shader from a Vector2.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setVector2(name: string, value: Vector2): ProceduralTexture;
  14000. /**
  14001. * Set a vec3 in the shader from a Vector3.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setVector3(name: string, value: Vector3): ProceduralTexture;
  14007. /**
  14008. * Set a mat4 in the shader from a MAtrix.
  14009. * @param name Define the name of the uniform as defined in the shader
  14010. * @param value Define the value to give to the uniform
  14011. * @return the texture itself allowing "fluent" like uniform updates
  14012. */
  14013. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14014. /**
  14015. * Render the texture to its associated render target.
  14016. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14017. */
  14018. render(useCameraPostProcess?: boolean): void;
  14019. /**
  14020. * Clone the texture.
  14021. * @returns the cloned texture
  14022. */
  14023. clone(): ProceduralTexture;
  14024. /**
  14025. * Dispose the texture and release its asoociated resources.
  14026. */
  14027. dispose(): void;
  14028. }
  14029. }
  14030. declare module "babylonjs/Particles/baseParticleSystem" {
  14031. import { Nullable } from "babylonjs/types";
  14032. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14034. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14035. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14036. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14037. import { Scene } from "babylonjs/scene";
  14038. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14039. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14040. import { Texture } from "babylonjs/Materials/Textures/texture";
  14041. import { Animation } from "babylonjs/Animations/animation";
  14042. /**
  14043. * This represents the base class for particle system in Babylon.
  14044. * 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.
  14045. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14046. * @example https://doc.babylonjs.com/babylon101/particles
  14047. */
  14048. export class BaseParticleSystem {
  14049. /**
  14050. * Source color is added to the destination color without alpha affecting the result
  14051. */
  14052. static BLENDMODE_ONEONE: number;
  14053. /**
  14054. * Blend current color and particle color using particle’s alpha
  14055. */
  14056. static BLENDMODE_STANDARD: number;
  14057. /**
  14058. * Add current color and particle color multiplied by particle’s alpha
  14059. */
  14060. static BLENDMODE_ADD: number;
  14061. /**
  14062. * Multiply current color with particle color
  14063. */
  14064. static BLENDMODE_MULTIPLY: number;
  14065. /**
  14066. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14067. */
  14068. static BLENDMODE_MULTIPLYADD: number;
  14069. /**
  14070. * List of animations used by the particle system.
  14071. */
  14072. animations: Animation[];
  14073. /**
  14074. * The id of the Particle system.
  14075. */
  14076. id: string;
  14077. /**
  14078. * The friendly name of the Particle system.
  14079. */
  14080. name: string;
  14081. /**
  14082. * The rendering group used by the Particle system to chose when to render.
  14083. */
  14084. renderingGroupId: number;
  14085. /**
  14086. * The emitter represents the Mesh or position we are attaching the particle system to.
  14087. */
  14088. emitter: Nullable<AbstractMesh | Vector3>;
  14089. /**
  14090. * The maximum number of particles to emit per frame
  14091. */
  14092. emitRate: number;
  14093. /**
  14094. * If you want to launch only a few particles at once, that can be done, as well.
  14095. */
  14096. manualEmitCount: number;
  14097. /**
  14098. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14099. */
  14100. updateSpeed: number;
  14101. /**
  14102. * The amount of time the particle system is running (depends of the overall update speed).
  14103. */
  14104. targetStopDuration: number;
  14105. /**
  14106. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14107. */
  14108. disposeOnStop: boolean;
  14109. /**
  14110. * Minimum power of emitting particles.
  14111. */
  14112. minEmitPower: number;
  14113. /**
  14114. * Maximum power of emitting particles.
  14115. */
  14116. maxEmitPower: number;
  14117. /**
  14118. * Minimum life time of emitting particles.
  14119. */
  14120. minLifeTime: number;
  14121. /**
  14122. * Maximum life time of emitting particles.
  14123. */
  14124. maxLifeTime: number;
  14125. /**
  14126. * Minimum Size of emitting particles.
  14127. */
  14128. minSize: number;
  14129. /**
  14130. * Maximum Size of emitting particles.
  14131. */
  14132. maxSize: number;
  14133. /**
  14134. * Minimum scale of emitting particles on X axis.
  14135. */
  14136. minScaleX: number;
  14137. /**
  14138. * Maximum scale of emitting particles on X axis.
  14139. */
  14140. maxScaleX: number;
  14141. /**
  14142. * Minimum scale of emitting particles on Y axis.
  14143. */
  14144. minScaleY: number;
  14145. /**
  14146. * Maximum scale of emitting particles on Y axis.
  14147. */
  14148. maxScaleY: number;
  14149. /**
  14150. * Gets or sets the minimal initial rotation in radians.
  14151. */
  14152. minInitialRotation: number;
  14153. /**
  14154. * Gets or sets the maximal initial rotation in radians.
  14155. */
  14156. maxInitialRotation: number;
  14157. /**
  14158. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14159. */
  14160. minAngularSpeed: number;
  14161. /**
  14162. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14163. */
  14164. maxAngularSpeed: number;
  14165. /**
  14166. * The texture used to render each particle. (this can be a spritesheet)
  14167. */
  14168. particleTexture: Nullable<Texture>;
  14169. /**
  14170. * The layer mask we are rendering the particles through.
  14171. */
  14172. layerMask: number;
  14173. /**
  14174. * This can help using your own shader to render the particle system.
  14175. * The according effect will be created
  14176. */
  14177. customShader: any;
  14178. /**
  14179. * By default particle system starts as soon as they are created. This prevents the
  14180. * automatic start to happen and let you decide when to start emitting particles.
  14181. */
  14182. preventAutoStart: boolean;
  14183. private _noiseTexture;
  14184. /**
  14185. * Gets or sets a texture used to add random noise to particle positions
  14186. */
  14187. noiseTexture: Nullable<ProceduralTexture>;
  14188. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14189. noiseStrength: Vector3;
  14190. /**
  14191. * Callback triggered when the particle animation is ending.
  14192. */
  14193. onAnimationEnd: Nullable<() => void>;
  14194. /**
  14195. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14196. */
  14197. blendMode: number;
  14198. /**
  14199. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14200. * to override the particles.
  14201. */
  14202. forceDepthWrite: boolean;
  14203. /** 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 */
  14204. preWarmCycles: number;
  14205. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14206. preWarmStepOffset: number;
  14207. /**
  14208. * 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)
  14209. */
  14210. spriteCellChangeSpeed: number;
  14211. /**
  14212. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14213. */
  14214. startSpriteCellID: number;
  14215. /**
  14216. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14217. */
  14218. endSpriteCellID: number;
  14219. /**
  14220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14221. */
  14222. spriteCellWidth: number;
  14223. /**
  14224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14225. */
  14226. spriteCellHeight: number;
  14227. /**
  14228. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14229. */
  14230. spriteRandomStartCell: boolean;
  14231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14232. translationPivot: Vector2;
  14233. /** @hidden */
  14234. protected _isAnimationSheetEnabled: boolean;
  14235. /**
  14236. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14237. */
  14238. beginAnimationOnStart: boolean;
  14239. /**
  14240. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14241. */
  14242. beginAnimationFrom: number;
  14243. /**
  14244. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14245. */
  14246. beginAnimationTo: number;
  14247. /**
  14248. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14249. */
  14250. beginAnimationLoop: boolean;
  14251. /**
  14252. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14253. */
  14254. isAnimationSheetEnabled: boolean;
  14255. /**
  14256. * Get hosting scene
  14257. * @returns the scene
  14258. */
  14259. getScene(): Scene;
  14260. /**
  14261. * You can use gravity if you want to give an orientation to your particles.
  14262. */
  14263. gravity: Vector3;
  14264. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14265. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14266. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14267. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14268. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14269. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14270. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14271. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14272. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14273. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14274. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14275. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14276. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14277. /**
  14278. * Defines the delay in milliseconds before starting the system (0 by default)
  14279. */
  14280. startDelay: number;
  14281. /**
  14282. * Gets the current list of drag gradients.
  14283. * You must use addDragGradient and removeDragGradient to udpate this list
  14284. * @returns the list of drag gradients
  14285. */
  14286. getDragGradients(): Nullable<Array<FactorGradient>>;
  14287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14288. limitVelocityDamping: number;
  14289. /**
  14290. * Gets the current list of limit velocity gradients.
  14291. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14292. * @returns the list of limit velocity gradients
  14293. */
  14294. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of color gradients.
  14297. * You must use addColorGradient and removeColorGradient to udpate this list
  14298. * @returns the list of color gradients
  14299. */
  14300. getColorGradients(): Nullable<Array<ColorGradient>>;
  14301. /**
  14302. * Gets the current list of size gradients.
  14303. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14304. * @returns the list of size gradients
  14305. */
  14306. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Gets the current list of color remap gradients.
  14309. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14310. * @returns the list of color remap gradients
  14311. */
  14312. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14313. /**
  14314. * Gets the current list of alpha remap gradients.
  14315. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14316. * @returns the list of alpha remap gradients
  14317. */
  14318. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14319. /**
  14320. * Gets the current list of life time gradients.
  14321. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14322. * @returns the list of life time gradients
  14323. */
  14324. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Gets the current list of angular speed gradients.
  14327. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14328. * @returns the list of angular speed gradients
  14329. */
  14330. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Gets the current list of velocity gradients.
  14333. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14334. * @returns the list of velocity gradients
  14335. */
  14336. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14337. /**
  14338. * Gets the current list of start size gradients.
  14339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14340. * @returns the list of start size gradients
  14341. */
  14342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Gets the current list of emit rate gradients.
  14345. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14346. * @returns the list of emit rate gradients
  14347. */
  14348. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14349. /**
  14350. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14352. */
  14353. direction1: Vector3;
  14354. /**
  14355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14356. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14357. */
  14358. direction2: Vector3;
  14359. /**
  14360. * 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.
  14361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14362. */
  14363. minEmitBox: Vector3;
  14364. /**
  14365. * 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.
  14366. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14367. */
  14368. maxEmitBox: Vector3;
  14369. /**
  14370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14371. */
  14372. color1: Color4;
  14373. /**
  14374. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14375. */
  14376. color2: Color4;
  14377. /**
  14378. * Color the particle will have at the end of its lifetime
  14379. */
  14380. colorDead: Color4;
  14381. /**
  14382. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14383. */
  14384. textureMask: Color4;
  14385. /**
  14386. * The particle emitter type defines the emitter used by the particle system.
  14387. * It can be for example box, sphere, or cone...
  14388. */
  14389. particleEmitterType: IParticleEmitterType;
  14390. /** @hidden */
  14391. _isSubEmitter: boolean;
  14392. /**
  14393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14395. */
  14396. billboardMode: number;
  14397. protected _isBillboardBased: boolean;
  14398. /**
  14399. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14400. */
  14401. isBillboardBased: boolean;
  14402. /**
  14403. * The scene the particle system belongs to.
  14404. */
  14405. protected _scene: Scene;
  14406. /**
  14407. * Local cache of defines for image processing.
  14408. */
  14409. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14410. /**
  14411. * Default configuration related to image processing available in the standard Material.
  14412. */
  14413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14414. /**
  14415. * Gets the image processing configuration used either in this material.
  14416. */
  14417. /**
  14418. * Sets the Default image processing configuration used either in the this material.
  14419. *
  14420. * If sets to null, the scene one is in use.
  14421. */
  14422. imageProcessingConfiguration: ImageProcessingConfiguration;
  14423. /**
  14424. * Attaches a new image processing configuration to the Standard Material.
  14425. * @param configuration
  14426. */
  14427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14428. /** @hidden */
  14429. protected _reset(): void;
  14430. /** @hidden */
  14431. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14432. /**
  14433. * Instantiates a particle system.
  14434. * 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.
  14435. * @param name The name of the particle system
  14436. */
  14437. constructor(name: string);
  14438. /**
  14439. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14442. * @returns the emitter
  14443. */
  14444. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14445. /**
  14446. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14447. * @param radius The radius of the hemisphere to emit from
  14448. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14449. * @returns the emitter
  14450. */
  14451. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14452. /**
  14453. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14454. * @param radius The radius of the sphere to emit from
  14455. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14456. * @returns the emitter
  14457. */
  14458. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14459. /**
  14460. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14461. * @param radius The radius of the sphere to emit from
  14462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14464. * @returns the emitter
  14465. */
  14466. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14467. /**
  14468. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14469. * @param radius The radius of the emission cylinder
  14470. * @param height The height of the emission cylinder
  14471. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14472. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14473. * @returns the emitter
  14474. */
  14475. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14476. /**
  14477. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14478. * @param radius The radius of the cylinder to emit from
  14479. * @param height The height of the emission cylinder
  14480. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14481. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14482. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14483. * @returns the emitter
  14484. */
  14485. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14486. /**
  14487. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14488. * @param radius The radius of the cone to emit from
  14489. * @param angle The base angle of the cone
  14490. * @returns the emitter
  14491. */
  14492. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14493. /**
  14494. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14498. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14499. * @returns the emitter
  14500. */
  14501. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14502. }
  14503. }
  14504. declare module "babylonjs/Particles/subEmitter" {
  14505. import { Scene } from "babylonjs/scene";
  14506. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14507. /**
  14508. * Type of sub emitter
  14509. */
  14510. export enum SubEmitterType {
  14511. /**
  14512. * Attached to the particle over it's lifetime
  14513. */
  14514. ATTACHED = 0,
  14515. /**
  14516. * Created when the particle dies
  14517. */
  14518. END = 1
  14519. }
  14520. /**
  14521. * Sub emitter class used to emit particles from an existing particle
  14522. */
  14523. export class SubEmitter {
  14524. /**
  14525. * the particle system to be used by the sub emitter
  14526. */
  14527. particleSystem: ParticleSystem;
  14528. /**
  14529. * Type of the submitter (Default: END)
  14530. */
  14531. type: SubEmitterType;
  14532. /**
  14533. * 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)
  14534. * Note: This only is supported when using an emitter of type Mesh
  14535. */
  14536. inheritDirection: boolean;
  14537. /**
  14538. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14539. */
  14540. inheritedVelocityAmount: number;
  14541. /**
  14542. * Creates a sub emitter
  14543. * @param particleSystem the particle system to be used by the sub emitter
  14544. */
  14545. constructor(
  14546. /**
  14547. * the particle system to be used by the sub emitter
  14548. */
  14549. particleSystem: ParticleSystem);
  14550. /**
  14551. * Clones the sub emitter
  14552. * @returns the cloned sub emitter
  14553. */
  14554. clone(): SubEmitter;
  14555. /**
  14556. * Serialize current object to a JSON object
  14557. * @returns the serialized object
  14558. */
  14559. serialize(): any;
  14560. /** @hidden */
  14561. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14562. /**
  14563. * Creates a new SubEmitter from a serialized JSON version
  14564. * @param serializationObject defines the JSON object to read from
  14565. * @param scene defines the hosting scene
  14566. * @param rootUrl defines the rootUrl for data loading
  14567. * @returns a new SubEmitter
  14568. */
  14569. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14570. /** Release associated resources */
  14571. dispose(): void;
  14572. }
  14573. }
  14574. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14575. /** @hidden */
  14576. export var clipPlaneFragmentDeclaration: {
  14577. name: string;
  14578. shader: string;
  14579. };
  14580. }
  14581. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14582. /** @hidden */
  14583. export var imageProcessingDeclaration: {
  14584. name: string;
  14585. shader: string;
  14586. };
  14587. }
  14588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14589. /** @hidden */
  14590. export var imageProcessingFunctions: {
  14591. name: string;
  14592. shader: string;
  14593. };
  14594. }
  14595. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14596. /** @hidden */
  14597. export var clipPlaneFragment: {
  14598. name: string;
  14599. shader: string;
  14600. };
  14601. }
  14602. declare module "babylonjs/Shaders/particles.fragment" {
  14603. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14608. /** @hidden */
  14609. export var particlesPixelShader: {
  14610. name: string;
  14611. shader: string;
  14612. };
  14613. }
  14614. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14615. /** @hidden */
  14616. export var clipPlaneVertexDeclaration: {
  14617. name: string;
  14618. shader: string;
  14619. };
  14620. }
  14621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14622. /** @hidden */
  14623. export var clipPlaneVertex: {
  14624. name: string;
  14625. shader: string;
  14626. };
  14627. }
  14628. declare module "babylonjs/Shaders/particles.vertex" {
  14629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14631. /** @hidden */
  14632. export var particlesVertexShader: {
  14633. name: string;
  14634. shader: string;
  14635. };
  14636. }
  14637. declare module "babylonjs/Particles/particleSystem" {
  14638. import { Nullable } from "babylonjs/types";
  14639. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14640. import { Observable } from "babylonjs/Misc/observable";
  14641. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14642. import { Effect } from "babylonjs/Materials/effect";
  14643. import { Scene, IDisposable } from "babylonjs/scene";
  14644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14645. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14646. import { Particle } from "babylonjs/Particles/particle";
  14647. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14648. import "babylonjs/Shaders/particles.fragment";
  14649. import "babylonjs/Shaders/particles.vertex";
  14650. /**
  14651. * This represents a particle system in Babylon.
  14652. * 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.
  14653. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14654. * @example https://doc.babylonjs.com/babylon101/particles
  14655. */
  14656. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14657. /**
  14658. * Billboard mode will only apply to Y axis
  14659. */
  14660. static readonly BILLBOARDMODE_Y: number;
  14661. /**
  14662. * Billboard mode will apply to all axes
  14663. */
  14664. static readonly BILLBOARDMODE_ALL: number;
  14665. /**
  14666. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14667. */
  14668. static readonly BILLBOARDMODE_STRETCHED: number;
  14669. /**
  14670. * This function can be defined to provide custom update for active particles.
  14671. * This function will be called instead of regular update (age, position, color, etc.).
  14672. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14673. */
  14674. updateFunction: (particles: Particle[]) => void;
  14675. private _emitterWorldMatrix;
  14676. /**
  14677. * This function can be defined to specify initial direction for every new particle.
  14678. * It by default use the emitterType defined function
  14679. */
  14680. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14681. /**
  14682. * This function can be defined to specify initial position for every new particle.
  14683. * It by default use the emitterType defined function
  14684. */
  14685. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14686. /**
  14687. * @hidden
  14688. */
  14689. _inheritedVelocityOffset: Vector3;
  14690. /**
  14691. * An event triggered when the system is disposed
  14692. */
  14693. onDisposeObservable: Observable<ParticleSystem>;
  14694. private _onDisposeObserver;
  14695. /**
  14696. * Sets a callback that will be triggered when the system is disposed
  14697. */
  14698. onDispose: () => void;
  14699. private _particles;
  14700. private _epsilon;
  14701. private _capacity;
  14702. private _stockParticles;
  14703. private _newPartsExcess;
  14704. private _vertexData;
  14705. private _vertexBuffer;
  14706. private _vertexBuffers;
  14707. private _spriteBuffer;
  14708. private _indexBuffer;
  14709. private _effect;
  14710. private _customEffect;
  14711. private _cachedDefines;
  14712. private _scaledColorStep;
  14713. private _colorDiff;
  14714. private _scaledDirection;
  14715. private _scaledGravity;
  14716. private _currentRenderId;
  14717. private _alive;
  14718. private _useInstancing;
  14719. private _started;
  14720. private _stopped;
  14721. private _actualFrame;
  14722. private _scaledUpdateSpeed;
  14723. private _vertexBufferSize;
  14724. /** @hidden */
  14725. _currentEmitRateGradient: Nullable<FactorGradient>;
  14726. /** @hidden */
  14727. _currentEmitRate1: number;
  14728. /** @hidden */
  14729. _currentEmitRate2: number;
  14730. /** @hidden */
  14731. _currentStartSizeGradient: Nullable<FactorGradient>;
  14732. /** @hidden */
  14733. _currentStartSize1: number;
  14734. /** @hidden */
  14735. _currentStartSize2: number;
  14736. private readonly _rawTextureWidth;
  14737. private _rampGradientsTexture;
  14738. private _useRampGradients;
  14739. /** Gets or sets a boolean indicating that ramp gradients must be used
  14740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14741. */
  14742. useRampGradients: boolean;
  14743. /**
  14744. * 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.
  14745. * 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: [])
  14746. */
  14747. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14748. private _subEmitters;
  14749. /**
  14750. * @hidden
  14751. * If the particle systems emitter should be disposed when the particle system is disposed
  14752. */
  14753. _disposeEmitterOnDispose: boolean;
  14754. /**
  14755. * The current active Sub-systems, this property is used by the root particle system only.
  14756. */
  14757. activeSubSystems: Array<ParticleSystem>;
  14758. private _rootParticleSystem;
  14759. /**
  14760. * Gets the current list of active particles
  14761. */
  14762. readonly particles: Particle[];
  14763. /**
  14764. * Returns the string "ParticleSystem"
  14765. * @returns a string containing the class name
  14766. */
  14767. getClassName(): string;
  14768. /**
  14769. * Instantiates a particle system.
  14770. * 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.
  14771. * @param name The name of the particle system
  14772. * @param capacity The max number of particles alive at the same time
  14773. * @param scene The scene the particle system belongs to
  14774. * @param customEffect a custom effect used to change the way particles are rendered by default
  14775. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14776. * @param epsilon Offset used to render the particles
  14777. */
  14778. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14779. private _addFactorGradient;
  14780. private _removeFactorGradient;
  14781. /**
  14782. * Adds a new life time gradient
  14783. * @param gradient defines the gradient to use (between 0 and 1)
  14784. * @param factor defines the life time factor to affect to the specified gradient
  14785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14786. * @returns the current particle system
  14787. */
  14788. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14789. /**
  14790. * Remove a specific life time gradient
  14791. * @param gradient defines the gradient to remove
  14792. * @returns the current particle system
  14793. */
  14794. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14795. /**
  14796. * Adds a new size gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param factor defines the size factor to affect to the specified gradient
  14799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14800. * @returns the current particle system
  14801. */
  14802. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14803. /**
  14804. * Remove a specific size gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeSizeGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new color remap gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param min defines the color remap minimal range
  14813. * @param max defines the color remap maximal range
  14814. * @returns the current particle system
  14815. */
  14816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific color remap gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeColorRemapGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Adds a new alpha remap gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param min defines the alpha remap minimal range
  14827. * @param max defines the alpha remap maximal range
  14828. * @returns the current particle system
  14829. */
  14830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific alpha remap gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new angular speed gradient
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the angular speed to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific angular speed gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14851. /**
  14852. * Adds a new velocity gradient
  14853. * @param gradient defines the gradient to use (between 0 and 1)
  14854. * @param factor defines the velocity to affect to the specified gradient
  14855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14856. * @returns the current particle system
  14857. */
  14858. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14859. /**
  14860. * Remove a specific velocity gradient
  14861. * @param gradient defines the gradient to remove
  14862. * @returns the current particle system
  14863. */
  14864. removeVelocityGradient(gradient: number): IParticleSystem;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity value to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag value to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14895. * @param gradient defines the gradient to use (between 0 and 1)
  14896. * @param factor defines the emit rate value to affect to the specified gradient
  14897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14898. * @returns the current particle system
  14899. */
  14900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14901. /**
  14902. * Remove a specific emit rate gradient
  14903. * @param gradient defines the gradient to remove
  14904. * @returns the current particle system
  14905. */
  14906. removeEmitRateGradient(gradient: number): IParticleSystem;
  14907. /**
  14908. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param factor defines the start size value to affect to the specified gradient
  14911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14912. * @returns the current particle system
  14913. */
  14914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14915. /**
  14916. * Remove a specific start size gradient
  14917. * @param gradient defines the gradient to remove
  14918. * @returns the current particle system
  14919. */
  14920. removeStartSizeGradient(gradient: number): IParticleSystem;
  14921. private _createRampGradientTexture;
  14922. /**
  14923. * Gets the current list of ramp gradients.
  14924. * You must use addRampGradient and removeRampGradient to udpate this list
  14925. * @returns the list of ramp gradients
  14926. */
  14927. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14928. /**
  14929. * Adds a new ramp gradient used to remap particle colors
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param color defines the color to affect to the specified gradient
  14932. * @returns the current particle system
  14933. */
  14934. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14935. /**
  14936. * Remove a specific ramp gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeRampGradient(gradient: number): ParticleSystem;
  14941. /**
  14942. * Adds a new color gradient
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param color1 defines the color to affect to the specified gradient
  14945. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14946. * @returns this particle system
  14947. */
  14948. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14949. /**
  14950. * Remove a specific color gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns this particle system
  14953. */
  14954. removeColorGradient(gradient: number): IParticleSystem;
  14955. private _fetchR;
  14956. protected _reset(): void;
  14957. private _resetEffect;
  14958. private _createVertexBuffers;
  14959. private _createIndexBuffer;
  14960. /**
  14961. * Gets the maximum number of particles active at the same time.
  14962. * @returns The max number of active particles.
  14963. */
  14964. getCapacity(): number;
  14965. /**
  14966. * Gets whether there are still active particles in the system.
  14967. * @returns True if it is alive, otherwise false.
  14968. */
  14969. isAlive(): boolean;
  14970. /**
  14971. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14972. * @returns True if it has been started, otherwise false.
  14973. */
  14974. isStarted(): boolean;
  14975. private _prepareSubEmitterInternalArray;
  14976. /**
  14977. * Starts the particle system and begins to emit
  14978. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14979. */
  14980. start(delay?: number): void;
  14981. /**
  14982. * Stops the particle system.
  14983. * @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.
  14984. */
  14985. stop(stopSubEmitters?: boolean): void;
  14986. /**
  14987. * Remove all active particles
  14988. */
  14989. reset(): void;
  14990. /**
  14991. * @hidden (for internal use only)
  14992. */
  14993. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14994. /**
  14995. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14996. * Its lifetime will start back at 0.
  14997. */
  14998. recycleParticle: (particle: Particle) => void;
  14999. private _stopSubEmitters;
  15000. private _createParticle;
  15001. private _removeFromRoot;
  15002. private _emitFromParticle;
  15003. private _update;
  15004. /** @hidden */
  15005. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15006. /** @hidden */
  15007. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15008. /** @hidden */
  15009. private _getEffect;
  15010. /**
  15011. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15012. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15013. */
  15014. animate(preWarmOnly?: boolean): void;
  15015. private _appendParticleVertices;
  15016. /**
  15017. * Rebuilds the particle system.
  15018. */
  15019. rebuild(): void;
  15020. /**
  15021. * Is this system ready to be used/rendered
  15022. * @return true if the system is ready
  15023. */
  15024. isReady(): boolean;
  15025. private _render;
  15026. /**
  15027. * Renders the particle system in its current state.
  15028. * @returns the current number of particles
  15029. */
  15030. render(): number;
  15031. /**
  15032. * Disposes the particle system and free the associated resources
  15033. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15034. */
  15035. dispose(disposeTexture?: boolean): void;
  15036. /**
  15037. * Clones the particle system.
  15038. * @param name The name of the cloned object
  15039. * @param newEmitter The new emitter to use
  15040. * @returns the cloned particle system
  15041. */
  15042. clone(name: string, newEmitter: any): ParticleSystem;
  15043. /**
  15044. * Serializes the particle system to a JSON object.
  15045. * @returns the JSON object
  15046. */
  15047. serialize(): any;
  15048. /** @hidden */
  15049. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15050. /** @hidden */
  15051. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15052. /**
  15053. * Parses a JSON object to create a particle system.
  15054. * @param parsedParticleSystem The JSON object to parse
  15055. * @param scene The scene to create the particle system in
  15056. * @param rootUrl The root url to use to load external dependencies like texture
  15057. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15058. * @returns the Parsed particle system
  15059. */
  15060. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15061. }
  15062. }
  15063. declare module "babylonjs/Particles/particle" {
  15064. import { Nullable } from "babylonjs/types";
  15065. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15066. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15067. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15068. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15069. /**
  15070. * A particle represents one of the element emitted by a particle system.
  15071. * This is mainly define by its coordinates, direction, velocity and age.
  15072. */
  15073. export class Particle {
  15074. /**
  15075. * The particle system the particle belongs to.
  15076. */
  15077. particleSystem: ParticleSystem;
  15078. private static _Count;
  15079. /**
  15080. * Unique ID of the particle
  15081. */
  15082. id: number;
  15083. /**
  15084. * The world position of the particle in the scene.
  15085. */
  15086. position: Vector3;
  15087. /**
  15088. * The world direction of the particle in the scene.
  15089. */
  15090. direction: Vector3;
  15091. /**
  15092. * The color of the particle.
  15093. */
  15094. color: Color4;
  15095. /**
  15096. * The color change of the particle per step.
  15097. */
  15098. colorStep: Color4;
  15099. /**
  15100. * Defines how long will the life of the particle be.
  15101. */
  15102. lifeTime: number;
  15103. /**
  15104. * The current age of the particle.
  15105. */
  15106. age: number;
  15107. /**
  15108. * The current size of the particle.
  15109. */
  15110. size: number;
  15111. /**
  15112. * The current scale of the particle.
  15113. */
  15114. scale: Vector2;
  15115. /**
  15116. * The current angle of the particle.
  15117. */
  15118. angle: number;
  15119. /**
  15120. * Defines how fast is the angle changing.
  15121. */
  15122. angularSpeed: number;
  15123. /**
  15124. * Defines the cell index used by the particle to be rendered from a sprite.
  15125. */
  15126. cellIndex: number;
  15127. /**
  15128. * The information required to support color remapping
  15129. */
  15130. remapData: Vector4;
  15131. /** @hidden */
  15132. _randomCellOffset?: number;
  15133. /** @hidden */
  15134. _initialDirection: Nullable<Vector3>;
  15135. /** @hidden */
  15136. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15137. /** @hidden */
  15138. _initialStartSpriteCellID: number;
  15139. /** @hidden */
  15140. _initialEndSpriteCellID: number;
  15141. /** @hidden */
  15142. _currentColorGradient: Nullable<ColorGradient>;
  15143. /** @hidden */
  15144. _currentColor1: Color4;
  15145. /** @hidden */
  15146. _currentColor2: Color4;
  15147. /** @hidden */
  15148. _currentSizeGradient: Nullable<FactorGradient>;
  15149. /** @hidden */
  15150. _currentSize1: number;
  15151. /** @hidden */
  15152. _currentSize2: number;
  15153. /** @hidden */
  15154. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15155. /** @hidden */
  15156. _currentAngularSpeed1: number;
  15157. /** @hidden */
  15158. _currentAngularSpeed2: number;
  15159. /** @hidden */
  15160. _currentVelocityGradient: Nullable<FactorGradient>;
  15161. /** @hidden */
  15162. _currentVelocity1: number;
  15163. /** @hidden */
  15164. _currentVelocity2: number;
  15165. /** @hidden */
  15166. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15167. /** @hidden */
  15168. _currentLimitVelocity1: number;
  15169. /** @hidden */
  15170. _currentLimitVelocity2: number;
  15171. /** @hidden */
  15172. _currentDragGradient: Nullable<FactorGradient>;
  15173. /** @hidden */
  15174. _currentDrag1: number;
  15175. /** @hidden */
  15176. _currentDrag2: number;
  15177. /** @hidden */
  15178. _randomNoiseCoordinates1: Vector3;
  15179. /** @hidden */
  15180. _randomNoiseCoordinates2: Vector3;
  15181. /**
  15182. * Creates a new instance Particle
  15183. * @param particleSystem the particle system the particle belongs to
  15184. */
  15185. constructor(
  15186. /**
  15187. * The particle system the particle belongs to.
  15188. */
  15189. particleSystem: ParticleSystem);
  15190. private updateCellInfoFromSystem;
  15191. /**
  15192. * Defines how the sprite cell index is updated for the particle
  15193. */
  15194. updateCellIndex(): void;
  15195. /** @hidden */
  15196. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15197. /** @hidden */
  15198. _inheritParticleInfoToSubEmitters(): void;
  15199. /** @hidden */
  15200. _reset(): void;
  15201. /**
  15202. * Copy the properties of particle to another one.
  15203. * @param other the particle to copy the information to.
  15204. */
  15205. copyTo(other: Particle): void;
  15206. }
  15207. }
  15208. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15209. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15210. import { Effect } from "babylonjs/Materials/effect";
  15211. import { Particle } from "babylonjs/Particles/particle";
  15212. /**
  15213. * Particle emitter represents a volume emitting particles.
  15214. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15215. */
  15216. export interface IParticleEmitterType {
  15217. /**
  15218. * Called by the particle System when the direction is computed for the created particle.
  15219. * @param worldMatrix is the world matrix of the particle system
  15220. * @param directionToUpdate is the direction vector to update with the result
  15221. * @param particle is the particle we are computed the direction for
  15222. */
  15223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15224. /**
  15225. * Called by the particle System when the position is computed for the created particle.
  15226. * @param worldMatrix is the world matrix of the particle system
  15227. * @param positionToUpdate is the position vector to update with the result
  15228. * @param particle is the particle we are computed the position for
  15229. */
  15230. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15231. /**
  15232. * Clones the current emitter and returns a copy of it
  15233. * @returns the new emitter
  15234. */
  15235. clone(): IParticleEmitterType;
  15236. /**
  15237. * Called by the GPUParticleSystem to setup the update shader
  15238. * @param effect defines the update shader
  15239. */
  15240. applyToShader(effect: Effect): void;
  15241. /**
  15242. * Returns a string to use to update the GPU particles update shader
  15243. * @returns the effect defines string
  15244. */
  15245. getEffectDefines(): string;
  15246. /**
  15247. * Returns a string representing the class name
  15248. * @returns a string containing the class name
  15249. */
  15250. getClassName(): string;
  15251. /**
  15252. * Serializes the particle system to a JSON object.
  15253. * @returns the JSON object
  15254. */
  15255. serialize(): any;
  15256. /**
  15257. * Parse properties from a JSON object
  15258. * @param serializationObject defines the JSON object
  15259. */
  15260. parse(serializationObject: any): void;
  15261. }
  15262. }
  15263. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15265. import { Effect } from "babylonjs/Materials/effect";
  15266. import { Particle } from "babylonjs/Particles/particle";
  15267. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15268. /**
  15269. * Particle emitter emitting particles from the inside of a box.
  15270. * It emits the particles randomly between 2 given directions.
  15271. */
  15272. export class BoxParticleEmitter implements IParticleEmitterType {
  15273. /**
  15274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15275. */
  15276. direction1: Vector3;
  15277. /**
  15278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15279. */
  15280. direction2: Vector3;
  15281. /**
  15282. * 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.
  15283. */
  15284. minEmitBox: Vector3;
  15285. /**
  15286. * 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.
  15287. */
  15288. maxEmitBox: Vector3;
  15289. /**
  15290. * Creates a new instance BoxParticleEmitter
  15291. */
  15292. constructor();
  15293. /**
  15294. * Called by the particle System when the direction is computed for the created particle.
  15295. * @param worldMatrix is the world matrix of the particle system
  15296. * @param directionToUpdate is the direction vector to update with the result
  15297. * @param particle is the particle we are computed the direction for
  15298. */
  15299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15300. /**
  15301. * Called by the particle System when the position is computed for the created particle.
  15302. * @param worldMatrix is the world matrix of the particle system
  15303. * @param positionToUpdate is the position vector to update with the result
  15304. * @param particle is the particle we are computed the position for
  15305. */
  15306. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15307. /**
  15308. * Clones the current emitter and returns a copy of it
  15309. * @returns the new emitter
  15310. */
  15311. clone(): BoxParticleEmitter;
  15312. /**
  15313. * Called by the GPUParticleSystem to setup the update shader
  15314. * @param effect defines the update shader
  15315. */
  15316. applyToShader(effect: Effect): void;
  15317. /**
  15318. * Returns a string to use to update the GPU particles update shader
  15319. * @returns a string containng the defines string
  15320. */
  15321. getEffectDefines(): string;
  15322. /**
  15323. * Returns the string "BoxParticleEmitter"
  15324. * @returns a string containing the class name
  15325. */
  15326. getClassName(): string;
  15327. /**
  15328. * Serializes the particle system to a JSON object.
  15329. * @returns the JSON object
  15330. */
  15331. serialize(): any;
  15332. /**
  15333. * Parse properties from a JSON object
  15334. * @param serializationObject defines the JSON object
  15335. */
  15336. parse(serializationObject: any): void;
  15337. }
  15338. }
  15339. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15340. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15341. import { Effect } from "babylonjs/Materials/effect";
  15342. import { Particle } from "babylonjs/Particles/particle";
  15343. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15344. /**
  15345. * Particle emitter emitting particles from the inside of a cone.
  15346. * It emits the particles alongside the cone volume from the base to the particle.
  15347. * The emission direction might be randomized.
  15348. */
  15349. export class ConeParticleEmitter implements IParticleEmitterType {
  15350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15351. directionRandomizer: number;
  15352. private _radius;
  15353. private _angle;
  15354. private _height;
  15355. /**
  15356. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15357. */
  15358. radiusRange: number;
  15359. /**
  15360. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15361. */
  15362. heightRange: number;
  15363. /**
  15364. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15365. */
  15366. emitFromSpawnPointOnly: boolean;
  15367. /**
  15368. * Gets or sets the radius of the emission cone
  15369. */
  15370. radius: number;
  15371. /**
  15372. * Gets or sets the angle of the emission cone
  15373. */
  15374. angle: number;
  15375. private _buildHeight;
  15376. /**
  15377. * Creates a new instance ConeParticleEmitter
  15378. * @param radius the radius of the emission cone (1 by default)
  15379. * @param angle the cone base angle (PI by default)
  15380. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15381. */
  15382. constructor(radius?: number, angle?: number,
  15383. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15384. directionRandomizer?: number);
  15385. /**
  15386. * Called by the particle System when the direction is computed for the created particle.
  15387. * @param worldMatrix is the world matrix of the particle system
  15388. * @param directionToUpdate is the direction vector to update with the result
  15389. * @param particle is the particle we are computed the direction for
  15390. */
  15391. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15392. /**
  15393. * Called by the particle System when the position is computed for the created particle.
  15394. * @param worldMatrix is the world matrix of the particle system
  15395. * @param positionToUpdate is the position vector to update with the result
  15396. * @param particle is the particle we are computed the position for
  15397. */
  15398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15399. /**
  15400. * Clones the current emitter and returns a copy of it
  15401. * @returns the new emitter
  15402. */
  15403. clone(): ConeParticleEmitter;
  15404. /**
  15405. * Called by the GPUParticleSystem to setup the update shader
  15406. * @param effect defines the update shader
  15407. */
  15408. applyToShader(effect: Effect): void;
  15409. /**
  15410. * Returns a string to use to update the GPU particles update shader
  15411. * @returns a string containng the defines string
  15412. */
  15413. getEffectDefines(): string;
  15414. /**
  15415. * Returns the string "ConeParticleEmitter"
  15416. * @returns a string containing the class name
  15417. */
  15418. getClassName(): string;
  15419. /**
  15420. * Serializes the particle system to a JSON object.
  15421. * @returns the JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Parse properties from a JSON object
  15426. * @param serializationObject defines the JSON object
  15427. */
  15428. parse(serializationObject: any): void;
  15429. }
  15430. }
  15431. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15432. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15433. import { Effect } from "babylonjs/Materials/effect";
  15434. import { Particle } from "babylonjs/Particles/particle";
  15435. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15436. /**
  15437. * Particle emitter emitting particles from the inside of a cylinder.
  15438. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15439. */
  15440. export class CylinderParticleEmitter implements IParticleEmitterType {
  15441. /**
  15442. * The radius of the emission cylinder.
  15443. */
  15444. radius: number;
  15445. /**
  15446. * The height of the emission cylinder.
  15447. */
  15448. height: number;
  15449. /**
  15450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15451. */
  15452. radiusRange: number;
  15453. /**
  15454. * How much to randomize the particle direction [0-1].
  15455. */
  15456. directionRandomizer: number;
  15457. /**
  15458. * Creates a new instance CylinderParticleEmitter
  15459. * @param radius the radius of the emission cylinder (1 by default)
  15460. * @param height the height of the emission cylinder (1 by default)
  15461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15462. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15463. */
  15464. constructor(
  15465. /**
  15466. * The radius of the emission cylinder.
  15467. */
  15468. radius?: number,
  15469. /**
  15470. * The height of the emission cylinder.
  15471. */
  15472. height?: number,
  15473. /**
  15474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15475. */
  15476. radiusRange?: number,
  15477. /**
  15478. * How much to randomize the particle direction [0-1].
  15479. */
  15480. directionRandomizer?: number);
  15481. /**
  15482. * Called by the particle System when the direction is computed for the created particle.
  15483. * @param worldMatrix is the world matrix of the particle system
  15484. * @param directionToUpdate is the direction vector to update with the result
  15485. * @param particle is the particle we are computed the direction for
  15486. */
  15487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15488. /**
  15489. * Called by the particle System when the position is computed for the created particle.
  15490. * @param worldMatrix is the world matrix of the particle system
  15491. * @param positionToUpdate is the position vector to update with the result
  15492. * @param particle is the particle we are computed the position for
  15493. */
  15494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15495. /**
  15496. * Clones the current emitter and returns a copy of it
  15497. * @returns the new emitter
  15498. */
  15499. clone(): CylinderParticleEmitter;
  15500. /**
  15501. * Called by the GPUParticleSystem to setup the update shader
  15502. * @param effect defines the update shader
  15503. */
  15504. applyToShader(effect: Effect): void;
  15505. /**
  15506. * Returns a string to use to update the GPU particles update shader
  15507. * @returns a string containng the defines string
  15508. */
  15509. getEffectDefines(): string;
  15510. /**
  15511. * Returns the string "CylinderParticleEmitter"
  15512. * @returns a string containing the class name
  15513. */
  15514. getClassName(): string;
  15515. /**
  15516. * Serializes the particle system to a JSON object.
  15517. * @returns the JSON object
  15518. */
  15519. serialize(): any;
  15520. /**
  15521. * Parse properties from a JSON object
  15522. * @param serializationObject defines the JSON object
  15523. */
  15524. parse(serializationObject: any): void;
  15525. }
  15526. /**
  15527. * Particle emitter emitting particles from the inside of a cylinder.
  15528. * It emits the particles randomly between two vectors.
  15529. */
  15530. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15531. /**
  15532. * The min limit of the emission direction.
  15533. */
  15534. direction1: Vector3;
  15535. /**
  15536. * The max limit of the emission direction.
  15537. */
  15538. direction2: Vector3;
  15539. /**
  15540. * Creates a new instance CylinderDirectedParticleEmitter
  15541. * @param radius the radius of the emission cylinder (1 by default)
  15542. * @param height the height of the emission cylinder (1 by default)
  15543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15544. * @param direction1 the min limit of the emission direction (up vector by default)
  15545. * @param direction2 the max limit of the emission direction (up vector by default)
  15546. */
  15547. constructor(radius?: number, height?: number, radiusRange?: number,
  15548. /**
  15549. * The min limit of the emission direction.
  15550. */
  15551. direction1?: Vector3,
  15552. /**
  15553. * The max limit of the emission direction.
  15554. */
  15555. direction2?: Vector3);
  15556. /**
  15557. * Called by the particle System when the direction is computed for the created particle.
  15558. * @param worldMatrix is the world matrix of the particle system
  15559. * @param directionToUpdate is the direction vector to update with the result
  15560. * @param particle is the particle we are computed the direction for
  15561. */
  15562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15563. /**
  15564. * Clones the current emitter and returns a copy of it
  15565. * @returns the new emitter
  15566. */
  15567. clone(): CylinderDirectedParticleEmitter;
  15568. /**
  15569. * Called by the GPUParticleSystem to setup the update shader
  15570. * @param effect defines the update shader
  15571. */
  15572. applyToShader(effect: Effect): void;
  15573. /**
  15574. * Returns a string to use to update the GPU particles update shader
  15575. * @returns a string containng the defines string
  15576. */
  15577. getEffectDefines(): string;
  15578. /**
  15579. * Returns the string "CylinderDirectedParticleEmitter"
  15580. * @returns a string containing the class name
  15581. */
  15582. getClassName(): string;
  15583. /**
  15584. * Serializes the particle system to a JSON object.
  15585. * @returns the JSON object
  15586. */
  15587. serialize(): any;
  15588. /**
  15589. * Parse properties from a JSON object
  15590. * @param serializationObject defines the JSON object
  15591. */
  15592. parse(serializationObject: any): void;
  15593. }
  15594. }
  15595. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15596. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15597. import { Effect } from "babylonjs/Materials/effect";
  15598. import { Particle } from "babylonjs/Particles/particle";
  15599. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15600. /**
  15601. * Particle emitter emitting particles from the inside of a hemisphere.
  15602. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15603. */
  15604. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15605. /**
  15606. * The radius of the emission hemisphere.
  15607. */
  15608. radius: number;
  15609. /**
  15610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15611. */
  15612. radiusRange: number;
  15613. /**
  15614. * How much to randomize the particle direction [0-1].
  15615. */
  15616. directionRandomizer: number;
  15617. /**
  15618. * Creates a new instance HemisphericParticleEmitter
  15619. * @param radius the radius of the emission hemisphere (1 by default)
  15620. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15622. */
  15623. constructor(
  15624. /**
  15625. * The radius of the emission hemisphere.
  15626. */
  15627. radius?: number,
  15628. /**
  15629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15630. */
  15631. radiusRange?: number,
  15632. /**
  15633. * How much to randomize the particle direction [0-1].
  15634. */
  15635. directionRandomizer?: number);
  15636. /**
  15637. * Called by the particle System when the direction is computed for the created particle.
  15638. * @param worldMatrix is the world matrix of the particle system
  15639. * @param directionToUpdate is the direction vector to update with the result
  15640. * @param particle is the particle we are computed the direction for
  15641. */
  15642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15643. /**
  15644. * Called by the particle System when the position is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param positionToUpdate is the position vector to update with the result
  15647. * @param particle is the particle we are computed the position for
  15648. */
  15649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15650. /**
  15651. * Clones the current emitter and returns a copy of it
  15652. * @returns the new emitter
  15653. */
  15654. clone(): HemisphericParticleEmitter;
  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 "HemisphericParticleEmitter"
  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/pointParticleEmitter" {
  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 a point.
  15689. * It emits the particles randomly between 2 given directions.
  15690. */
  15691. export class PointParticleEmitter implements IParticleEmitterType {
  15692. /**
  15693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15694. */
  15695. direction1: Vector3;
  15696. /**
  15697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15698. */
  15699. direction2: Vector3;
  15700. /**
  15701. * Creates a new instance PointParticleEmitter
  15702. */
  15703. constructor();
  15704. /**
  15705. * Called by the particle System when the direction is computed for the created particle.
  15706. * @param worldMatrix is the world matrix of the particle system
  15707. * @param directionToUpdate is the direction vector to update with the result
  15708. * @param particle is the particle we are computed the direction for
  15709. */
  15710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15711. /**
  15712. * Called by the particle System when the position is computed for the created particle.
  15713. * @param worldMatrix is the world matrix of the particle system
  15714. * @param positionToUpdate is the position vector to update with the result
  15715. * @param particle is the particle we are computed the position for
  15716. */
  15717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15718. /**
  15719. * Clones the current emitter and returns a copy of it
  15720. * @returns the new emitter
  15721. */
  15722. clone(): PointParticleEmitter;
  15723. /**
  15724. * Called by the GPUParticleSystem to setup the update shader
  15725. * @param effect defines the update shader
  15726. */
  15727. applyToShader(effect: Effect): void;
  15728. /**
  15729. * Returns a string to use to update the GPU particles update shader
  15730. * @returns a string containng the defines string
  15731. */
  15732. getEffectDefines(): string;
  15733. /**
  15734. * Returns the string "PointParticleEmitter"
  15735. * @returns a string containing the class name
  15736. */
  15737. getClassName(): string;
  15738. /**
  15739. * Serializes the particle system to a JSON object.
  15740. * @returns the JSON object
  15741. */
  15742. serialize(): any;
  15743. /**
  15744. * Parse properties from a JSON object
  15745. * @param serializationObject defines the JSON object
  15746. */
  15747. parse(serializationObject: any): void;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15751. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15752. import { Effect } from "babylonjs/Materials/effect";
  15753. import { Particle } from "babylonjs/Particles/particle";
  15754. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15755. /**
  15756. * Particle emitter emitting particles from the inside of a sphere.
  15757. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15758. */
  15759. export class SphereParticleEmitter implements IParticleEmitterType {
  15760. /**
  15761. * The radius of the emission sphere.
  15762. */
  15763. radius: number;
  15764. /**
  15765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15766. */
  15767. radiusRange: number;
  15768. /**
  15769. * How much to randomize the particle direction [0-1].
  15770. */
  15771. directionRandomizer: number;
  15772. /**
  15773. * Creates a new instance SphereParticleEmitter
  15774. * @param radius the radius of the emission sphere (1 by default)
  15775. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15776. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15777. */
  15778. constructor(
  15779. /**
  15780. * The radius of the emission sphere.
  15781. */
  15782. radius?: number,
  15783. /**
  15784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15785. */
  15786. radiusRange?: number,
  15787. /**
  15788. * How much to randomize the particle direction [0-1].
  15789. */
  15790. directionRandomizer?: number);
  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(): SphereParticleEmitter;
  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 "SphereParticleEmitter"
  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. * Particle emitter emitting particles from the inside of a sphere.
  15838. * It emits the particles randomly between two vectors.
  15839. */
  15840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15841. /**
  15842. * The min limit of the emission direction.
  15843. */
  15844. direction1: Vector3;
  15845. /**
  15846. * The max limit of the emission direction.
  15847. */
  15848. direction2: Vector3;
  15849. /**
  15850. * Creates a new instance SphereDirectedParticleEmitter
  15851. * @param radius the radius of the emission sphere (1 by default)
  15852. * @param direction1 the min limit of the emission direction (up vector by default)
  15853. * @param direction2 the max limit of the emission direction (up vector by default)
  15854. */
  15855. constructor(radius?: number,
  15856. /**
  15857. * The min limit of the emission direction.
  15858. */
  15859. direction1?: Vector3,
  15860. /**
  15861. * The max limit of the emission direction.
  15862. */
  15863. direction2?: Vector3);
  15864. /**
  15865. * Called by the particle System when the direction is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param directionToUpdate is the direction vector to update with the result
  15868. * @param particle is the particle we are computed the direction for
  15869. */
  15870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereDirectedParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereDirectedParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. }
  15903. declare module "babylonjs/Particles/EmitterTypes/index" {
  15904. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15905. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15906. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15907. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15908. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15909. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15910. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15911. }
  15912. declare module "babylonjs/Particles/IParticleSystem" {
  15913. import { Nullable } from "babylonjs/types";
  15914. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15917. import { Texture } from "babylonjs/Materials/Textures/texture";
  15918. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15919. import { Scene } from "babylonjs/scene";
  15920. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15921. import { Animation } from "babylonjs/Animations/animation";
  15922. /**
  15923. * Interface representing a particle system in Babylon.js.
  15924. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15925. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15926. */
  15927. export interface IParticleSystem {
  15928. /**
  15929. * List of animations used by the particle system.
  15930. */
  15931. animations: Animation[];
  15932. /**
  15933. * The id of the Particle system.
  15934. */
  15935. id: string;
  15936. /**
  15937. * The name of the Particle system.
  15938. */
  15939. name: string;
  15940. /**
  15941. * The emitter represents the Mesh or position we are attaching the particle system to.
  15942. */
  15943. emitter: Nullable<AbstractMesh | Vector3>;
  15944. /**
  15945. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15946. */
  15947. isBillboardBased: boolean;
  15948. /**
  15949. * The rendering group used by the Particle system to chose when to render.
  15950. */
  15951. renderingGroupId: number;
  15952. /**
  15953. * The layer mask we are rendering the particles through.
  15954. */
  15955. layerMask: number;
  15956. /**
  15957. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15958. */
  15959. updateSpeed: number;
  15960. /**
  15961. * The amount of time the particle system is running (depends of the overall update speed).
  15962. */
  15963. targetStopDuration: number;
  15964. /**
  15965. * The texture used to render each particle. (this can be a spritesheet)
  15966. */
  15967. particleTexture: Nullable<Texture>;
  15968. /**
  15969. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15970. */
  15971. blendMode: number;
  15972. /**
  15973. * Minimum life time of emitting particles.
  15974. */
  15975. minLifeTime: number;
  15976. /**
  15977. * Maximum life time of emitting particles.
  15978. */
  15979. maxLifeTime: number;
  15980. /**
  15981. * Minimum Size of emitting particles.
  15982. */
  15983. minSize: number;
  15984. /**
  15985. * Maximum Size of emitting particles.
  15986. */
  15987. maxSize: number;
  15988. /**
  15989. * Minimum scale of emitting particles on X axis.
  15990. */
  15991. minScaleX: number;
  15992. /**
  15993. * Maximum scale of emitting particles on X axis.
  15994. */
  15995. maxScaleX: number;
  15996. /**
  15997. * Minimum scale of emitting particles on Y axis.
  15998. */
  15999. minScaleY: number;
  16000. /**
  16001. * Maximum scale of emitting particles on Y axis.
  16002. */
  16003. maxScaleY: number;
  16004. /**
  16005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16006. */
  16007. color1: Color4;
  16008. /**
  16009. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16010. */
  16011. color2: Color4;
  16012. /**
  16013. * Color the particle will have at the end of its lifetime.
  16014. */
  16015. colorDead: Color4;
  16016. /**
  16017. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16018. */
  16019. emitRate: number;
  16020. /**
  16021. * You can use gravity if you want to give an orientation to your particles.
  16022. */
  16023. gravity: Vector3;
  16024. /**
  16025. * Minimum power of emitting particles.
  16026. */
  16027. minEmitPower: number;
  16028. /**
  16029. * Maximum power of emitting particles.
  16030. */
  16031. maxEmitPower: number;
  16032. /**
  16033. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16034. */
  16035. minAngularSpeed: number;
  16036. /**
  16037. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16038. */
  16039. maxAngularSpeed: number;
  16040. /**
  16041. * Gets or sets the minimal initial rotation in radians.
  16042. */
  16043. minInitialRotation: number;
  16044. /**
  16045. * Gets or sets the maximal initial rotation in radians.
  16046. */
  16047. maxInitialRotation: number;
  16048. /**
  16049. * The particle emitter type defines the emitter used by the particle system.
  16050. * It can be for example box, sphere, or cone...
  16051. */
  16052. particleEmitterType: Nullable<IParticleEmitterType>;
  16053. /**
  16054. * Defines the delay in milliseconds before starting the system (0 by default)
  16055. */
  16056. startDelay: number;
  16057. /**
  16058. * 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
  16059. */
  16060. preWarmCycles: number;
  16061. /**
  16062. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16063. */
  16064. preWarmStepOffset: number;
  16065. /**
  16066. * 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)
  16067. */
  16068. spriteCellChangeSpeed: number;
  16069. /**
  16070. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16071. */
  16072. startSpriteCellID: number;
  16073. /**
  16074. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16075. */
  16076. endSpriteCellID: number;
  16077. /**
  16078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16079. */
  16080. spriteCellWidth: number;
  16081. /**
  16082. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16083. */
  16084. spriteCellHeight: number;
  16085. /**
  16086. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16087. */
  16088. spriteRandomStartCell: boolean;
  16089. /**
  16090. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16091. */
  16092. isAnimationSheetEnabled: boolean;
  16093. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16094. translationPivot: Vector2;
  16095. /**
  16096. * Gets or sets a texture used to add random noise to particle positions
  16097. */
  16098. noiseTexture: Nullable<BaseTexture>;
  16099. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16100. noiseStrength: Vector3;
  16101. /**
  16102. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16103. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16104. */
  16105. billboardMode: number;
  16106. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16107. limitVelocityDamping: number;
  16108. /**
  16109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16110. */
  16111. beginAnimationOnStart: boolean;
  16112. /**
  16113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16114. */
  16115. beginAnimationFrom: number;
  16116. /**
  16117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16118. */
  16119. beginAnimationTo: number;
  16120. /**
  16121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16122. */
  16123. beginAnimationLoop: boolean;
  16124. /**
  16125. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16126. */
  16127. disposeOnStop: boolean;
  16128. /**
  16129. * Gets the maximum number of particles active at the same time.
  16130. * @returns The max number of active particles.
  16131. */
  16132. getCapacity(): number;
  16133. /**
  16134. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16135. * @returns True if it has been started, otherwise false.
  16136. */
  16137. isStarted(): boolean;
  16138. /**
  16139. * Animates the particle system for this frame.
  16140. */
  16141. animate(): void;
  16142. /**
  16143. * Renders the particle system in its current state.
  16144. * @returns the current number of particles
  16145. */
  16146. render(): number;
  16147. /**
  16148. * Dispose the particle system and frees its associated resources.
  16149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16150. */
  16151. dispose(disposeTexture?: boolean): void;
  16152. /**
  16153. * Clones the particle system.
  16154. * @param name The name of the cloned object
  16155. * @param newEmitter The new emitter to use
  16156. * @returns the cloned particle system
  16157. */
  16158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16159. /**
  16160. * Serializes the particle system to a JSON object.
  16161. * @returns the JSON object
  16162. */
  16163. serialize(): any;
  16164. /**
  16165. * Rebuild the particle system
  16166. */
  16167. rebuild(): void;
  16168. /**
  16169. * Starts the particle system and begins to emit
  16170. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16171. */
  16172. start(delay?: number): void;
  16173. /**
  16174. * Stops the particle system.
  16175. */
  16176. stop(): void;
  16177. /**
  16178. * Remove all active particles
  16179. */
  16180. reset(): void;
  16181. /**
  16182. * Is this system ready to be used/rendered
  16183. * @return true if the system is ready
  16184. */
  16185. isReady(): boolean;
  16186. /**
  16187. * Adds a new color gradient
  16188. * @param gradient defines the gradient to use (between 0 and 1)
  16189. * @param color1 defines the color to affect to the specified gradient
  16190. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16191. * @returns the current particle system
  16192. */
  16193. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16194. /**
  16195. * Remove a specific color gradient
  16196. * @param gradient defines the gradient to remove
  16197. * @returns the current particle system
  16198. */
  16199. removeColorGradient(gradient: number): IParticleSystem;
  16200. /**
  16201. * Adds a new size gradient
  16202. * @param gradient defines the gradient to use (between 0 and 1)
  16203. * @param factor defines the size factor to affect to the specified gradient
  16204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16205. * @returns the current particle system
  16206. */
  16207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16208. /**
  16209. * Remove a specific size gradient
  16210. * @param gradient defines the gradient to remove
  16211. * @returns the current particle system
  16212. */
  16213. removeSizeGradient(gradient: number): IParticleSystem;
  16214. /**
  16215. * Gets the current list of color gradients.
  16216. * You must use addColorGradient and removeColorGradient to udpate this list
  16217. * @returns the list of color gradients
  16218. */
  16219. getColorGradients(): Nullable<Array<ColorGradient>>;
  16220. /**
  16221. * Gets the current list of size gradients.
  16222. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16223. * @returns the list of size gradients
  16224. */
  16225. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16226. /**
  16227. * Gets the current list of angular speed gradients.
  16228. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16229. * @returns the list of angular speed gradients
  16230. */
  16231. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16232. /**
  16233. * Adds a new angular speed gradient
  16234. * @param gradient defines the gradient to use (between 0 and 1)
  16235. * @param factor defines the angular speed to affect to the specified gradient
  16236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16237. * @returns the current particle system
  16238. */
  16239. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16240. /**
  16241. * Remove a specific angular speed gradient
  16242. * @param gradient defines the gradient to remove
  16243. * @returns the current particle system
  16244. */
  16245. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16246. /**
  16247. * Gets the current list of velocity gradients.
  16248. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16249. * @returns the list of velocity gradients
  16250. */
  16251. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16252. /**
  16253. * Adds a new velocity gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param factor defines the velocity to affect to the specified gradient
  16256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16257. * @returns the current particle system
  16258. */
  16259. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16260. /**
  16261. * Remove a specific velocity gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeVelocityGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Gets the current list of limit velocity gradients.
  16268. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16269. * @returns the list of limit velocity gradients
  16270. */
  16271. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16272. /**
  16273. * Adds a new limit velocity gradient
  16274. * @param gradient defines the gradient to use (between 0 and 1)
  16275. * @param factor defines the limit velocity to affect to the specified gradient
  16276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16277. * @returns the current particle system
  16278. */
  16279. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16280. /**
  16281. * Remove a specific limit velocity gradient
  16282. * @param gradient defines the gradient to remove
  16283. * @returns the current particle system
  16284. */
  16285. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16286. /**
  16287. * Adds a new drag gradient
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the drag to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific drag gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeDragGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Gets the current list of drag gradients.
  16302. * You must use addDragGradient and removeDragGradient to udpate this list
  16303. * @returns the list of drag gradients
  16304. */
  16305. getDragGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16308. * @param gradient defines the gradient to use (between 0 and 1)
  16309. * @param factor defines the emit rate to affect to the specified gradient
  16310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16311. * @returns the current particle system
  16312. */
  16313. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16314. /**
  16315. * Remove a specific emit rate gradient
  16316. * @param gradient defines the gradient to remove
  16317. * @returns the current particle system
  16318. */
  16319. removeEmitRateGradient(gradient: number): IParticleSystem;
  16320. /**
  16321. * Gets the current list of emit rate gradients.
  16322. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16323. * @returns the list of emit rate gradients
  16324. */
  16325. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16326. /**
  16327. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16328. * @param gradient defines the gradient to use (between 0 and 1)
  16329. * @param factor defines the start size to affect to the specified gradient
  16330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16331. * @returns the current particle system
  16332. */
  16333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16334. /**
  16335. * Remove a specific start size gradient
  16336. * @param gradient defines the gradient to remove
  16337. * @returns the current particle system
  16338. */
  16339. removeStartSizeGradient(gradient: number): IParticleSystem;
  16340. /**
  16341. * Gets the current list of start size gradients.
  16342. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16343. * @returns the list of start size gradients
  16344. */
  16345. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16346. /**
  16347. * Adds a new life time gradient
  16348. * @param gradient defines the gradient to use (between 0 and 1)
  16349. * @param factor defines the life time factor to affect to the specified gradient
  16350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16351. * @returns the current particle system
  16352. */
  16353. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16354. /**
  16355. * Remove a specific life time gradient
  16356. * @param gradient defines the gradient to remove
  16357. * @returns the current particle system
  16358. */
  16359. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16360. /**
  16361. * Gets the current list of life time gradients.
  16362. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16363. * @returns the list of life time gradients
  16364. */
  16365. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16366. /**
  16367. * Gets the current list of color gradients.
  16368. * You must use addColorGradient and removeColorGradient to udpate this list
  16369. * @returns the list of color gradients
  16370. */
  16371. getColorGradients(): Nullable<Array<ColorGradient>>;
  16372. /**
  16373. * Adds a new ramp gradient used to remap particle colors
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param color defines the color to affect to the specified gradient
  16376. * @returns the current particle system
  16377. */
  16378. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16379. /**
  16380. * Gets the current list of ramp gradients.
  16381. * You must use addRampGradient and removeRampGradient to udpate this list
  16382. * @returns the list of ramp gradients
  16383. */
  16384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16385. /** Gets or sets a boolean indicating that ramp gradients must be used
  16386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16387. */
  16388. useRampGradients: boolean;
  16389. /**
  16390. * Adds a new color remap gradient
  16391. * @param gradient defines the gradient to use (between 0 and 1)
  16392. * @param min defines the color remap minimal range
  16393. * @param max defines the color remap maximal range
  16394. * @returns the current particle system
  16395. */
  16396. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16397. /**
  16398. * Gets the current list of color remap gradients.
  16399. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16400. * @returns the list of color remap gradients
  16401. */
  16402. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16403. /**
  16404. * Adds a new alpha remap gradient
  16405. * @param gradient defines the gradient to use (between 0 and 1)
  16406. * @param min defines the alpha remap minimal range
  16407. * @param max defines the alpha remap maximal range
  16408. * @returns the current particle system
  16409. */
  16410. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16411. /**
  16412. * Gets the current list of alpha remap gradients.
  16413. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16414. * @returns the list of alpha remap gradients
  16415. */
  16416. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16417. /**
  16418. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16421. * @returns the emitter
  16422. */
  16423. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16424. /**
  16425. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16426. * @param radius The radius of the hemisphere to emit from
  16427. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16428. * @returns the emitter
  16429. */
  16430. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16431. /**
  16432. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16433. * @param radius The radius of the sphere to emit from
  16434. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16435. * @returns the emitter
  16436. */
  16437. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16438. /**
  16439. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16440. * @param radius The radius of the sphere to emit from
  16441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16443. * @returns the emitter
  16444. */
  16445. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16446. /**
  16447. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16448. * @param radius The radius of the emission cylinder
  16449. * @param height The height of the emission cylinder
  16450. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16451. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16452. * @returns the emitter
  16453. */
  16454. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16455. /**
  16456. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16457. * @param radius The radius of the cylinder to emit from
  16458. * @param height The height of the emission cylinder
  16459. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16462. * @returns the emitter
  16463. */
  16464. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16465. /**
  16466. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16467. * @param radius The radius of the cone to emit from
  16468. * @param angle The base angle of the cone
  16469. * @returns the emitter
  16470. */
  16471. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16472. /**
  16473. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16476. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16477. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16478. * @returns the emitter
  16479. */
  16480. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16481. /**
  16482. * Get hosting scene
  16483. * @returns the scene
  16484. */
  16485. getScene(): Scene;
  16486. }
  16487. }
  16488. declare module "babylonjs/Meshes/instancedMesh" {
  16489. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16490. import { Vector3 } from "babylonjs/Maths/math";
  16491. import { Camera } from "babylonjs/Cameras/camera";
  16492. import { Node } from "babylonjs/node";
  16493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16494. import { Mesh } from "babylonjs/Meshes/mesh";
  16495. import { Material } from "babylonjs/Materials/material";
  16496. import { Skeleton } from "babylonjs/Bones/skeleton";
  16497. /**
  16498. * Creates an instance based on a source mesh.
  16499. */
  16500. export class InstancedMesh extends AbstractMesh {
  16501. private _sourceMesh;
  16502. private _currentLOD;
  16503. /** @hidden */
  16504. _indexInSourceMeshInstanceArray: number;
  16505. constructor(name: string, source: Mesh);
  16506. /**
  16507. * Returns the string "InstancedMesh".
  16508. */
  16509. getClassName(): string;
  16510. /**
  16511. * If the source mesh receives shadows
  16512. */
  16513. readonly receiveShadows: boolean;
  16514. /**
  16515. * The material of the source mesh
  16516. */
  16517. readonly material: Nullable<Material>;
  16518. /**
  16519. * Visibility of the source mesh
  16520. */
  16521. readonly visibility: number;
  16522. /**
  16523. * Skeleton of the source mesh
  16524. */
  16525. readonly skeleton: Nullable<Skeleton>;
  16526. /**
  16527. * Rendering ground id of the source mesh
  16528. */
  16529. renderingGroupId: number;
  16530. /**
  16531. * Returns the total number of vertices (integer).
  16532. */
  16533. getTotalVertices(): number;
  16534. /**
  16535. * Returns a positive integer : the total number of indices in this mesh geometry.
  16536. * @returns the numner of indices or zero if the mesh has no geometry.
  16537. */
  16538. getTotalIndices(): number;
  16539. /**
  16540. * The source mesh of the instance
  16541. */
  16542. readonly sourceMesh: Mesh;
  16543. /**
  16544. * Is this node ready to be used/rendered
  16545. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16546. * @return {boolean} is it ready
  16547. */
  16548. isReady(completeCheck?: boolean): boolean;
  16549. /**
  16550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16551. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16552. * @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.
  16553. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16554. */
  16555. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16556. /**
  16557. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16558. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16559. * The `data` are either a numeric array either a Float32Array.
  16560. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16561. * 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).
  16562. * Note that a new underlying VertexBuffer object is created each call.
  16563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16564. *
  16565. * Possible `kind` values :
  16566. * - VertexBuffer.PositionKind
  16567. * - VertexBuffer.UVKind
  16568. * - VertexBuffer.UV2Kind
  16569. * - VertexBuffer.UV3Kind
  16570. * - VertexBuffer.UV4Kind
  16571. * - VertexBuffer.UV5Kind
  16572. * - VertexBuffer.UV6Kind
  16573. * - VertexBuffer.ColorKind
  16574. * - VertexBuffer.MatricesIndicesKind
  16575. * - VertexBuffer.MatricesIndicesExtraKind
  16576. * - VertexBuffer.MatricesWeightsKind
  16577. * - VertexBuffer.MatricesWeightsExtraKind
  16578. *
  16579. * Returns the Mesh.
  16580. */
  16581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16582. /**
  16583. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16584. * If the mesh has no geometry, it is simply returned as it is.
  16585. * The `data` are either a numeric array either a Float32Array.
  16586. * No new underlying VertexBuffer object is created.
  16587. * 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.
  16588. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16589. *
  16590. * Possible `kind` values :
  16591. * - VertexBuffer.PositionKind
  16592. * - VertexBuffer.UVKind
  16593. * - VertexBuffer.UV2Kind
  16594. * - VertexBuffer.UV3Kind
  16595. * - VertexBuffer.UV4Kind
  16596. * - VertexBuffer.UV5Kind
  16597. * - VertexBuffer.UV6Kind
  16598. * - VertexBuffer.ColorKind
  16599. * - VertexBuffer.MatricesIndicesKind
  16600. * - VertexBuffer.MatricesIndicesExtraKind
  16601. * - VertexBuffer.MatricesWeightsKind
  16602. * - VertexBuffer.MatricesWeightsExtraKind
  16603. *
  16604. * Returns the Mesh.
  16605. */
  16606. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16607. /**
  16608. * Sets the mesh indices.
  16609. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16610. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16611. * This method creates a new index buffer each call.
  16612. * Returns the Mesh.
  16613. */
  16614. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16615. /**
  16616. * Boolean : True if the mesh owns the requested kind of data.
  16617. */
  16618. isVerticesDataPresent(kind: string): boolean;
  16619. /**
  16620. * Returns an array of indices (IndicesArray).
  16621. */
  16622. getIndices(): Nullable<IndicesArray>;
  16623. readonly _positions: Nullable<Vector3[]>;
  16624. /**
  16625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16626. * This means the mesh underlying bounding box and sphere are recomputed.
  16627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16628. * @returns the current mesh
  16629. */
  16630. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16631. /** @hidden */
  16632. _preActivate(): InstancedMesh;
  16633. /** @hidden */
  16634. _activate(renderId: number): InstancedMesh;
  16635. /**
  16636. * Returns the current associated LOD AbstractMesh.
  16637. */
  16638. getLOD(camera: Camera): AbstractMesh;
  16639. /** @hidden */
  16640. _syncSubMeshes(): InstancedMesh;
  16641. /** @hidden */
  16642. _generatePointsArray(): boolean;
  16643. /**
  16644. * Creates a new InstancedMesh from the current mesh.
  16645. * - name (string) : the cloned mesh name
  16646. * - newParent (optional Node) : the optional Node to parent the clone to.
  16647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16648. *
  16649. * Returns the clone.
  16650. */
  16651. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16652. /**
  16653. * Disposes the InstancedMesh.
  16654. * Returns nothing.
  16655. */
  16656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16657. }
  16658. }
  16659. declare module "babylonjs/Materials/shaderMaterial" {
  16660. import { Scene } from "babylonjs/scene";
  16661. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16663. import { Mesh } from "babylonjs/Meshes/mesh";
  16664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16665. import { Texture } from "babylonjs/Materials/Textures/texture";
  16666. import { Material } from "babylonjs/Materials/material";
  16667. /**
  16668. * Defines the options associated with the creation of a shader material.
  16669. */
  16670. export interface IShaderMaterialOptions {
  16671. /**
  16672. * Does the material work in alpha blend mode
  16673. */
  16674. needAlphaBlending: boolean;
  16675. /**
  16676. * Does the material work in alpha test mode
  16677. */
  16678. needAlphaTesting: boolean;
  16679. /**
  16680. * The list of attribute names used in the shader
  16681. */
  16682. attributes: string[];
  16683. /**
  16684. * The list of unifrom names used in the shader
  16685. */
  16686. uniforms: string[];
  16687. /**
  16688. * The list of UBO names used in the shader
  16689. */
  16690. uniformBuffers: string[];
  16691. /**
  16692. * The list of sampler names used in the shader
  16693. */
  16694. samplers: string[];
  16695. /**
  16696. * The list of defines used in the shader
  16697. */
  16698. defines: string[];
  16699. }
  16700. /**
  16701. * 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.
  16702. *
  16703. * This returned material effects how the mesh will look based on the code in the shaders.
  16704. *
  16705. * @see http://doc.babylonjs.com/how_to/shader_material
  16706. */
  16707. export class ShaderMaterial extends Material {
  16708. private _shaderPath;
  16709. private _options;
  16710. private _textures;
  16711. private _textureArrays;
  16712. private _floats;
  16713. private _ints;
  16714. private _floatsArrays;
  16715. private _colors3;
  16716. private _colors3Arrays;
  16717. private _colors4;
  16718. private _vectors2;
  16719. private _vectors3;
  16720. private _vectors4;
  16721. private _matrices;
  16722. private _matrices3x3;
  16723. private _matrices2x2;
  16724. private _vectors2Arrays;
  16725. private _vectors3Arrays;
  16726. private _cachedWorldViewMatrix;
  16727. private _renderId;
  16728. /**
  16729. * Instantiate a new shader material.
  16730. * 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.
  16731. * This returned material effects how the mesh will look based on the code in the shaders.
  16732. * @see http://doc.babylonjs.com/how_to/shader_material
  16733. * @param name Define the name of the material in the scene
  16734. * @param scene Define the scene the material belongs to
  16735. * @param shaderPath Defines the route to the shader code in one of three ways:
  16736. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16737. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16738. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16739. * @param options Define the options used to create the shader
  16740. */
  16741. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16742. /**
  16743. * Gets the current class name of the material e.g. "ShaderMaterial"
  16744. * Mainly use in serialization.
  16745. * @returns the class name
  16746. */
  16747. getClassName(): string;
  16748. /**
  16749. * Specifies if the material will require alpha blending
  16750. * @returns a boolean specifying if alpha blending is needed
  16751. */
  16752. needAlphaBlending(): boolean;
  16753. /**
  16754. * Specifies if this material should be rendered in alpha test mode
  16755. * @returns a boolean specifying if an alpha test is needed.
  16756. */
  16757. needAlphaTesting(): boolean;
  16758. private _checkUniform;
  16759. /**
  16760. * Set a texture in the shader.
  16761. * @param name Define the name of the uniform samplers as defined in the shader
  16762. * @param texture Define the texture to bind to this sampler
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setTexture(name: string, texture: Texture): ShaderMaterial;
  16766. /**
  16767. * Set a texture array in the shader.
  16768. * @param name Define the name of the uniform sampler array as defined in the shader
  16769. * @param textures Define the list of textures to bind to this sampler
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16773. /**
  16774. * Set a float in the shader.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setFloat(name: string, value: number): ShaderMaterial;
  16780. /**
  16781. * Set a int in the shader.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setInt(name: string, value: number): ShaderMaterial;
  16787. /**
  16788. * Set an array of floats in the shader.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setFloats(name: string, value: number[]): ShaderMaterial;
  16794. /**
  16795. * Set a vec3 in the shader from a Color3.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setColor3(name: string, value: Color3): ShaderMaterial;
  16801. /**
  16802. * Set a vec3 array in the shader from a Color3 array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16808. /**
  16809. * Set a vec4 in the shader from a Color4.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setColor4(name: string, value: Color4): ShaderMaterial;
  16815. /**
  16816. * Set a vec2 in the shader from a Vector2.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setVector2(name: string, value: Vector2): ShaderMaterial;
  16822. /**
  16823. * Set a vec3 in the shader from a Vector3.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setVector3(name: string, value: Vector3): ShaderMaterial;
  16829. /**
  16830. * Set a vec4 in the shader from a Vector4.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setVector4(name: string, value: Vector4): ShaderMaterial;
  16836. /**
  16837. * Set a mat4 in the shader from a Matrix.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16843. /**
  16844. * Set a mat3 in the shader from a Float32Array.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the material itself allowing "fluent" like uniform updates
  16848. */
  16849. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16850. /**
  16851. * Set a mat2 in the shader from a Float32Array.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the material itself allowing "fluent" like uniform updates
  16855. */
  16856. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16857. /**
  16858. * Set a vec2 array in the shader from a number array.
  16859. * @param name Define the name of the uniform as defined in the shader
  16860. * @param value Define the value to give to the uniform
  16861. * @return the material itself allowing "fluent" like uniform updates
  16862. */
  16863. setArray2(name: string, value: number[]): ShaderMaterial;
  16864. /**
  16865. * Set a vec3 array in the shader from a number array.
  16866. * @param name Define the name of the uniform as defined in the shader
  16867. * @param value Define the value to give to the uniform
  16868. * @return the material itself allowing "fluent" like uniform updates
  16869. */
  16870. setArray3(name: string, value: number[]): ShaderMaterial;
  16871. private _checkCache;
  16872. /**
  16873. * Checks if the material is ready to render the requested mesh
  16874. * @param mesh Define the mesh to render
  16875. * @param useInstances Define whether or not the material is used with instances
  16876. * @returns true if ready, otherwise false
  16877. */
  16878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16879. /**
  16880. * Binds the world matrix to the material
  16881. * @param world defines the world transformation matrix
  16882. */
  16883. bindOnlyWorldMatrix(world: Matrix): void;
  16884. /**
  16885. * Binds the material to the mesh
  16886. * @param world defines the world transformation matrix
  16887. * @param mesh defines the mesh to bind the material to
  16888. */
  16889. bind(world: Matrix, mesh?: Mesh): void;
  16890. /**
  16891. * Gets the active textures from the material
  16892. * @returns an array of textures
  16893. */
  16894. getActiveTextures(): BaseTexture[];
  16895. /**
  16896. * Specifies if the material uses a texture
  16897. * @param texture defines the texture to check against the material
  16898. * @returns a boolean specifying if the material uses the texture
  16899. */
  16900. hasTexture(texture: BaseTexture): boolean;
  16901. /**
  16902. * Makes a duplicate of the material, and gives it a new name
  16903. * @param name defines the new name for the duplicated material
  16904. * @returns the cloned material
  16905. */
  16906. clone(name: string): ShaderMaterial;
  16907. /**
  16908. * Disposes the material
  16909. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16910. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16911. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16912. */
  16913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16914. /**
  16915. * Serializes this material in a JSON representation
  16916. * @returns the serialized material object
  16917. */
  16918. serialize(): any;
  16919. /**
  16920. * Creates a shader material from parsed shader material data
  16921. * @param source defines the JSON represnetation of the material
  16922. * @param scene defines the hosting scene
  16923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16924. * @returns a new material
  16925. */
  16926. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16927. }
  16928. }
  16929. declare module "babylonjs/Shaders/color.fragment" {
  16930. /** @hidden */
  16931. export var colorPixelShader: {
  16932. name: string;
  16933. shader: string;
  16934. };
  16935. }
  16936. declare module "babylonjs/Shaders/color.vertex" {
  16937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16941. /** @hidden */
  16942. export var colorVertexShader: {
  16943. name: string;
  16944. shader: string;
  16945. };
  16946. }
  16947. declare module "babylonjs/Meshes/linesMesh" {
  16948. import { Nullable } from "babylonjs/types";
  16949. import { Scene } from "babylonjs/scene";
  16950. import { Color3 } from "babylonjs/Maths/math";
  16951. import { Node } from "babylonjs/node";
  16952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16953. import { Mesh } from "babylonjs/Meshes/mesh";
  16954. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16955. import { Effect } from "babylonjs/Materials/effect";
  16956. import { Material } from "babylonjs/Materials/material";
  16957. import "babylonjs/Shaders/color.fragment";
  16958. import "babylonjs/Shaders/color.vertex";
  16959. /**
  16960. * Line mesh
  16961. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16962. */
  16963. export class LinesMesh extends Mesh {
  16964. /**
  16965. * If vertex color should be applied to the mesh
  16966. */
  16967. useVertexColor?: boolean | undefined;
  16968. /**
  16969. * If vertex alpha should be applied to the mesh
  16970. */
  16971. useVertexAlpha?: boolean | undefined;
  16972. /**
  16973. * Color of the line (Default: White)
  16974. */
  16975. color: Color3;
  16976. /**
  16977. * Alpha of the line (Default: 1)
  16978. */
  16979. alpha: number;
  16980. /**
  16981. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16982. * This margin is expressed in world space coordinates, so its value may vary.
  16983. * Default value is 0.1
  16984. */
  16985. intersectionThreshold: number;
  16986. private _colorShader;
  16987. /**
  16988. * Creates a new LinesMesh
  16989. * @param name defines the name
  16990. * @param scene defines the hosting scene
  16991. * @param parent defines the parent mesh if any
  16992. * @param source defines the optional source LinesMesh used to clone data from
  16993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16994. * When false, achieved by calling a clone(), also passing False.
  16995. * This will make creation of children, recursive.
  16996. * @param useVertexColor defines if this LinesMesh supports vertex color
  16997. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16998. */
  16999. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17000. /**
  17001. * If vertex color should be applied to the mesh
  17002. */
  17003. useVertexColor?: boolean | undefined,
  17004. /**
  17005. * If vertex alpha should be applied to the mesh
  17006. */
  17007. useVertexAlpha?: boolean | undefined);
  17008. /**
  17009. * Returns the string "LineMesh"
  17010. */
  17011. getClassName(): string;
  17012. /**
  17013. * @hidden
  17014. */
  17015. /**
  17016. * @hidden
  17017. */
  17018. material: Material;
  17019. /**
  17020. * @hidden
  17021. */
  17022. readonly checkCollisions: boolean;
  17023. /** @hidden */
  17024. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17025. /** @hidden */
  17026. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17027. /**
  17028. * Disposes of the line mesh
  17029. * @param doNotRecurse If children should be disposed
  17030. */
  17031. dispose(doNotRecurse?: boolean): void;
  17032. /**
  17033. * Returns a new LineMesh object cloned from the current one.
  17034. */
  17035. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17036. /**
  17037. * Creates a new InstancedLinesMesh object from the mesh model.
  17038. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17039. * @param name defines the name of the new instance
  17040. * @returns a new InstancedLinesMesh
  17041. */
  17042. createInstance(name: string): InstancedLinesMesh;
  17043. }
  17044. /**
  17045. * Creates an instance based on a source LinesMesh
  17046. */
  17047. export class InstancedLinesMesh extends InstancedMesh {
  17048. /**
  17049. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17050. * This margin is expressed in world space coordinates, so its value may vary.
  17051. * Initilized with the intersectionThreshold value of the source LinesMesh
  17052. */
  17053. intersectionThreshold: number;
  17054. constructor(name: string, source: LinesMesh);
  17055. /**
  17056. * Returns the string "InstancedLinesMesh".
  17057. */
  17058. getClassName(): string;
  17059. }
  17060. }
  17061. declare module "babylonjs/Shaders/line.fragment" {
  17062. /** @hidden */
  17063. export var linePixelShader: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module "babylonjs/Shaders/line.vertex" {
  17069. /** @hidden */
  17070. export var lineVertexShader: {
  17071. name: string;
  17072. shader: string;
  17073. };
  17074. }
  17075. declare module "babylonjs/Rendering/edgesRenderer" {
  17076. import { Nullable } from "babylonjs/types";
  17077. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17079. import { Vector3 } from "babylonjs/Maths/math";
  17080. import { IDisposable } from "babylonjs/scene";
  17081. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17082. import "babylonjs/Shaders/line.fragment";
  17083. import "babylonjs/Shaders/line.vertex";
  17084. module "babylonjs/Meshes/abstractMesh" {
  17085. interface AbstractMesh {
  17086. /**
  17087. * Disables the mesh edge rendering mode
  17088. * @returns the currentAbstractMesh
  17089. */
  17090. disableEdgesRendering(): AbstractMesh;
  17091. /**
  17092. * Enables the edge rendering mode on the mesh.
  17093. * This mode makes the mesh edges visible
  17094. * @param epsilon defines the maximal distance between two angles to detect a face
  17095. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17096. * @returns the currentAbstractMesh
  17097. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17098. */
  17099. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17100. /**
  17101. * Gets the edgesRenderer associated with the mesh
  17102. */
  17103. edgesRenderer: Nullable<EdgesRenderer>;
  17104. }
  17105. }
  17106. module "babylonjs/Meshes/linesMesh" {
  17107. interface LinesMesh {
  17108. /**
  17109. * Enables the edge rendering mode on the mesh.
  17110. * This mode makes the mesh edges visible
  17111. * @param epsilon defines the maximal distance between two angles to detect a face
  17112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17113. * @returns the currentAbstractMesh
  17114. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17115. */
  17116. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17117. }
  17118. }
  17119. module "babylonjs/Meshes/linesMesh" {
  17120. interface InstancedLinesMesh {
  17121. /**
  17122. * Enables the edge rendering mode on the mesh.
  17123. * This mode makes the mesh edges visible
  17124. * @param epsilon defines the maximal distance between two angles to detect a face
  17125. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17126. * @returns the current InstancedLinesMesh
  17127. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17128. */
  17129. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17130. }
  17131. }
  17132. /**
  17133. * Defines the minimum contract an Edges renderer should follow.
  17134. */
  17135. export interface IEdgesRenderer extends IDisposable {
  17136. /**
  17137. * Gets or sets a boolean indicating if the edgesRenderer is active
  17138. */
  17139. isEnabled: boolean;
  17140. /**
  17141. * Renders the edges of the attached mesh,
  17142. */
  17143. render(): void;
  17144. /**
  17145. * Checks wether or not the edges renderer is ready to render.
  17146. * @return true if ready, otherwise false.
  17147. */
  17148. isReady(): boolean;
  17149. }
  17150. /**
  17151. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17152. */
  17153. export class EdgesRenderer implements IEdgesRenderer {
  17154. /**
  17155. * Define the size of the edges with an orthographic camera
  17156. */
  17157. edgesWidthScalerForOrthographic: number;
  17158. /**
  17159. * Define the size of the edges with a perspective camera
  17160. */
  17161. edgesWidthScalerForPerspective: number;
  17162. protected _source: AbstractMesh;
  17163. protected _linesPositions: number[];
  17164. protected _linesNormals: number[];
  17165. protected _linesIndices: number[];
  17166. protected _epsilon: number;
  17167. protected _indicesCount: number;
  17168. protected _lineShader: ShaderMaterial;
  17169. protected _ib: WebGLBuffer;
  17170. protected _buffers: {
  17171. [key: string]: Nullable<VertexBuffer>;
  17172. };
  17173. protected _checkVerticesInsteadOfIndices: boolean;
  17174. private _meshRebuildObserver;
  17175. private _meshDisposeObserver;
  17176. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17177. isEnabled: boolean;
  17178. /**
  17179. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17180. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17181. * @param source Mesh used to create edges
  17182. * @param epsilon sum of angles in adjacency to check for edge
  17183. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17184. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17185. */
  17186. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17187. protected _prepareRessources(): void;
  17188. /** @hidden */
  17189. _rebuild(): void;
  17190. /**
  17191. * Releases the required resources for the edges renderer
  17192. */
  17193. dispose(): void;
  17194. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17195. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17196. /**
  17197. * Checks if the pair of p0 and p1 is en edge
  17198. * @param faceIndex
  17199. * @param edge
  17200. * @param faceNormals
  17201. * @param p0
  17202. * @param p1
  17203. * @private
  17204. */
  17205. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17206. /**
  17207. * push line into the position, normal and index buffer
  17208. * @protected
  17209. */
  17210. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17211. /**
  17212. * Generates lines edges from adjacencjes
  17213. * @private
  17214. */
  17215. _generateEdgesLines(): void;
  17216. /**
  17217. * Checks wether or not the edges renderer is ready to render.
  17218. * @return true if ready, otherwise false.
  17219. */
  17220. isReady(): boolean;
  17221. /**
  17222. * Renders the edges of the attached mesh,
  17223. */
  17224. render(): void;
  17225. }
  17226. /**
  17227. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17228. */
  17229. export class LineEdgesRenderer extends EdgesRenderer {
  17230. /**
  17231. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17232. * @param source LineMesh used to generate edges
  17233. * @param epsilon not important (specified angle for edge detection)
  17234. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17235. */
  17236. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17237. /**
  17238. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17239. */
  17240. _generateEdgesLines(): void;
  17241. }
  17242. }
  17243. declare module "babylonjs/Rendering/renderingGroup" {
  17244. import { SmartArray } from "babylonjs/Misc/smartArray";
  17245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17247. import { Nullable } from "babylonjs/types";
  17248. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17249. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17250. import { Material } from "babylonjs/Materials/material";
  17251. import { Scene } from "babylonjs/scene";
  17252. /**
  17253. * This represents the object necessary to create a rendering group.
  17254. * This is exclusively used and created by the rendering manager.
  17255. * To modify the behavior, you use the available helpers in your scene or meshes.
  17256. * @hidden
  17257. */
  17258. export class RenderingGroup {
  17259. index: number;
  17260. private _scene;
  17261. private _opaqueSubMeshes;
  17262. private _transparentSubMeshes;
  17263. private _alphaTestSubMeshes;
  17264. private _depthOnlySubMeshes;
  17265. private _particleSystems;
  17266. private _spriteManagers;
  17267. private _opaqueSortCompareFn;
  17268. private _alphaTestSortCompareFn;
  17269. private _transparentSortCompareFn;
  17270. private _renderOpaque;
  17271. private _renderAlphaTest;
  17272. private _renderTransparent;
  17273. private _edgesRenderers;
  17274. onBeforeTransparentRendering: () => void;
  17275. /**
  17276. * Set the opaque sort comparison function.
  17277. * If null the sub meshes will be render in the order they were created
  17278. */
  17279. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17280. /**
  17281. * Set the alpha test sort comparison function.
  17282. * If null the sub meshes will be render in the order they were created
  17283. */
  17284. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17285. /**
  17286. * Set the transparent sort comparison function.
  17287. * If null the sub meshes will be render in the order they were created
  17288. */
  17289. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17290. /**
  17291. * Creates a new rendering group.
  17292. * @param index The rendering group index
  17293. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17294. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17295. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17296. */
  17297. 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>);
  17298. /**
  17299. * Render all the sub meshes contained in the group.
  17300. * @param customRenderFunction Used to override the default render behaviour of the group.
  17301. * @returns true if rendered some submeshes.
  17302. */
  17303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17304. /**
  17305. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17306. * @param subMeshes The submeshes to render
  17307. */
  17308. private renderOpaqueSorted;
  17309. /**
  17310. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17311. * @param subMeshes The submeshes to render
  17312. */
  17313. private renderAlphaTestSorted;
  17314. /**
  17315. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17316. * @param subMeshes The submeshes to render
  17317. */
  17318. private renderTransparentSorted;
  17319. /**
  17320. * Renders the submeshes in a specified order.
  17321. * @param subMeshes The submeshes to sort before render
  17322. * @param sortCompareFn The comparison function use to sort
  17323. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17324. * @param transparent Specifies to activate blending if true
  17325. */
  17326. private static renderSorted;
  17327. /**
  17328. * Renders the submeshes in the order they were dispatched (no sort applied).
  17329. * @param subMeshes The submeshes to render
  17330. */
  17331. private static renderUnsorted;
  17332. /**
  17333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17334. * are rendered back to front if in the same alpha index.
  17335. *
  17336. * @param a The first submesh
  17337. * @param b The second submesh
  17338. * @returns The result of the comparison
  17339. */
  17340. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17341. /**
  17342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17343. * are rendered back to front.
  17344. *
  17345. * @param a The first submesh
  17346. * @param b The second submesh
  17347. * @returns The result of the comparison
  17348. */
  17349. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17350. /**
  17351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17352. * are rendered front to back (prevent overdraw).
  17353. *
  17354. * @param a The first submesh
  17355. * @param b The second submesh
  17356. * @returns The result of the comparison
  17357. */
  17358. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17359. /**
  17360. * Resets the different lists of submeshes to prepare a new frame.
  17361. */
  17362. prepare(): void;
  17363. dispose(): void;
  17364. /**
  17365. * Inserts the submesh in its correct queue depending on its material.
  17366. * @param subMesh The submesh to dispatch
  17367. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17368. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17369. */
  17370. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17371. dispatchSprites(spriteManager: ISpriteManager): void;
  17372. dispatchParticles(particleSystem: IParticleSystem): void;
  17373. private _renderParticles;
  17374. private _renderSprites;
  17375. }
  17376. }
  17377. declare module "babylonjs/Rendering/renderingManager" {
  17378. import { Nullable } from "babylonjs/types";
  17379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17381. import { SmartArray } from "babylonjs/Misc/smartArray";
  17382. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17384. import { Material } from "babylonjs/Materials/material";
  17385. import { Scene } from "babylonjs/scene";
  17386. import { Camera } from "babylonjs/Cameras/camera";
  17387. /**
  17388. * Interface describing the different options available in the rendering manager
  17389. * regarding Auto Clear between groups.
  17390. */
  17391. export interface IRenderingManagerAutoClearSetup {
  17392. /**
  17393. * Defines whether or not autoclear is enable.
  17394. */
  17395. autoClear: boolean;
  17396. /**
  17397. * Defines whether or not to autoclear the depth buffer.
  17398. */
  17399. depth: boolean;
  17400. /**
  17401. * Defines whether or not to autoclear the stencil buffer.
  17402. */
  17403. stencil: boolean;
  17404. }
  17405. /**
  17406. * This class is used by the onRenderingGroupObservable
  17407. */
  17408. export class RenderingGroupInfo {
  17409. /**
  17410. * The Scene that being rendered
  17411. */
  17412. scene: Scene;
  17413. /**
  17414. * The camera currently used for the rendering pass
  17415. */
  17416. camera: Nullable<Camera>;
  17417. /**
  17418. * The ID of the renderingGroup being processed
  17419. */
  17420. renderingGroupId: number;
  17421. }
  17422. /**
  17423. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17424. * It is enable to manage the different groups as well as the different necessary sort functions.
  17425. * This should not be used directly aside of the few static configurations
  17426. */
  17427. export class RenderingManager {
  17428. /**
  17429. * The max id used for rendering groups (not included)
  17430. */
  17431. static MAX_RENDERINGGROUPS: number;
  17432. /**
  17433. * The min id used for rendering groups (included)
  17434. */
  17435. static MIN_RENDERINGGROUPS: number;
  17436. /**
  17437. * Used to globally prevent autoclearing scenes.
  17438. */
  17439. static AUTOCLEAR: boolean;
  17440. /**
  17441. * @hidden
  17442. */
  17443. _useSceneAutoClearSetup: boolean;
  17444. private _scene;
  17445. private _renderingGroups;
  17446. private _depthStencilBufferAlreadyCleaned;
  17447. private _autoClearDepthStencil;
  17448. private _customOpaqueSortCompareFn;
  17449. private _customAlphaTestSortCompareFn;
  17450. private _customTransparentSortCompareFn;
  17451. private _renderingGroupInfo;
  17452. /**
  17453. * Instantiates a new rendering group for a particular scene
  17454. * @param scene Defines the scene the groups belongs to
  17455. */
  17456. constructor(scene: Scene);
  17457. private _clearDepthStencilBuffer;
  17458. /**
  17459. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17460. * @hidden
  17461. */
  17462. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17463. /**
  17464. * Resets the different information of the group to prepare a new frame
  17465. * @hidden
  17466. */
  17467. reset(): void;
  17468. /**
  17469. * Dispose and release the group and its associated resources.
  17470. * @hidden
  17471. */
  17472. dispose(): void;
  17473. /**
  17474. * Clear the info related to rendering groups preventing retention points during dispose.
  17475. */
  17476. freeRenderingGroups(): void;
  17477. private _prepareRenderingGroup;
  17478. /**
  17479. * Add a sprite manager to the rendering manager in order to render it this frame.
  17480. * @param spriteManager Define the sprite manager to render
  17481. */
  17482. dispatchSprites(spriteManager: ISpriteManager): void;
  17483. /**
  17484. * Add a particle system to the rendering manager in order to render it this frame.
  17485. * @param particleSystem Define the particle system to render
  17486. */
  17487. dispatchParticles(particleSystem: IParticleSystem): void;
  17488. /**
  17489. * Add a submesh to the manager in order to render it this frame
  17490. * @param subMesh The submesh to dispatch
  17491. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17492. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17493. */
  17494. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17495. /**
  17496. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17497. * This allowed control for front to back rendering or reversly depending of the special needs.
  17498. *
  17499. * @param renderingGroupId The rendering group id corresponding to its index
  17500. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17501. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17502. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17503. */
  17504. 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;
  17505. /**
  17506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17507. *
  17508. * @param renderingGroupId The rendering group id corresponding to its index
  17509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17510. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17511. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17512. */
  17513. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17514. /**
  17515. * Gets the current auto clear configuration for one rendering group of the rendering
  17516. * manager.
  17517. * @param index the rendering group index to get the information for
  17518. * @returns The auto clear setup for the requested rendering group
  17519. */
  17520. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17521. }
  17522. }
  17523. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17524. import { Observable } from "babylonjs/Misc/observable";
  17525. import { SmartArray } from "babylonjs/Misc/smartArray";
  17526. import { Nullable } from "babylonjs/types";
  17527. import { Camera } from "babylonjs/Cameras/camera";
  17528. import { Scene } from "babylonjs/scene";
  17529. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17530. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17534. import { Texture } from "babylonjs/Materials/Textures/texture";
  17535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17536. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17537. import { Engine } from "babylonjs/Engines/engine";
  17538. /**
  17539. * This Helps creating a texture that will be created from a camera in your scene.
  17540. * It is basically a dynamic texture that could be used to create special effects for instance.
  17541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17542. */
  17543. export class RenderTargetTexture extends Texture {
  17544. isCube: boolean;
  17545. /**
  17546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17547. */
  17548. static readonly REFRESHRATE_RENDER_ONCE: number;
  17549. /**
  17550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17551. */
  17552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17553. /**
  17554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17555. * the central point of your effect and can save a lot of performances.
  17556. */
  17557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17558. /**
  17559. * Use this predicate to dynamically define the list of mesh you want to render.
  17560. * If set, the renderList property will be overwritten.
  17561. */
  17562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17563. private _renderList;
  17564. /**
  17565. * Use this list to define the list of mesh you want to render.
  17566. */
  17567. renderList: Nullable<Array<AbstractMesh>>;
  17568. private _hookArray;
  17569. /**
  17570. * Define if particles should be rendered in your texture.
  17571. */
  17572. renderParticles: boolean;
  17573. /**
  17574. * Define if sprites should be rendered in your texture.
  17575. */
  17576. renderSprites: boolean;
  17577. /**
  17578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17579. */
  17580. coordinatesMode: number;
  17581. /**
  17582. * Define the camera used to render the texture.
  17583. */
  17584. activeCamera: Nullable<Camera>;
  17585. /**
  17586. * Override the render function of the texture with your own one.
  17587. */
  17588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17589. /**
  17590. * Define if camera post processes should be use while rendering the texture.
  17591. */
  17592. useCameraPostProcesses: boolean;
  17593. /**
  17594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17595. */
  17596. ignoreCameraViewport: boolean;
  17597. private _postProcessManager;
  17598. private _postProcesses;
  17599. private _resizeObserver;
  17600. /**
  17601. * An event triggered when the texture is unbind.
  17602. */
  17603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17604. /**
  17605. * An event triggered when the texture is unbind.
  17606. */
  17607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17608. private _onAfterUnbindObserver;
  17609. /**
  17610. * Set a after unbind callback in the texture.
  17611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17612. */
  17613. onAfterUnbind: () => void;
  17614. /**
  17615. * An event triggered before rendering the texture
  17616. */
  17617. onBeforeRenderObservable: Observable<number>;
  17618. private _onBeforeRenderObserver;
  17619. /**
  17620. * Set a before render callback in the texture.
  17621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17622. */
  17623. onBeforeRender: (faceIndex: number) => void;
  17624. /**
  17625. * An event triggered after rendering the texture
  17626. */
  17627. onAfterRenderObservable: Observable<number>;
  17628. private _onAfterRenderObserver;
  17629. /**
  17630. * Set a after render callback in the texture.
  17631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17632. */
  17633. onAfterRender: (faceIndex: number) => void;
  17634. /**
  17635. * An event triggered after the texture clear
  17636. */
  17637. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17638. private _onClearObserver;
  17639. /**
  17640. * Set a clear callback in the texture.
  17641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17642. */
  17643. onClear: (Engine: Engine) => void;
  17644. /**
  17645. * Define the clear color of the Render Target if it should be different from the scene.
  17646. */
  17647. clearColor: Color4;
  17648. protected _size: number | {
  17649. width: number;
  17650. height: number;
  17651. };
  17652. protected _initialSizeParameter: number | {
  17653. width: number;
  17654. height: number;
  17655. } | {
  17656. ratio: number;
  17657. };
  17658. protected _sizeRatio: Nullable<number>;
  17659. /** @hidden */
  17660. _generateMipMaps: boolean;
  17661. protected _renderingManager: RenderingManager;
  17662. /** @hidden */
  17663. _waitingRenderList: string[];
  17664. protected _doNotChangeAspectRatio: boolean;
  17665. protected _currentRefreshId: number;
  17666. protected _refreshRate: number;
  17667. protected _textureMatrix: Matrix;
  17668. protected _samples: number;
  17669. protected _renderTargetOptions: RenderTargetCreationOptions;
  17670. /**
  17671. * Gets render target creation options that were used.
  17672. */
  17673. readonly renderTargetOptions: RenderTargetCreationOptions;
  17674. protected _engine: Engine;
  17675. protected _onRatioRescale(): void;
  17676. /**
  17677. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17678. * It must define where the camera used to render the texture is set
  17679. */
  17680. boundingBoxPosition: Vector3;
  17681. private _boundingBoxSize;
  17682. /**
  17683. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17684. * When defined, the cubemap will switch to local mode
  17685. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17686. * @example https://www.babylonjs-playground.com/#RNASML
  17687. */
  17688. boundingBoxSize: Vector3;
  17689. /**
  17690. * In case the RTT has been created with a depth texture, get the associated
  17691. * depth texture.
  17692. * Otherwise, return null.
  17693. */
  17694. depthStencilTexture: Nullable<InternalTexture>;
  17695. /**
  17696. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17697. * or used a shadow, depth texture...
  17698. * @param name The friendly name of the texture
  17699. * @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)
  17700. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17701. * @param generateMipMaps True if mip maps need to be generated after render.
  17702. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17703. * @param type The type of the buffer in the RTT (int, half float, float...)
  17704. * @param isCube True if a cube texture needs to be created
  17705. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17706. * @param generateDepthBuffer True to generate a depth buffer
  17707. * @param generateStencilBuffer True to generate a stencil buffer
  17708. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17709. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17710. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17711. */
  17712. constructor(name: string, size: number | {
  17713. width: number;
  17714. height: number;
  17715. } | {
  17716. ratio: number;
  17717. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17718. /**
  17719. * Creates a depth stencil texture.
  17720. * This is only available in WebGL 2 or with the depth texture extension available.
  17721. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17722. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17723. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17724. */
  17725. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17726. private _processSizeParameter;
  17727. /**
  17728. * Define the number of samples to use in case of MSAA.
  17729. * It defaults to one meaning no MSAA has been enabled.
  17730. */
  17731. samples: number;
  17732. /**
  17733. * Resets the refresh counter of the texture and start bak from scratch.
  17734. * Could be useful to regenerate the texture if it is setup to render only once.
  17735. */
  17736. resetRefreshCounter(): void;
  17737. /**
  17738. * Define the refresh rate of the texture or the rendering frequency.
  17739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17740. */
  17741. refreshRate: number;
  17742. /**
  17743. * Adds a post process to the render target rendering passes.
  17744. * @param postProcess define the post process to add
  17745. */
  17746. addPostProcess(postProcess: PostProcess): void;
  17747. /**
  17748. * Clear all the post processes attached to the render target
  17749. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17750. */
  17751. clearPostProcesses(dispose?: boolean): void;
  17752. /**
  17753. * Remove one of the post process from the list of attached post processes to the texture
  17754. * @param postProcess define the post process to remove from the list
  17755. */
  17756. removePostProcess(postProcess: PostProcess): void;
  17757. /** @hidden */
  17758. _shouldRender(): boolean;
  17759. /**
  17760. * Gets the actual render size of the texture.
  17761. * @returns the width of the render size
  17762. */
  17763. getRenderSize(): number;
  17764. /**
  17765. * Gets the actual render width of the texture.
  17766. * @returns the width of the render size
  17767. */
  17768. getRenderWidth(): number;
  17769. /**
  17770. * Gets the actual render height of the texture.
  17771. * @returns the height of the render size
  17772. */
  17773. getRenderHeight(): number;
  17774. /**
  17775. * Get if the texture can be rescaled or not.
  17776. */
  17777. readonly canRescale: boolean;
  17778. /**
  17779. * Resize the texture using a ratio.
  17780. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17781. */
  17782. scale(ratio: number): void;
  17783. /**
  17784. * Get the texture reflection matrix used to rotate/transform the reflection.
  17785. * @returns the reflection matrix
  17786. */
  17787. getReflectionTextureMatrix(): Matrix;
  17788. /**
  17789. * Resize the texture to a new desired size.
  17790. * Be carrefull as it will recreate all the data in the new texture.
  17791. * @param size Define the new size. It can be:
  17792. * - a number for squared texture,
  17793. * - an object containing { width: number, height: number }
  17794. * - or an object containing a ratio { ratio: number }
  17795. */
  17796. resize(size: number | {
  17797. width: number;
  17798. height: number;
  17799. } | {
  17800. ratio: number;
  17801. }): void;
  17802. /**
  17803. * Renders all the objects from the render list into the texture.
  17804. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17805. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17806. */
  17807. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17808. private _bestReflectionRenderTargetDimension;
  17809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17810. private renderToTarget;
  17811. /**
  17812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17813. * This allowed control for front to back rendering or reversly depending of the special needs.
  17814. *
  17815. * @param renderingGroupId The rendering group id corresponding to its index
  17816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17819. */
  17820. 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;
  17821. /**
  17822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17823. *
  17824. * @param renderingGroupId The rendering group id corresponding to its index
  17825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17826. */
  17827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17828. /**
  17829. * Clones the texture.
  17830. * @returns the cloned texture
  17831. */
  17832. clone(): RenderTargetTexture;
  17833. /**
  17834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17835. * @returns The JSON representation of the texture
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17840. */
  17841. disposeFramebufferObjects(): void;
  17842. /**
  17843. * Dispose the texture and release its associated resources.
  17844. */
  17845. dispose(): void;
  17846. /** @hidden */
  17847. _rebuild(): void;
  17848. /**
  17849. * Clear the info related to rendering groups preventing retention point in material dispose.
  17850. */
  17851. freeRenderingGroups(): void;
  17852. }
  17853. }
  17854. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17855. import { Scene } from "babylonjs/scene";
  17856. import { Plane } from "babylonjs/Maths/math";
  17857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17858. /**
  17859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17861. * You can then easily use it as a reflectionTexture on a flat surface.
  17862. * In case the surface is not a plane, please consider relying on reflection probes.
  17863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17864. */
  17865. export class MirrorTexture extends RenderTargetTexture {
  17866. private scene;
  17867. /**
  17868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17869. * 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.
  17870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17871. */
  17872. mirrorPlane: Plane;
  17873. /**
  17874. * Define the blur ratio used to blur the reflection if needed.
  17875. */
  17876. blurRatio: number;
  17877. /**
  17878. * Define the adaptive blur kernel used to blur the reflection if needed.
  17879. * This will autocompute the closest best match for the `blurKernel`
  17880. */
  17881. adaptiveBlurKernel: number;
  17882. /**
  17883. * Define the blur kernel used to blur the reflection if needed.
  17884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17885. */
  17886. blurKernel: number;
  17887. /**
  17888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17890. */
  17891. blurKernelX: number;
  17892. /**
  17893. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17894. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17895. */
  17896. blurKernelY: number;
  17897. private _autoComputeBlurKernel;
  17898. protected _onRatioRescale(): void;
  17899. private _updateGammaSpace;
  17900. private _imageProcessingConfigChangeObserver;
  17901. private _transformMatrix;
  17902. private _mirrorMatrix;
  17903. private _savedViewMatrix;
  17904. private _blurX;
  17905. private _blurY;
  17906. private _adaptiveBlurKernel;
  17907. private _blurKernelX;
  17908. private _blurKernelY;
  17909. private _blurRatio;
  17910. /**
  17911. * Instantiates a Mirror Texture.
  17912. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17913. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17914. * You can then easily use it as a reflectionTexture on a flat surface.
  17915. * In case the surface is not a plane, please consider relying on reflection probes.
  17916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17917. * @param name
  17918. * @param size
  17919. * @param scene
  17920. * @param generateMipMaps
  17921. * @param type
  17922. * @param samplingMode
  17923. * @param generateDepthBuffer
  17924. */
  17925. constructor(name: string, size: number | {
  17926. width: number;
  17927. height: number;
  17928. } | {
  17929. ratio: number;
  17930. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17931. private _preparePostProcesses;
  17932. /**
  17933. * Clone the mirror texture.
  17934. * @returns the cloned texture
  17935. */
  17936. clone(): MirrorTexture;
  17937. /**
  17938. * Serialize the texture to a JSON representation you could use in Parse later on
  17939. * @returns the serialized JSON representation
  17940. */
  17941. serialize(): any;
  17942. /**
  17943. * Dispose the texture and release its associated resources.
  17944. */
  17945. dispose(): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Materials/Textures/texture" {
  17949. import { Observable } from "babylonjs/Misc/observable";
  17950. import { Nullable } from "babylonjs/types";
  17951. import { Scene } from "babylonjs/scene";
  17952. import { Matrix } from "babylonjs/Maths/math";
  17953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17954. /**
  17955. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17956. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17957. */
  17958. export class Texture extends BaseTexture {
  17959. /** @hidden */
  17960. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17961. /** @hidden */
  17962. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17963. /** @hidden */
  17964. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17965. /** nearest is mag = nearest and min = nearest and mip = linear */
  17966. static readonly NEAREST_SAMPLINGMODE: number;
  17967. /** nearest is mag = nearest and min = nearest and mip = linear */
  17968. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17970. static readonly BILINEAR_SAMPLINGMODE: number;
  17971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17972. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17973. /** Trilinear is mag = linear and min = linear and mip = linear */
  17974. static readonly TRILINEAR_SAMPLINGMODE: number;
  17975. /** Trilinear is mag = linear and min = linear and mip = linear */
  17976. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17977. /** mag = nearest and min = nearest and mip = nearest */
  17978. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17979. /** mag = nearest and min = linear and mip = nearest */
  17980. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17981. /** mag = nearest and min = linear and mip = linear */
  17982. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17983. /** mag = nearest and min = linear and mip = none */
  17984. static readonly NEAREST_LINEAR: number;
  17985. /** mag = nearest and min = nearest and mip = none */
  17986. static readonly NEAREST_NEAREST: number;
  17987. /** mag = linear and min = nearest and mip = nearest */
  17988. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17989. /** mag = linear and min = nearest and mip = linear */
  17990. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17991. /** mag = linear and min = linear and mip = none */
  17992. static readonly LINEAR_LINEAR: number;
  17993. /** mag = linear and min = nearest and mip = none */
  17994. static readonly LINEAR_NEAREST: number;
  17995. /** Explicit coordinates mode */
  17996. static readonly EXPLICIT_MODE: number;
  17997. /** Spherical coordinates mode */
  17998. static readonly SPHERICAL_MODE: number;
  17999. /** Planar coordinates mode */
  18000. static readonly PLANAR_MODE: number;
  18001. /** Cubic coordinates mode */
  18002. static readonly CUBIC_MODE: number;
  18003. /** Projection coordinates mode */
  18004. static readonly PROJECTION_MODE: number;
  18005. /** Inverse Cubic coordinates mode */
  18006. static readonly SKYBOX_MODE: number;
  18007. /** Inverse Cubic coordinates mode */
  18008. static readonly INVCUBIC_MODE: number;
  18009. /** Equirectangular coordinates mode */
  18010. static readonly EQUIRECTANGULAR_MODE: number;
  18011. /** Equirectangular Fixed coordinates mode */
  18012. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18013. /** Equirectangular Fixed Mirrored coordinates mode */
  18014. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18015. /** Texture is not repeating outside of 0..1 UVs */
  18016. static readonly CLAMP_ADDRESSMODE: number;
  18017. /** Texture is repeating outside of 0..1 UVs */
  18018. static readonly WRAP_ADDRESSMODE: number;
  18019. /** Texture is repeating and mirrored */
  18020. static readonly MIRROR_ADDRESSMODE: number;
  18021. /**
  18022. * 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
  18023. */
  18024. static UseSerializedUrlIfAny: boolean;
  18025. /**
  18026. * Define the url of the texture.
  18027. */
  18028. url: Nullable<string>;
  18029. /**
  18030. * Define an offset on the texture to offset the u coordinates of the UVs
  18031. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18032. */
  18033. uOffset: number;
  18034. /**
  18035. * Define an offset on the texture to offset the v coordinates of the UVs
  18036. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18037. */
  18038. vOffset: number;
  18039. /**
  18040. * Define an offset on the texture to scale the u coordinates of the UVs
  18041. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18042. */
  18043. uScale: number;
  18044. /**
  18045. * Define an offset on the texture to scale the v coordinates of the UVs
  18046. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18047. */
  18048. vScale: number;
  18049. /**
  18050. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18051. * @see http://doc.babylonjs.com/how_to/more_materials
  18052. */
  18053. uAng: number;
  18054. /**
  18055. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18056. * @see http://doc.babylonjs.com/how_to/more_materials
  18057. */
  18058. vAng: number;
  18059. /**
  18060. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18061. * @see http://doc.babylonjs.com/how_to/more_materials
  18062. */
  18063. wAng: number;
  18064. /**
  18065. * Defines the center of rotation (U)
  18066. */
  18067. uRotationCenter: number;
  18068. /**
  18069. * Defines the center of rotation (V)
  18070. */
  18071. vRotationCenter: number;
  18072. /**
  18073. * Defines the center of rotation (W)
  18074. */
  18075. wRotationCenter: number;
  18076. /**
  18077. * Are mip maps generated for this texture or not.
  18078. */
  18079. readonly noMipmap: boolean;
  18080. private _noMipmap;
  18081. /** @hidden */
  18082. _invertY: boolean;
  18083. private _rowGenerationMatrix;
  18084. private _cachedTextureMatrix;
  18085. private _projectionModeMatrix;
  18086. private _t0;
  18087. private _t1;
  18088. private _t2;
  18089. private _cachedUOffset;
  18090. private _cachedVOffset;
  18091. private _cachedUScale;
  18092. private _cachedVScale;
  18093. private _cachedUAng;
  18094. private _cachedVAng;
  18095. private _cachedWAng;
  18096. private _cachedProjectionMatrixId;
  18097. private _cachedCoordinatesMode;
  18098. /** @hidden */
  18099. protected _initialSamplingMode: number;
  18100. /** @hidden */
  18101. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18102. private _deleteBuffer;
  18103. protected _format: Nullable<number>;
  18104. private _delayedOnLoad;
  18105. private _delayedOnError;
  18106. /**
  18107. * Observable triggered once the texture has been loaded.
  18108. */
  18109. onLoadObservable: Observable<Texture>;
  18110. protected _isBlocking: boolean;
  18111. /**
  18112. * Is the texture preventing material to render while loading.
  18113. * If false, a default texture will be used instead of the loading one during the preparation step.
  18114. */
  18115. isBlocking: boolean;
  18116. /**
  18117. * Get the current sampling mode associated with the texture.
  18118. */
  18119. readonly samplingMode: number;
  18120. /**
  18121. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18122. */
  18123. readonly invertY: boolean;
  18124. /**
  18125. * Instantiates a new texture.
  18126. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18127. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18128. * @param url define the url of the picture to load as a texture
  18129. * @param scene define the scene the texture will belong to
  18130. * @param noMipmap define if the texture will require mip maps or not
  18131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18133. * @param onLoad define a callback triggered when the texture has been loaded
  18134. * @param onError define a callback triggered when an error occurred during the loading session
  18135. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18136. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18137. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18138. */
  18139. 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);
  18140. /**
  18141. * Update the url (and optional buffer) of this texture if url was null during construction.
  18142. * @param url the url of the texture
  18143. * @param buffer the buffer of the texture (defaults to null)
  18144. * @param onLoad callback called when the texture is loaded (defaults to null)
  18145. */
  18146. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18147. /**
  18148. * Finish the loading sequence of a texture flagged as delayed load.
  18149. * @hidden
  18150. */
  18151. delayLoad(): void;
  18152. private _prepareRowForTextureGeneration;
  18153. /**
  18154. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18155. * @returns the transform matrix of the texture.
  18156. */
  18157. getTextureMatrix(): Matrix;
  18158. /**
  18159. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18160. * @returns The reflection texture transform
  18161. */
  18162. getReflectionTextureMatrix(): Matrix;
  18163. /**
  18164. * Clones the texture.
  18165. * @returns the cloned texture
  18166. */
  18167. clone(): Texture;
  18168. /**
  18169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18170. * @returns The JSON representation of the texture
  18171. */
  18172. serialize(): any;
  18173. /**
  18174. * Get the current class name of the texture useful for serialization or dynamic coding.
  18175. * @returns "Texture"
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Dispose the texture and release its associated resources.
  18180. */
  18181. dispose(): void;
  18182. /**
  18183. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18184. * @param parsedTexture Define the JSON representation of the texture
  18185. * @param scene Define the scene the parsed texture should be instantiated in
  18186. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18187. * @returns The parsed texture if successful
  18188. */
  18189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18190. /**
  18191. * Creates a texture from its base 64 representation.
  18192. * @param data Define the base64 payload without the data: prefix
  18193. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18194. * @param scene Define the scene the texture should belong to
  18195. * @param noMipmap Forces the texture to not create mip map information if true
  18196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18197. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18198. * @param onLoad define a callback triggered when the texture has been loaded
  18199. * @param onError define a callback triggered when an error occurred during the loading session
  18200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18201. * @returns the created texture
  18202. */
  18203. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18204. /**
  18205. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18206. * @param data Define the base64 payload without the data: prefix
  18207. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18209. * @param scene Define the scene the texture should belong to
  18210. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18211. * @param noMipmap Forces the texture to not create mip map information if true
  18212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18214. * @param onLoad define a callback triggered when the texture has been loaded
  18215. * @param onError define a callback triggered when an error occurred during the loading session
  18216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18217. * @returns the created texture
  18218. */
  18219. 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;
  18220. }
  18221. }
  18222. declare module "babylonjs/Materials/Textures/rawTexture" {
  18223. import { Scene } from "babylonjs/scene";
  18224. import { Texture } from "babylonjs/Materials/Textures/texture";
  18225. /**
  18226. * Raw texture can help creating a texture directly from an array of data.
  18227. * This can be super useful if you either get the data from an uncompressed source or
  18228. * if you wish to create your texture pixel by pixel.
  18229. */
  18230. export class RawTexture extends Texture {
  18231. /**
  18232. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18233. */
  18234. format: number;
  18235. private _engine;
  18236. /**
  18237. * Instantiates a new RawTexture.
  18238. * Raw texture can help creating a texture directly from an array of data.
  18239. * This can be super useful if you either get the data from an uncompressed source or
  18240. * if you wish to create your texture pixel by pixel.
  18241. * @param data define the array of data to use to create the texture
  18242. * @param width define the width of the texture
  18243. * @param height define the height of the texture
  18244. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18245. * @param scene define the scene the texture belongs to
  18246. * @param generateMipMaps define whether mip maps should be generated or not
  18247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18250. */
  18251. constructor(data: ArrayBufferView, width: number, height: number,
  18252. /**
  18253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18254. */
  18255. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18256. /**
  18257. * Updates the texture underlying data.
  18258. * @param data Define the new data of the texture
  18259. */
  18260. update(data: ArrayBufferView): void;
  18261. /**
  18262. * Creates a luminance texture from some data.
  18263. * @param data Define the texture data
  18264. * @param width Define the width of the texture
  18265. * @param height Define the height of the texture
  18266. * @param scene Define the scene the texture belongs to
  18267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18270. * @returns the luminance texture
  18271. */
  18272. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18273. /**
  18274. * Creates a luminance alpha texture from some data.
  18275. * @param data Define the texture data
  18276. * @param width Define the width of the texture
  18277. * @param height Define the height of the texture
  18278. * @param scene Define the scene the texture belongs to
  18279. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18280. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18281. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18282. * @returns the luminance alpha texture
  18283. */
  18284. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18285. /**
  18286. * Creates an alpha texture from some data.
  18287. * @param data Define the texture data
  18288. * @param width Define the width of the texture
  18289. * @param height Define the height of the texture
  18290. * @param scene Define the scene the texture belongs to
  18291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18294. * @returns the alpha texture
  18295. */
  18296. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18297. /**
  18298. * Creates a RGB texture from some data.
  18299. * @param data Define the texture data
  18300. * @param width Define the width of the texture
  18301. * @param height Define the height of the texture
  18302. * @param scene Define the scene the texture belongs to
  18303. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18307. * @returns the RGB alpha texture
  18308. */
  18309. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18310. /**
  18311. * Creates a RGBA texture from some data.
  18312. * @param data Define the texture data
  18313. * @param width Define the width of the texture
  18314. * @param height Define the height of the texture
  18315. * @param scene Define the scene the texture belongs to
  18316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18319. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18320. * @returns the RGBA texture
  18321. */
  18322. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18323. /**
  18324. * Creates a R texture from some data.
  18325. * @param data Define the texture data
  18326. * @param width Define the width of the texture
  18327. * @param height Define the height of the texture
  18328. * @param scene Define the scene the texture belongs to
  18329. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18330. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18331. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18332. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18333. * @returns the R texture
  18334. */
  18335. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18336. }
  18337. }
  18338. declare module "babylonjs/Animations/runtimeAnimation" {
  18339. import { Animation } from "babylonjs/Animations/animation";
  18340. import { Animatable } from "babylonjs/Animations/animatable";
  18341. import { Scene } from "babylonjs/scene";
  18342. /**
  18343. * Defines a runtime animation
  18344. */
  18345. export class RuntimeAnimation {
  18346. private _events;
  18347. /**
  18348. * The current frame of the runtime animation
  18349. */
  18350. private _currentFrame;
  18351. /**
  18352. * The animation used by the runtime animation
  18353. */
  18354. private _animation;
  18355. /**
  18356. * The target of the runtime animation
  18357. */
  18358. private _target;
  18359. /**
  18360. * The initiating animatable
  18361. */
  18362. private _host;
  18363. /**
  18364. * The original value of the runtime animation
  18365. */
  18366. private _originalValue;
  18367. /**
  18368. * The original blend value of the runtime animation
  18369. */
  18370. private _originalBlendValue;
  18371. /**
  18372. * The offsets cache of the runtime animation
  18373. */
  18374. private _offsetsCache;
  18375. /**
  18376. * The high limits cache of the runtime animation
  18377. */
  18378. private _highLimitsCache;
  18379. /**
  18380. * Specifies if the runtime animation has been stopped
  18381. */
  18382. private _stopped;
  18383. /**
  18384. * The blending factor of the runtime animation
  18385. */
  18386. private _blendingFactor;
  18387. /**
  18388. * The BabylonJS scene
  18389. */
  18390. private _scene;
  18391. /**
  18392. * The current value of the runtime animation
  18393. */
  18394. private _currentValue;
  18395. /** @hidden */
  18396. _workValue: any;
  18397. /**
  18398. * The active target of the runtime animation
  18399. */
  18400. private _activeTarget;
  18401. /**
  18402. * The target path of the runtime animation
  18403. */
  18404. private _targetPath;
  18405. /**
  18406. * The weight of the runtime animation
  18407. */
  18408. private _weight;
  18409. /**
  18410. * The ratio offset of the runtime animation
  18411. */
  18412. private _ratioOffset;
  18413. /**
  18414. * The previous delay of the runtime animation
  18415. */
  18416. private _previousDelay;
  18417. /**
  18418. * The previous ratio of the runtime animation
  18419. */
  18420. private _previousRatio;
  18421. /**
  18422. * Gets the current frame of the runtime animation
  18423. */
  18424. readonly currentFrame: number;
  18425. /**
  18426. * Gets the weight of the runtime animation
  18427. */
  18428. readonly weight: number;
  18429. /**
  18430. * Gets the current value of the runtime animation
  18431. */
  18432. readonly currentValue: any;
  18433. /**
  18434. * Gets the target path of the runtime animation
  18435. */
  18436. readonly targetPath: string;
  18437. /**
  18438. * Gets the actual target of the runtime animation
  18439. */
  18440. readonly target: any;
  18441. /**
  18442. * Create a new RuntimeAnimation object
  18443. * @param target defines the target of the animation
  18444. * @param animation defines the source animation object
  18445. * @param scene defines the hosting scene
  18446. * @param host defines the initiating Animatable
  18447. */
  18448. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18449. /**
  18450. * Gets the animation from the runtime animation
  18451. */
  18452. readonly animation: Animation;
  18453. /**
  18454. * Resets the runtime animation to the beginning
  18455. * @param restoreOriginal defines whether to restore the target property to the original value
  18456. */
  18457. reset(restoreOriginal?: boolean): void;
  18458. /**
  18459. * Specifies if the runtime animation is stopped
  18460. * @returns Boolean specifying if the runtime animation is stopped
  18461. */
  18462. isStopped(): boolean;
  18463. /**
  18464. * Disposes of the runtime animation
  18465. */
  18466. dispose(): void;
  18467. /**
  18468. * Interpolates the animation from the current frame
  18469. * @param currentFrame The frame to interpolate the animation to
  18470. * @param repeatCount The number of times that the animation should loop
  18471. * @param loopMode The type of looping mode to use
  18472. * @param offsetValue Animation offset value
  18473. * @param highLimitValue The high limit value
  18474. * @returns The interpolated value
  18475. */
  18476. private _interpolate;
  18477. /**
  18478. * Apply the interpolated value to the target
  18479. * @param currentValue defines the value computed by the animation
  18480. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18481. */
  18482. setValue(currentValue: any, weight?: number): void;
  18483. private _setValue;
  18484. /**
  18485. * Gets the loop pmode of the runtime animation
  18486. * @returns Loop Mode
  18487. */
  18488. private _getCorrectLoopMode;
  18489. /**
  18490. * Move the current animation to a given frame
  18491. * @param frame defines the frame to move to
  18492. */
  18493. goToFrame(frame: number): void;
  18494. /**
  18495. * @hidden Internal use only
  18496. */
  18497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18498. /**
  18499. * Execute the current animation
  18500. * @param delay defines the delay to add to the current frame
  18501. * @param from defines the lower bound of the animation range
  18502. * @param to defines the upper bound of the animation range
  18503. * @param loop defines if the current animation must loop
  18504. * @param speedRatio defines the current speed ratio
  18505. * @param weight defines the weight of the animation (default is -1 so no weight)
  18506. * @param onLoop optional callback called when animation loops
  18507. * @returns a boolean indicating if the animation is running
  18508. */
  18509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18510. }
  18511. }
  18512. declare module "babylonjs/Animations/animatable" {
  18513. import { Animation } from "babylonjs/Animations/animation";
  18514. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18515. import { Nullable } from "babylonjs/types";
  18516. import { Observable } from "babylonjs/Misc/observable";
  18517. import { Scene } from "babylonjs/scene";
  18518. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18519. import { Node } from "babylonjs/node";
  18520. /**
  18521. * Class used to store an actual running animation
  18522. */
  18523. export class Animatable {
  18524. /** defines the target object */
  18525. target: any;
  18526. /** defines the starting frame number (default is 0) */
  18527. fromFrame: number;
  18528. /** defines the ending frame number (default is 100) */
  18529. toFrame: number;
  18530. /** defines if the animation must loop (default is false) */
  18531. loopAnimation: boolean;
  18532. /** defines a callback to call when animation ends if it is not looping */
  18533. onAnimationEnd?: (() => void) | null | undefined;
  18534. /** defines a callback to call when animation loops */
  18535. onAnimationLoop?: (() => void) | null | undefined;
  18536. private _localDelayOffset;
  18537. private _pausedDelay;
  18538. private _runtimeAnimations;
  18539. private _paused;
  18540. private _scene;
  18541. private _speedRatio;
  18542. private _weight;
  18543. private _syncRoot;
  18544. /**
  18545. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18546. * This will only apply for non looping animation (default is true)
  18547. */
  18548. disposeOnEnd: boolean;
  18549. /**
  18550. * Gets a boolean indicating if the animation has started
  18551. */
  18552. animationStarted: boolean;
  18553. /**
  18554. * Observer raised when the animation ends
  18555. */
  18556. onAnimationEndObservable: Observable<Animatable>;
  18557. /**
  18558. * Observer raised when the animation loops
  18559. */
  18560. onAnimationLoopObservable: Observable<Animatable>;
  18561. /**
  18562. * Gets the root Animatable used to synchronize and normalize animations
  18563. */
  18564. readonly syncRoot: Animatable;
  18565. /**
  18566. * Gets the current frame of the first RuntimeAnimation
  18567. * Used to synchronize Animatables
  18568. */
  18569. readonly masterFrame: number;
  18570. /**
  18571. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18572. */
  18573. weight: number;
  18574. /**
  18575. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18576. */
  18577. speedRatio: number;
  18578. /**
  18579. * Creates a new Animatable
  18580. * @param scene defines the hosting scene
  18581. * @param target defines the target object
  18582. * @param fromFrame defines the starting frame number (default is 0)
  18583. * @param toFrame defines the ending frame number (default is 100)
  18584. * @param loopAnimation defines if the animation must loop (default is false)
  18585. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18586. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18587. * @param animations defines a group of animation to add to the new Animatable
  18588. * @param onAnimationLoop defines a callback to call when animation loops
  18589. */
  18590. constructor(scene: Scene,
  18591. /** defines the target object */
  18592. target: any,
  18593. /** defines the starting frame number (default is 0) */
  18594. fromFrame?: number,
  18595. /** defines the ending frame number (default is 100) */
  18596. toFrame?: number,
  18597. /** defines if the animation must loop (default is false) */
  18598. loopAnimation?: boolean, speedRatio?: number,
  18599. /** defines a callback to call when animation ends if it is not looping */
  18600. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18601. /** defines a callback to call when animation loops */
  18602. onAnimationLoop?: (() => void) | null | undefined);
  18603. /**
  18604. * Synchronize and normalize current Animatable with a source Animatable
  18605. * This is useful when using animation weights and when animations are not of the same length
  18606. * @param root defines the root Animatable to synchronize with
  18607. * @returns the current Animatable
  18608. */
  18609. syncWith(root: Animatable): Animatable;
  18610. /**
  18611. * Gets the list of runtime animations
  18612. * @returns an array of RuntimeAnimation
  18613. */
  18614. getAnimations(): RuntimeAnimation[];
  18615. /**
  18616. * Adds more animations to the current animatable
  18617. * @param target defines the target of the animations
  18618. * @param animations defines the new animations to add
  18619. */
  18620. appendAnimations(target: any, animations: Animation[]): void;
  18621. /**
  18622. * Gets the source animation for a specific property
  18623. * @param property defines the propertyu to look for
  18624. * @returns null or the source animation for the given property
  18625. */
  18626. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18627. /**
  18628. * Gets the runtime animation for a specific property
  18629. * @param property defines the propertyu to look for
  18630. * @returns null or the runtime animation for the given property
  18631. */
  18632. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18633. /**
  18634. * Resets the animatable to its original state
  18635. */
  18636. reset(): void;
  18637. /**
  18638. * Allows the animatable to blend with current running animations
  18639. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18640. * @param blendingSpeed defines the blending speed to use
  18641. */
  18642. enableBlending(blendingSpeed: number): void;
  18643. /**
  18644. * Disable animation blending
  18645. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18646. */
  18647. disableBlending(): void;
  18648. /**
  18649. * Jump directly to a given frame
  18650. * @param frame defines the frame to jump to
  18651. */
  18652. goToFrame(frame: number): void;
  18653. /**
  18654. * Pause the animation
  18655. */
  18656. pause(): void;
  18657. /**
  18658. * Restart the animation
  18659. */
  18660. restart(): void;
  18661. private _raiseOnAnimationEnd;
  18662. /**
  18663. * Stop and delete the current animation
  18664. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18665. * @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)
  18666. */
  18667. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18668. /**
  18669. * Wait asynchronously for the animation to end
  18670. * @returns a promise which will be fullfilled when the animation ends
  18671. */
  18672. waitAsync(): Promise<Animatable>;
  18673. /** @hidden */
  18674. _animate(delay: number): boolean;
  18675. }
  18676. module "babylonjs/scene" {
  18677. interface Scene {
  18678. /** @hidden */
  18679. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18680. /** @hidden */
  18681. _processLateAnimationBindingsForMatrices(holder: {
  18682. totalWeight: number;
  18683. animations: RuntimeAnimation[];
  18684. originalValue: Matrix;
  18685. }): any;
  18686. /** @hidden */
  18687. _processLateAnimationBindingsForQuaternions(holder: {
  18688. totalWeight: number;
  18689. animations: RuntimeAnimation[];
  18690. originalValue: Quaternion;
  18691. }, refQuaternion: Quaternion): Quaternion;
  18692. /** @hidden */
  18693. _processLateAnimationBindings(): void;
  18694. /**
  18695. * Will start the animation sequence of a given target
  18696. * @param target defines the target
  18697. * @param from defines from which frame should animation start
  18698. * @param to defines until which frame should animation run.
  18699. * @param weight defines the weight to apply to the animation (1.0 by default)
  18700. * @param loop defines if the animation loops
  18701. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18702. * @param onAnimationEnd defines the function to be executed when the animation ends
  18703. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18704. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18705. * @param onAnimationLoop defines the callback to call when an animation loops
  18706. * @returns the animatable object created for this animation
  18707. */
  18708. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18709. /**
  18710. * Will start the animation sequence of a given target
  18711. * @param target defines the target
  18712. * @param from defines from which frame should animation start
  18713. * @param to defines until which frame should animation run.
  18714. * @param loop defines if the animation loops
  18715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18716. * @param onAnimationEnd defines the function to be executed when the animation ends
  18717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18718. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18719. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18720. * @param onAnimationLoop defines the callback to call when an animation loops
  18721. * @returns the animatable object created for this animation
  18722. */
  18723. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18724. /**
  18725. * Will start the animation sequence of a given target and its hierarchy
  18726. * @param target defines the target
  18727. * @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.
  18728. * @param from defines from which frame should animation start
  18729. * @param to defines until which frame should animation run.
  18730. * @param loop defines if the animation loops
  18731. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18732. * @param onAnimationEnd defines the function to be executed when the animation ends
  18733. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18734. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18736. * @param onAnimationLoop defines the callback to call when an animation loops
  18737. * @returns the list of created animatables
  18738. */
  18739. 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[];
  18740. /**
  18741. * Begin a new animation on a given node
  18742. * @param target defines the target where the animation will take place
  18743. * @param animations defines the list of animations to start
  18744. * @param from defines the initial value
  18745. * @param to defines the final value
  18746. * @param loop defines if you want animation to loop (off by default)
  18747. * @param speedRatio defines the speed ratio to apply to all animations
  18748. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18749. * @param onAnimationLoop defines the callback to call when an animation loops
  18750. * @returns the list of created animatables
  18751. */
  18752. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18753. /**
  18754. * Begin a new animation on a given node and its hierarchy
  18755. * @param target defines the root node where the animation will take place
  18756. * @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.
  18757. * @param animations defines the list of animations to start
  18758. * @param from defines the initial value
  18759. * @param to defines the final value
  18760. * @param loop defines if you want animation to loop (off by default)
  18761. * @param speedRatio defines the speed ratio to apply to all animations
  18762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18763. * @param onAnimationLoop defines the callback to call when an animation loops
  18764. * @returns the list of animatables created for all nodes
  18765. */
  18766. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18767. /**
  18768. * Gets the animatable associated with a specific target
  18769. * @param target defines the target of the animatable
  18770. * @returns the required animatable if found
  18771. */
  18772. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18773. /**
  18774. * Gets all animatables associated with a given target
  18775. * @param target defines the target to look animatables for
  18776. * @returns an array of Animatables
  18777. */
  18778. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18779. /**
  18780. * Will stop the animation of the given target
  18781. * @param target - the target
  18782. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18783. * @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)
  18784. */
  18785. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18786. /**
  18787. * Stops and removes all animations that have been applied to the scene
  18788. */
  18789. stopAllAnimations(): void;
  18790. }
  18791. }
  18792. module "babylonjs/Bones/bone" {
  18793. interface Bone {
  18794. /**
  18795. * Copy an animation range from another bone
  18796. * @param source defines the source bone
  18797. * @param rangeName defines the range name to copy
  18798. * @param frameOffset defines the frame offset
  18799. * @param rescaleAsRequired defines if rescaling must be applied if required
  18800. * @param skelDimensionsRatio defines the scaling ratio
  18801. * @returns true if operation was successful
  18802. */
  18803. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18804. }
  18805. }
  18806. }
  18807. declare module "babylonjs/Bones/skeleton" {
  18808. import { Bone } from "babylonjs/Bones/bone";
  18809. import { IAnimatable } from "babylonjs/Misc/tools";
  18810. import { Observable } from "babylonjs/Misc/observable";
  18811. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18812. import { Scene } from "babylonjs/scene";
  18813. import { Nullable } from "babylonjs/types";
  18814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18815. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18816. import { Animatable } from "babylonjs/Animations/animatable";
  18817. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18818. import { Animation } from "babylonjs/Animations/animation";
  18819. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18820. /**
  18821. * Class used to handle skinning animations
  18822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18823. */
  18824. export class Skeleton implements IAnimatable {
  18825. /** defines the skeleton name */
  18826. name: string;
  18827. /** defines the skeleton Id */
  18828. id: string;
  18829. /**
  18830. * Defines the list of child bones
  18831. */
  18832. bones: Bone[];
  18833. /**
  18834. * Defines an estimate of the dimension of the skeleton at rest
  18835. */
  18836. dimensionsAtRest: Vector3;
  18837. /**
  18838. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18839. */
  18840. needInitialSkinMatrix: boolean;
  18841. /**
  18842. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18843. */
  18844. overrideMesh: Nullable<AbstractMesh>;
  18845. /**
  18846. * Gets the list of animations attached to this skeleton
  18847. */
  18848. animations: Array<Animation>;
  18849. private _scene;
  18850. private _isDirty;
  18851. private _transformMatrices;
  18852. private _transformMatrixTexture;
  18853. private _meshesWithPoseMatrix;
  18854. private _animatables;
  18855. private _identity;
  18856. private _synchronizedWithMesh;
  18857. private _ranges;
  18858. private _lastAbsoluteTransformsUpdateId;
  18859. private _canUseTextureForBones;
  18860. /** @hidden */
  18861. _numBonesWithLinkedTransformNode: number;
  18862. /**
  18863. * Specifies if the skeleton should be serialized
  18864. */
  18865. doNotSerialize: boolean;
  18866. /**
  18867. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18868. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18869. */
  18870. useTextureToStoreBoneMatrices: boolean;
  18871. private _animationPropertiesOverride;
  18872. /**
  18873. * Gets or sets the animation properties override
  18874. */
  18875. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18876. /**
  18877. * An observable triggered before computing the skeleton's matrices
  18878. */
  18879. onBeforeComputeObservable: Observable<Skeleton>;
  18880. /**
  18881. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18882. */
  18883. readonly isUsingTextureForMatrices: boolean;
  18884. /**
  18885. * Creates a new skeleton
  18886. * @param name defines the skeleton name
  18887. * @param id defines the skeleton Id
  18888. * @param scene defines the hosting scene
  18889. */
  18890. constructor(
  18891. /** defines the skeleton name */
  18892. name: string,
  18893. /** defines the skeleton Id */
  18894. id: string, scene: Scene);
  18895. /**
  18896. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18897. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18898. * @returns a Float32Array containing matrices data
  18899. */
  18900. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18901. /**
  18902. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18903. * @returns a raw texture containing the data
  18904. */
  18905. getTransformMatrixTexture(): Nullable<RawTexture>;
  18906. /**
  18907. * Gets the current hosting scene
  18908. * @returns a scene object
  18909. */
  18910. getScene(): Scene;
  18911. /**
  18912. * Gets a string representing the current skeleton data
  18913. * @param fullDetails defines a boolean indicating if we want a verbose version
  18914. * @returns a string representing the current skeleton data
  18915. */
  18916. toString(fullDetails?: boolean): string;
  18917. /**
  18918. * Get bone's index searching by name
  18919. * @param name defines bone's name to search for
  18920. * @return the indice of the bone. Returns -1 if not found
  18921. */
  18922. getBoneIndexByName(name: string): number;
  18923. /**
  18924. * Creater a new animation range
  18925. * @param name defines the name of the range
  18926. * @param from defines the start key
  18927. * @param to defines the end key
  18928. */
  18929. createAnimationRange(name: string, from: number, to: number): void;
  18930. /**
  18931. * Delete a specific animation range
  18932. * @param name defines the name of the range
  18933. * @param deleteFrames defines if frames must be removed as well
  18934. */
  18935. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18936. /**
  18937. * Gets a specific animation range
  18938. * @param name defines the name of the range to look for
  18939. * @returns the requested animation range or null if not found
  18940. */
  18941. getAnimationRange(name: string): Nullable<AnimationRange>;
  18942. /**
  18943. * Gets the list of all animation ranges defined on this skeleton
  18944. * @returns an array
  18945. */
  18946. getAnimationRanges(): Nullable<AnimationRange>[];
  18947. /**
  18948. * Copy animation range from a source skeleton.
  18949. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18950. * @param source defines the source skeleton
  18951. * @param name defines the name of the range to copy
  18952. * @param rescaleAsRequired defines if rescaling must be applied if required
  18953. * @returns true if operation was successful
  18954. */
  18955. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18956. /**
  18957. * Forces the skeleton to go to rest pose
  18958. */
  18959. returnToRest(): void;
  18960. private _getHighestAnimationFrame;
  18961. /**
  18962. * Begin a specific animation range
  18963. * @param name defines the name of the range to start
  18964. * @param loop defines if looping must be turned on (false by default)
  18965. * @param speedRatio defines the speed ratio to apply (1 by default)
  18966. * @param onAnimationEnd defines a callback which will be called when animation will end
  18967. * @returns a new animatable
  18968. */
  18969. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18970. /** @hidden */
  18971. _markAsDirty(): void;
  18972. /** @hidden */
  18973. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18974. /** @hidden */
  18975. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18976. private _computeTransformMatrices;
  18977. /**
  18978. * Build all resources required to render a skeleton
  18979. */
  18980. prepare(): void;
  18981. /**
  18982. * Gets the list of animatables currently running for this skeleton
  18983. * @returns an array of animatables
  18984. */
  18985. getAnimatables(): IAnimatable[];
  18986. /**
  18987. * Clone the current skeleton
  18988. * @param name defines the name of the new skeleton
  18989. * @param id defines the id of the enw skeleton
  18990. * @returns the new skeleton
  18991. */
  18992. clone(name: string, id: string): Skeleton;
  18993. /**
  18994. * Enable animation blending for this skeleton
  18995. * @param blendingSpeed defines the blending speed to apply
  18996. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18997. */
  18998. enableBlending(blendingSpeed?: number): void;
  18999. /**
  19000. * Releases all resources associated with the current skeleton
  19001. */
  19002. dispose(): void;
  19003. /**
  19004. * Serialize the skeleton in a JSON object
  19005. * @returns a JSON object
  19006. */
  19007. serialize(): any;
  19008. /**
  19009. * Creates a new skeleton from serialized data
  19010. * @param parsedSkeleton defines the serialized data
  19011. * @param scene defines the hosting scene
  19012. * @returns a new skeleton
  19013. */
  19014. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19015. /**
  19016. * Compute all node absolute transforms
  19017. * @param forceUpdate defines if computation must be done even if cache is up to date
  19018. */
  19019. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19020. /**
  19021. * Gets the root pose matrix
  19022. * @returns a matrix
  19023. */
  19024. getPoseMatrix(): Nullable<Matrix>;
  19025. /**
  19026. * Sorts bones per internal index
  19027. */
  19028. sortBones(): void;
  19029. private _sortBones;
  19030. }
  19031. }
  19032. declare module "babylonjs/Morph/morphTarget" {
  19033. import { IAnimatable } from "babylonjs/Misc/tools";
  19034. import { Observable } from "babylonjs/Misc/observable";
  19035. import { Nullable, FloatArray } from "babylonjs/types";
  19036. import { Scene } from "babylonjs/scene";
  19037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19038. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19039. /**
  19040. * Defines a target to use with MorphTargetManager
  19041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19042. */
  19043. export class MorphTarget implements IAnimatable {
  19044. /** defines the name of the target */
  19045. name: string;
  19046. /**
  19047. * Gets or sets the list of animations
  19048. */
  19049. animations: import("babylonjs/Animations/animation").Animation[];
  19050. private _scene;
  19051. private _positions;
  19052. private _normals;
  19053. private _tangents;
  19054. private _influence;
  19055. /**
  19056. * Observable raised when the influence changes
  19057. */
  19058. onInfluenceChanged: Observable<boolean>;
  19059. /** @hidden */
  19060. _onDataLayoutChanged: Observable<void>;
  19061. /**
  19062. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19063. */
  19064. influence: number;
  19065. /**
  19066. * Gets or sets the id of the morph Target
  19067. */
  19068. id: string;
  19069. private _animationPropertiesOverride;
  19070. /**
  19071. * Gets or sets the animation properties override
  19072. */
  19073. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19074. /**
  19075. * Creates a new MorphTarget
  19076. * @param name defines the name of the target
  19077. * @param influence defines the influence to use
  19078. * @param scene defines the scene the morphtarget belongs to
  19079. */
  19080. constructor(
  19081. /** defines the name of the target */
  19082. name: string, influence?: number, scene?: Nullable<Scene>);
  19083. /**
  19084. * Gets a boolean defining if the target contains position data
  19085. */
  19086. readonly hasPositions: boolean;
  19087. /**
  19088. * Gets a boolean defining if the target contains normal data
  19089. */
  19090. readonly hasNormals: boolean;
  19091. /**
  19092. * Gets a boolean defining if the target contains tangent data
  19093. */
  19094. readonly hasTangents: boolean;
  19095. /**
  19096. * Affects position data to this target
  19097. * @param data defines the position data to use
  19098. */
  19099. setPositions(data: Nullable<FloatArray>): void;
  19100. /**
  19101. * Gets the position data stored in this target
  19102. * @returns a FloatArray containing the position data (or null if not present)
  19103. */
  19104. getPositions(): Nullable<FloatArray>;
  19105. /**
  19106. * Affects normal data to this target
  19107. * @param data defines the normal data to use
  19108. */
  19109. setNormals(data: Nullable<FloatArray>): void;
  19110. /**
  19111. * Gets the normal data stored in this target
  19112. * @returns a FloatArray containing the normal data (or null if not present)
  19113. */
  19114. getNormals(): Nullable<FloatArray>;
  19115. /**
  19116. * Affects tangent data to this target
  19117. * @param data defines the tangent data to use
  19118. */
  19119. setTangents(data: Nullable<FloatArray>): void;
  19120. /**
  19121. * Gets the tangent data stored in this target
  19122. * @returns a FloatArray containing the tangent data (or null if not present)
  19123. */
  19124. getTangents(): Nullable<FloatArray>;
  19125. /**
  19126. * Serializes the current target into a Serialization object
  19127. * @returns the serialized object
  19128. */
  19129. serialize(): any;
  19130. /**
  19131. * Returns the string "MorphTarget"
  19132. * @returns "MorphTarget"
  19133. */
  19134. getClassName(): string;
  19135. /**
  19136. * Creates a new target from serialized data
  19137. * @param serializationObject defines the serialized data to use
  19138. * @returns a new MorphTarget
  19139. */
  19140. static Parse(serializationObject: any): MorphTarget;
  19141. /**
  19142. * Creates a MorphTarget from mesh data
  19143. * @param mesh defines the source mesh
  19144. * @param name defines the name to use for the new target
  19145. * @param influence defines the influence to attach to the target
  19146. * @returns a new MorphTarget
  19147. */
  19148. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19149. }
  19150. }
  19151. declare module "babylonjs/Morph/morphTargetManager" {
  19152. import { Nullable } from "babylonjs/types";
  19153. import { Scene } from "babylonjs/scene";
  19154. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19155. /**
  19156. * This class is used to deform meshes using morphing between different targets
  19157. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19158. */
  19159. export class MorphTargetManager {
  19160. private _targets;
  19161. private _targetInfluenceChangedObservers;
  19162. private _targetDataLayoutChangedObservers;
  19163. private _activeTargets;
  19164. private _scene;
  19165. private _influences;
  19166. private _supportsNormals;
  19167. private _supportsTangents;
  19168. private _vertexCount;
  19169. private _uniqueId;
  19170. private _tempInfluences;
  19171. /**
  19172. * Creates a new MorphTargetManager
  19173. * @param scene defines the current scene
  19174. */
  19175. constructor(scene?: Nullable<Scene>);
  19176. /**
  19177. * Gets the unique ID of this manager
  19178. */
  19179. readonly uniqueId: number;
  19180. /**
  19181. * Gets the number of vertices handled by this manager
  19182. */
  19183. readonly vertexCount: number;
  19184. /**
  19185. * Gets a boolean indicating if this manager supports morphing of normals
  19186. */
  19187. readonly supportsNormals: boolean;
  19188. /**
  19189. * Gets a boolean indicating if this manager supports morphing of tangents
  19190. */
  19191. readonly supportsTangents: boolean;
  19192. /**
  19193. * Gets the number of targets stored in this manager
  19194. */
  19195. readonly numTargets: number;
  19196. /**
  19197. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19198. */
  19199. readonly numInfluencers: number;
  19200. /**
  19201. * Gets the list of influences (one per target)
  19202. */
  19203. readonly influences: Float32Array;
  19204. /**
  19205. * Gets the active target at specified index. An active target is a target with an influence > 0
  19206. * @param index defines the index to check
  19207. * @returns the requested target
  19208. */
  19209. getActiveTarget(index: number): MorphTarget;
  19210. /**
  19211. * Gets the target at specified index
  19212. * @param index defines the index to check
  19213. * @returns the requested target
  19214. */
  19215. getTarget(index: number): MorphTarget;
  19216. /**
  19217. * Add a new target to this manager
  19218. * @param target defines the target to add
  19219. */
  19220. addTarget(target: MorphTarget): void;
  19221. /**
  19222. * Removes a target from the manager
  19223. * @param target defines the target to remove
  19224. */
  19225. removeTarget(target: MorphTarget): void;
  19226. /**
  19227. * Serializes the current manager into a Serialization object
  19228. * @returns the serialized object
  19229. */
  19230. serialize(): any;
  19231. private _syncActiveTargets;
  19232. /**
  19233. * Syncrhonize the targets with all the meshes using this morph target manager
  19234. */
  19235. synchronize(): void;
  19236. /**
  19237. * Creates a new MorphTargetManager from serialized data
  19238. * @param serializationObject defines the serialized data
  19239. * @param scene defines the hosting scene
  19240. * @returns the new MorphTargetManager
  19241. */
  19242. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19243. }
  19244. }
  19245. declare module "babylonjs/Meshes/groundMesh" {
  19246. import { Scene } from "babylonjs/scene";
  19247. import { Vector3 } from "babylonjs/Maths/math";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. /**
  19250. * Mesh representing the gorund
  19251. */
  19252. export class GroundMesh extends Mesh {
  19253. /** If octree should be generated */
  19254. generateOctree: boolean;
  19255. private _heightQuads;
  19256. /** @hidden */
  19257. _subdivisionsX: number;
  19258. /** @hidden */
  19259. _subdivisionsY: number;
  19260. /** @hidden */
  19261. _width: number;
  19262. /** @hidden */
  19263. _height: number;
  19264. /** @hidden */
  19265. _minX: number;
  19266. /** @hidden */
  19267. _maxX: number;
  19268. /** @hidden */
  19269. _minZ: number;
  19270. /** @hidden */
  19271. _maxZ: number;
  19272. constructor(name: string, scene: Scene);
  19273. /**
  19274. * "GroundMesh"
  19275. * @returns "GroundMesh"
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * The minimum of x and y subdivisions
  19280. */
  19281. readonly subdivisions: number;
  19282. /**
  19283. * X subdivisions
  19284. */
  19285. readonly subdivisionsX: number;
  19286. /**
  19287. * Y subdivisions
  19288. */
  19289. readonly subdivisionsY: number;
  19290. /**
  19291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19293. * @param chunksCount the number of subdivisions for x and y
  19294. * @param octreeBlocksSize (Default: 32)
  19295. */
  19296. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19297. /**
  19298. * Returns a height (y) value in the Worl system :
  19299. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19300. * @param x x coordinate
  19301. * @param z z coordinate
  19302. * @returns the ground y position if (x, z) are outside the ground surface.
  19303. */
  19304. getHeightAtCoordinates(x: number, z: number): number;
  19305. /**
  19306. * Returns a normalized vector (Vector3) orthogonal to the ground
  19307. * at the ground coordinates (x, z) expressed in the World system.
  19308. * @param x x coordinate
  19309. * @param z z coordinate
  19310. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19311. */
  19312. getNormalAtCoordinates(x: number, z: number): Vector3;
  19313. /**
  19314. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19315. * at the ground coordinates (x, z) expressed in the World system.
  19316. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19317. * @param x x coordinate
  19318. * @param z z coordinate
  19319. * @param ref vector to store the result
  19320. * @returns the GroundMesh.
  19321. */
  19322. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19323. /**
  19324. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19325. * if the ground has been updated.
  19326. * This can be used in the render loop.
  19327. * @returns the GroundMesh.
  19328. */
  19329. updateCoordinateHeights(): GroundMesh;
  19330. private _getFacetAt;
  19331. private _initHeightQuads;
  19332. private _computeHeightQuads;
  19333. /**
  19334. * Serializes this ground mesh
  19335. * @param serializationObject object to write serialization to
  19336. */
  19337. serialize(serializationObject: any): void;
  19338. /**
  19339. * Parses a serialized ground mesh
  19340. * @param parsedMesh the serialized mesh
  19341. * @param scene the scene to create the ground mesh in
  19342. * @returns the created ground mesh
  19343. */
  19344. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19345. }
  19346. }
  19347. declare module "babylonjs/Physics/physicsJoint" {
  19348. import { Vector3 } from "babylonjs/Maths/math";
  19349. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19350. /**
  19351. * Interface for Physics-Joint data
  19352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19353. */
  19354. export interface PhysicsJointData {
  19355. /**
  19356. * The main pivot of the joint
  19357. */
  19358. mainPivot?: Vector3;
  19359. /**
  19360. * The connected pivot of the joint
  19361. */
  19362. connectedPivot?: Vector3;
  19363. /**
  19364. * The main axis of the joint
  19365. */
  19366. mainAxis?: Vector3;
  19367. /**
  19368. * The connected axis of the joint
  19369. */
  19370. connectedAxis?: Vector3;
  19371. /**
  19372. * The collision of the joint
  19373. */
  19374. collision?: boolean;
  19375. /**
  19376. * Native Oimo/Cannon/Energy data
  19377. */
  19378. nativeParams?: any;
  19379. }
  19380. /**
  19381. * This is a holder class for the physics joint created by the physics plugin
  19382. * It holds a set of functions to control the underlying joint
  19383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19384. */
  19385. export class PhysicsJoint {
  19386. /**
  19387. * The type of the physics joint
  19388. */
  19389. type: number;
  19390. /**
  19391. * The data for the physics joint
  19392. */
  19393. jointData: PhysicsJointData;
  19394. private _physicsJoint;
  19395. protected _physicsPlugin: IPhysicsEnginePlugin;
  19396. /**
  19397. * Initializes the physics joint
  19398. * @param type The type of the physics joint
  19399. * @param jointData The data for the physics joint
  19400. */
  19401. constructor(
  19402. /**
  19403. * The type of the physics joint
  19404. */
  19405. type: number,
  19406. /**
  19407. * The data for the physics joint
  19408. */
  19409. jointData: PhysicsJointData);
  19410. /**
  19411. * Gets the physics joint
  19412. */
  19413. /**
  19414. * Sets the physics joint
  19415. */
  19416. physicsJoint: any;
  19417. /**
  19418. * Sets the physics plugin
  19419. */
  19420. physicsPlugin: IPhysicsEnginePlugin;
  19421. /**
  19422. * Execute a function that is physics-plugin specific.
  19423. * @param {Function} func the function that will be executed.
  19424. * It accepts two parameters: the physics world and the physics joint
  19425. */
  19426. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19427. /**
  19428. * Distance-Joint type
  19429. */
  19430. static DistanceJoint: number;
  19431. /**
  19432. * Hinge-Joint type
  19433. */
  19434. static HingeJoint: number;
  19435. /**
  19436. * Ball-and-Socket joint type
  19437. */
  19438. static BallAndSocketJoint: number;
  19439. /**
  19440. * Wheel-Joint type
  19441. */
  19442. static WheelJoint: number;
  19443. /**
  19444. * Slider-Joint type
  19445. */
  19446. static SliderJoint: number;
  19447. /**
  19448. * Prismatic-Joint type
  19449. */
  19450. static PrismaticJoint: number;
  19451. /**
  19452. * Universal-Joint type
  19453. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19454. */
  19455. static UniversalJoint: number;
  19456. /**
  19457. * Hinge-Joint 2 type
  19458. */
  19459. static Hinge2Joint: number;
  19460. /**
  19461. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19462. */
  19463. static PointToPointJoint: number;
  19464. /**
  19465. * Spring-Joint type
  19466. */
  19467. static SpringJoint: number;
  19468. /**
  19469. * Lock-Joint type
  19470. */
  19471. static LockJoint: number;
  19472. }
  19473. /**
  19474. * A class representing a physics distance joint
  19475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19476. */
  19477. export class DistanceJoint extends PhysicsJoint {
  19478. /**
  19479. *
  19480. * @param jointData The data for the Distance-Joint
  19481. */
  19482. constructor(jointData: DistanceJointData);
  19483. /**
  19484. * Update the predefined distance.
  19485. * @param maxDistance The maximum preferred distance
  19486. * @param minDistance The minimum preferred distance
  19487. */
  19488. updateDistance(maxDistance: number, minDistance?: number): void;
  19489. }
  19490. /**
  19491. * Represents a Motor-Enabled Joint
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19495. /**
  19496. * Initializes the Motor-Enabled Joint
  19497. * @param type The type of the joint
  19498. * @param jointData The physica joint data for the joint
  19499. */
  19500. constructor(type: number, jointData: PhysicsJointData);
  19501. /**
  19502. * Set the motor values.
  19503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19504. * @param force the force to apply
  19505. * @param maxForce max force for this motor.
  19506. */
  19507. setMotor(force?: number, maxForce?: number): void;
  19508. /**
  19509. * Set the motor's limits.
  19510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19511. * @param upperLimit The upper limit of the motor
  19512. * @param lowerLimit The lower limit of the motor
  19513. */
  19514. setLimit(upperLimit: number, lowerLimit?: number): void;
  19515. }
  19516. /**
  19517. * This class represents a single physics Hinge-Joint
  19518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19519. */
  19520. export class HingeJoint extends MotorEnabledJoint {
  19521. /**
  19522. * Initializes the Hinge-Joint
  19523. * @param jointData The joint data for the Hinge-Joint
  19524. */
  19525. constructor(jointData: PhysicsJointData);
  19526. /**
  19527. * Set the motor values.
  19528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19529. * @param {number} force the force to apply
  19530. * @param {number} maxForce max force for this motor.
  19531. */
  19532. setMotor(force?: number, maxForce?: number): void;
  19533. /**
  19534. * Set the motor's limits.
  19535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19536. * @param upperLimit The upper limit of the motor
  19537. * @param lowerLimit The lower limit of the motor
  19538. */
  19539. setLimit(upperLimit: number, lowerLimit?: number): void;
  19540. }
  19541. /**
  19542. * This class represents a dual hinge physics joint (same as wheel joint)
  19543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19544. */
  19545. export class Hinge2Joint extends MotorEnabledJoint {
  19546. /**
  19547. * Initializes the Hinge2-Joint
  19548. * @param jointData The joint data for the Hinge2-Joint
  19549. */
  19550. constructor(jointData: PhysicsJointData);
  19551. /**
  19552. * Set the motor values.
  19553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19554. * @param {number} targetSpeed the speed the motor is to reach
  19555. * @param {number} maxForce max force for this motor.
  19556. * @param {motorIndex} the motor's index, 0 or 1.
  19557. */
  19558. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19559. /**
  19560. * Set the motor limits.
  19561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19562. * @param {number} upperLimit the upper limit
  19563. * @param {number} lowerLimit lower limit
  19564. * @param {motorIndex} the motor's index, 0 or 1.
  19565. */
  19566. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19567. }
  19568. /**
  19569. * Interface for a motor enabled joint
  19570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19571. */
  19572. export interface IMotorEnabledJoint {
  19573. /**
  19574. * Physics joint
  19575. */
  19576. physicsJoint: any;
  19577. /**
  19578. * Sets the motor of the motor-enabled joint
  19579. * @param force The force of the motor
  19580. * @param maxForce The maximum force of the motor
  19581. * @param motorIndex The index of the motor
  19582. */
  19583. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19584. /**
  19585. * Sets the limit of the motor
  19586. * @param upperLimit The upper limit of the motor
  19587. * @param lowerLimit The lower limit of the motor
  19588. * @param motorIndex The index of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19591. }
  19592. /**
  19593. * Joint data for a Distance-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export interface DistanceJointData extends PhysicsJointData {
  19597. /**
  19598. * Max distance the 2 joint objects can be apart
  19599. */
  19600. maxDistance: number;
  19601. }
  19602. /**
  19603. * Joint data from a spring joint
  19604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19605. */
  19606. export interface SpringJointData extends PhysicsJointData {
  19607. /**
  19608. * Length of the spring
  19609. */
  19610. length: number;
  19611. /**
  19612. * Stiffness of the spring
  19613. */
  19614. stiffness: number;
  19615. /**
  19616. * Damping of the spring
  19617. */
  19618. damping: number;
  19619. /** this callback will be called when applying the force to the impostors. */
  19620. forceApplicationCallback: () => void;
  19621. }
  19622. }
  19623. declare module "babylonjs/Physics/IPhysicsEngine" {
  19624. import { Nullable } from "babylonjs/types";
  19625. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19627. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19628. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19629. /**
  19630. * Interface used to describe a physics joint
  19631. */
  19632. export interface PhysicsImpostorJoint {
  19633. /** Defines the main impostor to which the joint is linked */
  19634. mainImpostor: PhysicsImpostor;
  19635. /** Defines the impostor that is connected to the main impostor using this joint */
  19636. connectedImpostor: PhysicsImpostor;
  19637. /** Defines the joint itself */
  19638. joint: PhysicsJoint;
  19639. }
  19640. /** @hidden */
  19641. export interface IPhysicsEnginePlugin {
  19642. world: any;
  19643. name: string;
  19644. setGravity(gravity: Vector3): void;
  19645. setTimeStep(timeStep: number): void;
  19646. getTimeStep(): number;
  19647. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19651. removePhysicsBody(impostor: PhysicsImpostor): void;
  19652. generateJoint(joint: PhysicsImpostorJoint): void;
  19653. removeJoint(joint: PhysicsImpostorJoint): void;
  19654. isSupported(): boolean;
  19655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19657. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19659. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19662. getBodyMass(impostor: PhysicsImpostor): number;
  19663. getBodyFriction(impostor: PhysicsImpostor): number;
  19664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19665. getBodyRestitution(impostor: PhysicsImpostor): number;
  19666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19667. sleepBody(impostor: PhysicsImpostor): void;
  19668. wakeUpBody(impostor: PhysicsImpostor): void;
  19669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19670. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19671. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19672. getRadius(impostor: PhysicsImpostor): number;
  19673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19674. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19675. dispose(): void;
  19676. }
  19677. /**
  19678. * Interface used to define a physics engine
  19679. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export interface IPhysicsEngine {
  19682. /**
  19683. * Gets the gravity vector used by the simulation
  19684. */
  19685. gravity: Vector3;
  19686. /**
  19687. * Sets the gravity vector used by the simulation
  19688. * @param gravity defines the gravity vector to use
  19689. */
  19690. setGravity(gravity: Vector3): void;
  19691. /**
  19692. * Set the time step of the physics engine.
  19693. * Default is 1/60.
  19694. * To slow it down, enter 1/600 for example.
  19695. * To speed it up, 1/30
  19696. * @param newTimeStep the new timestep to apply to this world.
  19697. */
  19698. setTimeStep(newTimeStep: number): void;
  19699. /**
  19700. * Get the time step of the physics engine.
  19701. * @returns the current time step
  19702. */
  19703. getTimeStep(): number;
  19704. /**
  19705. * Release all resources
  19706. */
  19707. dispose(): void;
  19708. /**
  19709. * Gets the name of the current physics plugin
  19710. * @returns the name of the plugin
  19711. */
  19712. getPhysicsPluginName(): string;
  19713. /**
  19714. * Adding a new impostor for the impostor tracking.
  19715. * This will be done by the impostor itself.
  19716. * @param impostor the impostor to add
  19717. */
  19718. addImpostor(impostor: PhysicsImpostor): void;
  19719. /**
  19720. * Remove an impostor from the engine.
  19721. * This impostor and its mesh will not longer be updated by the physics engine.
  19722. * @param impostor the impostor to remove
  19723. */
  19724. removeImpostor(impostor: PhysicsImpostor): void;
  19725. /**
  19726. * Add a joint to the physics engine
  19727. * @param mainImpostor defines the main impostor to which the joint is added.
  19728. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19729. * @param joint defines the joint that will connect both impostors.
  19730. */
  19731. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19732. /**
  19733. * Removes a joint from the simulation
  19734. * @param mainImpostor defines the impostor used with the joint
  19735. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19736. * @param joint defines the joint to remove
  19737. */
  19738. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19739. /**
  19740. * Gets the current plugin used to run the simulation
  19741. * @returns current plugin
  19742. */
  19743. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19744. /**
  19745. * Gets the list of physic impostors
  19746. * @returns an array of PhysicsImpostor
  19747. */
  19748. getImpostors(): Array<PhysicsImpostor>;
  19749. /**
  19750. * Gets the impostor for a physics enabled object
  19751. * @param object defines the object impersonated by the impostor
  19752. * @returns the PhysicsImpostor or null if not found
  19753. */
  19754. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19755. /**
  19756. * Gets the impostor for a physics body object
  19757. * @param body defines physics body used by the impostor
  19758. * @returns the PhysicsImpostor or null if not found
  19759. */
  19760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19761. /**
  19762. * Called by the scene. No need to call it.
  19763. * @param delta defines the timespam between frames
  19764. */
  19765. _step(delta: number): void;
  19766. }
  19767. }
  19768. declare module "babylonjs/Physics/physicsImpostor" {
  19769. import { Nullable, IndicesArray } from "babylonjs/types";
  19770. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19773. import { Scene } from "babylonjs/scene";
  19774. import { Bone } from "babylonjs/Bones/bone";
  19775. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19776. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19777. /**
  19778. * The interface for the physics imposter parameters
  19779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19780. */
  19781. export interface PhysicsImpostorParameters {
  19782. /**
  19783. * The mass of the physics imposter
  19784. */
  19785. mass: number;
  19786. /**
  19787. * The friction of the physics imposter
  19788. */
  19789. friction?: number;
  19790. /**
  19791. * The coefficient of restitution of the physics imposter
  19792. */
  19793. restitution?: number;
  19794. /**
  19795. * The native options of the physics imposter
  19796. */
  19797. nativeOptions?: any;
  19798. /**
  19799. * Specifies if the parent should be ignored
  19800. */
  19801. ignoreParent?: boolean;
  19802. /**
  19803. * Specifies if bi-directional transformations should be disabled
  19804. */
  19805. disableBidirectionalTransformation?: boolean;
  19806. }
  19807. /**
  19808. * Interface for a physics-enabled object
  19809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19810. */
  19811. export interface IPhysicsEnabledObject {
  19812. /**
  19813. * The position of the physics-enabled object
  19814. */
  19815. position: Vector3;
  19816. /**
  19817. * The rotation of the physics-enabled object
  19818. */
  19819. rotationQuaternion: Nullable<Quaternion>;
  19820. /**
  19821. * The scale of the physics-enabled object
  19822. */
  19823. scaling: Vector3;
  19824. /**
  19825. * The rotation of the physics-enabled object
  19826. */
  19827. rotation?: Vector3;
  19828. /**
  19829. * The parent of the physics-enabled object
  19830. */
  19831. parent?: any;
  19832. /**
  19833. * The bounding info of the physics-enabled object
  19834. * @returns The bounding info of the physics-enabled object
  19835. */
  19836. getBoundingInfo(): BoundingInfo;
  19837. /**
  19838. * Computes the world matrix
  19839. * @param force Specifies if the world matrix should be computed by force
  19840. * @returns A world matrix
  19841. */
  19842. computeWorldMatrix(force: boolean): Matrix;
  19843. /**
  19844. * Gets the world matrix
  19845. * @returns A world matrix
  19846. */
  19847. getWorldMatrix?(): Matrix;
  19848. /**
  19849. * Gets the child meshes
  19850. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19851. * @returns An array of abstract meshes
  19852. */
  19853. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19854. /**
  19855. * Gets the vertex data
  19856. * @param kind The type of vertex data
  19857. * @returns A nullable array of numbers, or a float32 array
  19858. */
  19859. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19860. /**
  19861. * Gets the indices from the mesh
  19862. * @returns A nullable array of index arrays
  19863. */
  19864. getIndices?(): Nullable<IndicesArray>;
  19865. /**
  19866. * Gets the scene from the mesh
  19867. * @returns the indices array or null
  19868. */
  19869. getScene?(): Scene;
  19870. /**
  19871. * Gets the absolute position from the mesh
  19872. * @returns the absolute position
  19873. */
  19874. getAbsolutePosition(): Vector3;
  19875. /**
  19876. * Gets the absolute pivot point from the mesh
  19877. * @returns the absolute pivot point
  19878. */
  19879. getAbsolutePivotPoint(): Vector3;
  19880. /**
  19881. * Rotates the mesh
  19882. * @param axis The axis of rotation
  19883. * @param amount The amount of rotation
  19884. * @param space The space of the rotation
  19885. * @returns The rotation transform node
  19886. */
  19887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19888. /**
  19889. * Translates the mesh
  19890. * @param axis The axis of translation
  19891. * @param distance The distance of translation
  19892. * @param space The space of the translation
  19893. * @returns The transform node
  19894. */
  19895. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19896. /**
  19897. * Sets the absolute position of the mesh
  19898. * @param absolutePosition The absolute position of the mesh
  19899. * @returns The transform node
  19900. */
  19901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19902. /**
  19903. * Gets the class name of the mesh
  19904. * @returns The class name
  19905. */
  19906. getClassName(): string;
  19907. }
  19908. /**
  19909. * Represents a physics imposter
  19910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19911. */
  19912. export class PhysicsImpostor {
  19913. /**
  19914. * The physics-enabled object used as the physics imposter
  19915. */
  19916. object: IPhysicsEnabledObject;
  19917. /**
  19918. * The type of the physics imposter
  19919. */
  19920. type: number;
  19921. private _options;
  19922. private _scene?;
  19923. /**
  19924. * The default object size of the imposter
  19925. */
  19926. static DEFAULT_OBJECT_SIZE: Vector3;
  19927. /**
  19928. * The identity quaternion of the imposter
  19929. */
  19930. static IDENTITY_QUATERNION: Quaternion;
  19931. /** @hidden */
  19932. _pluginData: any;
  19933. private _physicsEngine;
  19934. private _physicsBody;
  19935. private _bodyUpdateRequired;
  19936. private _onBeforePhysicsStepCallbacks;
  19937. private _onAfterPhysicsStepCallbacks;
  19938. /** @hidden */
  19939. _onPhysicsCollideCallbacks: Array<{
  19940. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19941. otherImpostors: Array<PhysicsImpostor>;
  19942. }>;
  19943. private _deltaPosition;
  19944. private _deltaRotation;
  19945. private _deltaRotationConjugated;
  19946. private _parent;
  19947. private _isDisposed;
  19948. private static _tmpVecs;
  19949. private static _tmpQuat;
  19950. /**
  19951. * Specifies if the physics imposter is disposed
  19952. */
  19953. readonly isDisposed: boolean;
  19954. /**
  19955. * Gets the mass of the physics imposter
  19956. */
  19957. mass: number;
  19958. /**
  19959. * Gets the coefficient of friction
  19960. */
  19961. /**
  19962. * Sets the coefficient of friction
  19963. */
  19964. friction: number;
  19965. /**
  19966. * Gets the coefficient of restitution
  19967. */
  19968. /**
  19969. * Sets the coefficient of restitution
  19970. */
  19971. restitution: number;
  19972. /**
  19973. * The unique id of the physics imposter
  19974. * set by the physics engine when adding this impostor to the array
  19975. */
  19976. uniqueId: number;
  19977. private _joints;
  19978. /**
  19979. * Initializes the physics imposter
  19980. * @param object The physics-enabled object used as the physics imposter
  19981. * @param type The type of the physics imposter
  19982. * @param _options The options for the physics imposter
  19983. * @param _scene The Babylon scene
  19984. */
  19985. constructor(
  19986. /**
  19987. * The physics-enabled object used as the physics imposter
  19988. */
  19989. object: IPhysicsEnabledObject,
  19990. /**
  19991. * The type of the physics imposter
  19992. */
  19993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19994. /**
  19995. * This function will completly initialize this impostor.
  19996. * It will create a new body - but only if this mesh has no parent.
  19997. * If it has, this impostor will not be used other than to define the impostor
  19998. * of the child mesh.
  19999. * @hidden
  20000. */
  20001. _init(): void;
  20002. private _getPhysicsParent;
  20003. /**
  20004. * Should a new body be generated.
  20005. * @returns boolean specifying if body initialization is required
  20006. */
  20007. isBodyInitRequired(): boolean;
  20008. /**
  20009. * Sets the updated scaling
  20010. * @param updated Specifies if the scaling is updated
  20011. */
  20012. setScalingUpdated(): void;
  20013. /**
  20014. * Force a regeneration of this or the parent's impostor's body.
  20015. * Use under cautious - This will remove all joints already implemented.
  20016. */
  20017. forceUpdate(): void;
  20018. /**
  20019. * Gets the body that holds this impostor. Either its own, or its parent.
  20020. */
  20021. /**
  20022. * Set the physics body. Used mainly by the physics engine/plugin
  20023. */
  20024. physicsBody: any;
  20025. /**
  20026. * Get the parent of the physics imposter
  20027. * @returns Physics imposter or null
  20028. */
  20029. /**
  20030. * Sets the parent of the physics imposter
  20031. */
  20032. parent: Nullable<PhysicsImpostor>;
  20033. /**
  20034. * Resets the update flags
  20035. */
  20036. resetUpdateFlags(): void;
  20037. /**
  20038. * Gets the object extend size
  20039. * @returns the object extend size
  20040. */
  20041. getObjectExtendSize(): Vector3;
  20042. /**
  20043. * Gets the object center
  20044. * @returns The object center
  20045. */
  20046. getObjectCenter(): Vector3;
  20047. /**
  20048. * Get a specific parametes from the options parameter
  20049. * @param paramName The object parameter name
  20050. * @returns The object parameter
  20051. */
  20052. getParam(paramName: string): any;
  20053. /**
  20054. * Sets a specific parameter in the options given to the physics plugin
  20055. * @param paramName The parameter name
  20056. * @param value The value of the parameter
  20057. */
  20058. setParam(paramName: string, value: number): void;
  20059. /**
  20060. * Specifically change the body's mass option. Won't recreate the physics body object
  20061. * @param mass The mass of the physics imposter
  20062. */
  20063. setMass(mass: number): void;
  20064. /**
  20065. * Gets the linear velocity
  20066. * @returns linear velocity or null
  20067. */
  20068. getLinearVelocity(): Nullable<Vector3>;
  20069. /**
  20070. * Sets the linear velocity
  20071. * @param velocity linear velocity or null
  20072. */
  20073. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20074. /**
  20075. * Gets the angular velocity
  20076. * @returns angular velocity or null
  20077. */
  20078. getAngularVelocity(): Nullable<Vector3>;
  20079. /**
  20080. * Sets the angular velocity
  20081. * @param velocity The velocity or null
  20082. */
  20083. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20084. /**
  20085. * Execute a function with the physics plugin native code
  20086. * Provide a function the will have two variables - the world object and the physics body object
  20087. * @param func The function to execute with the physics plugin native code
  20088. */
  20089. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20090. /**
  20091. * Register a function that will be executed before the physics world is stepping forward
  20092. * @param func The function to execute before the physics world is stepped forward
  20093. */
  20094. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20095. /**
  20096. * Unregister a function that will be executed before the physics world is stepping forward
  20097. * @param func The function to execute before the physics world is stepped forward
  20098. */
  20099. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20100. /**
  20101. * Register a function that will be executed after the physics step
  20102. * @param func The function to execute after physics step
  20103. */
  20104. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20105. /**
  20106. * Unregisters a function that will be executed after the physics step
  20107. * @param func The function to execute after physics step
  20108. */
  20109. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20110. /**
  20111. * register a function that will be executed when this impostor collides against a different body
  20112. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20113. * @param func Callback that is executed on collision
  20114. */
  20115. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20116. /**
  20117. * Unregisters the physics imposter on contact
  20118. * @param collideAgainst The physics object to collide against
  20119. * @param func Callback to execute on collision
  20120. */
  20121. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20122. private _tmpQuat;
  20123. private _tmpQuat2;
  20124. /**
  20125. * Get the parent rotation
  20126. * @returns The parent rotation
  20127. */
  20128. getParentsRotation(): Quaternion;
  20129. /**
  20130. * this function is executed by the physics engine.
  20131. */
  20132. beforeStep: () => void;
  20133. /**
  20134. * this function is executed by the physics engine
  20135. */
  20136. afterStep: () => void;
  20137. /**
  20138. * Legacy collision detection event support
  20139. */
  20140. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20141. /**
  20142. * event and body object due to cannon's event-based architecture.
  20143. */
  20144. onCollide: (e: {
  20145. body: any;
  20146. }) => void;
  20147. /**
  20148. * Apply a force
  20149. * @param force The force to apply
  20150. * @param contactPoint The contact point for the force
  20151. * @returns The physics imposter
  20152. */
  20153. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20154. /**
  20155. * Apply an impulse
  20156. * @param force The impulse force
  20157. * @param contactPoint The contact point for the impulse force
  20158. * @returns The physics imposter
  20159. */
  20160. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20161. /**
  20162. * A help function to create a joint
  20163. * @param otherImpostor A physics imposter used to create a joint
  20164. * @param jointType The type of joint
  20165. * @param jointData The data for the joint
  20166. * @returns The physics imposter
  20167. */
  20168. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20169. /**
  20170. * Add a joint to this impostor with a different impostor
  20171. * @param otherImpostor A physics imposter used to add a joint
  20172. * @param joint The joint to add
  20173. * @returns The physics imposter
  20174. */
  20175. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20176. /**
  20177. * Will keep this body still, in a sleep mode.
  20178. * @returns the physics imposter
  20179. */
  20180. sleep(): PhysicsImpostor;
  20181. /**
  20182. * Wake the body up.
  20183. * @returns The physics imposter
  20184. */
  20185. wakeUp(): PhysicsImpostor;
  20186. /**
  20187. * Clones the physics imposter
  20188. * @param newObject The physics imposter clones to this physics-enabled object
  20189. * @returns A nullable physics imposter
  20190. */
  20191. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20192. /**
  20193. * Disposes the physics imposter
  20194. */
  20195. dispose(): void;
  20196. /**
  20197. * Sets the delta position
  20198. * @param position The delta position amount
  20199. */
  20200. setDeltaPosition(position: Vector3): void;
  20201. /**
  20202. * Sets the delta rotation
  20203. * @param rotation The delta rotation amount
  20204. */
  20205. setDeltaRotation(rotation: Quaternion): void;
  20206. /**
  20207. * Gets the box size of the physics imposter and stores the result in the input parameter
  20208. * @param result Stores the box size
  20209. * @returns The physics imposter
  20210. */
  20211. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20212. /**
  20213. * Gets the radius of the physics imposter
  20214. * @returns Radius of the physics imposter
  20215. */
  20216. getRadius(): number;
  20217. /**
  20218. * Sync a bone with this impostor
  20219. * @param bone The bone to sync to the impostor.
  20220. * @param boneMesh The mesh that the bone is influencing.
  20221. * @param jointPivot The pivot of the joint / bone in local space.
  20222. * @param distToJoint Optional distance from the impostor to the joint.
  20223. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20224. */
  20225. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20226. /**
  20227. * Sync impostor to a bone
  20228. * @param bone The bone that the impostor will be synced to.
  20229. * @param boneMesh The mesh that the bone is influencing.
  20230. * @param jointPivot The pivot of the joint / bone in local space.
  20231. * @param distToJoint Optional distance from the impostor to the joint.
  20232. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20233. * @param boneAxis Optional vector3 axis the bone is aligned with
  20234. */
  20235. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20236. /**
  20237. * No-Imposter type
  20238. */
  20239. static NoImpostor: number;
  20240. /**
  20241. * Sphere-Imposter type
  20242. */
  20243. static SphereImpostor: number;
  20244. /**
  20245. * Box-Imposter type
  20246. */
  20247. static BoxImpostor: number;
  20248. /**
  20249. * Plane-Imposter type
  20250. */
  20251. static PlaneImpostor: number;
  20252. /**
  20253. * Mesh-imposter type
  20254. */
  20255. static MeshImpostor: number;
  20256. /**
  20257. * Cylinder-Imposter type
  20258. */
  20259. static CylinderImpostor: number;
  20260. /**
  20261. * Particle-Imposter type
  20262. */
  20263. static ParticleImpostor: number;
  20264. /**
  20265. * Heightmap-Imposter type
  20266. */
  20267. static HeightmapImpostor: number;
  20268. }
  20269. }
  20270. declare module "babylonjs/Meshes/mesh" {
  20271. import { Observable } from "babylonjs/Misc/observable";
  20272. import { IAnimatable } from "babylonjs/Misc/tools";
  20273. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20274. import { Camera } from "babylonjs/Cameras/camera";
  20275. import { Scene } from "babylonjs/scene";
  20276. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20277. import { Engine } from "babylonjs/Engines/engine";
  20278. import { Node } from "babylonjs/node";
  20279. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20280. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20281. import { Buffer } from "babylonjs/Meshes/buffer";
  20282. import { Geometry } from "babylonjs/Meshes/geometry";
  20283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20285. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20286. import { Effect } from "babylonjs/Materials/effect";
  20287. import { Material } from "babylonjs/Materials/material";
  20288. import { Skeleton } from "babylonjs/Bones/skeleton";
  20289. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20290. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20291. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20292. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20293. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20295. /**
  20296. * Class used to represent a specific level of detail of a mesh
  20297. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20298. */
  20299. export class MeshLODLevel {
  20300. /** Defines the distance where this level should star being displayed */
  20301. distance: number;
  20302. /** Defines the mesh to use to render this level */
  20303. mesh: Nullable<Mesh>;
  20304. /**
  20305. * Creates a new LOD level
  20306. * @param distance defines the distance where this level should star being displayed
  20307. * @param mesh defines the mesh to use to render this level
  20308. */
  20309. constructor(
  20310. /** Defines the distance where this level should star being displayed */
  20311. distance: number,
  20312. /** Defines the mesh to use to render this level */
  20313. mesh: Nullable<Mesh>);
  20314. }
  20315. /**
  20316. * @hidden
  20317. **/
  20318. export class _CreationDataStorage {
  20319. closePath?: boolean;
  20320. closeArray?: boolean;
  20321. idx: number[];
  20322. dashSize: number;
  20323. gapSize: number;
  20324. path3D: Path3D;
  20325. pathArray: Vector3[][];
  20326. arc: number;
  20327. radius: number;
  20328. cap: number;
  20329. tessellation: number;
  20330. }
  20331. /**
  20332. * @hidden
  20333. **/
  20334. class _InstanceDataStorage {
  20335. visibleInstances: any;
  20336. renderIdForInstances: number[];
  20337. batchCache: _InstancesBatch;
  20338. instancesBufferSize: number;
  20339. instancesBuffer: Nullable<Buffer>;
  20340. instancesData: Float32Array;
  20341. overridenInstanceCount: number;
  20342. }
  20343. /**
  20344. * @hidden
  20345. **/
  20346. export class _InstancesBatch {
  20347. mustReturn: boolean;
  20348. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20349. renderSelf: boolean[];
  20350. }
  20351. /**
  20352. * Class used to represent renderable models
  20353. */
  20354. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20355. /**
  20356. * Mesh side orientation : usually the external or front surface
  20357. */
  20358. static readonly FRONTSIDE: number;
  20359. /**
  20360. * Mesh side orientation : usually the internal or back surface
  20361. */
  20362. static readonly BACKSIDE: number;
  20363. /**
  20364. * Mesh side orientation : both internal and external or front and back surfaces
  20365. */
  20366. static readonly DOUBLESIDE: number;
  20367. /**
  20368. * Mesh side orientation : by default, `FRONTSIDE`
  20369. */
  20370. static readonly DEFAULTSIDE: number;
  20371. /**
  20372. * Mesh cap setting : no cap
  20373. */
  20374. static readonly NO_CAP: number;
  20375. /**
  20376. * Mesh cap setting : one cap at the beginning of the mesh
  20377. */
  20378. static readonly CAP_START: number;
  20379. /**
  20380. * Mesh cap setting : one cap at the end of the mesh
  20381. */
  20382. static readonly CAP_END: number;
  20383. /**
  20384. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20385. */
  20386. static readonly CAP_ALL: number;
  20387. /**
  20388. * Gets the default side orientation.
  20389. * @param orientation the orientation to value to attempt to get
  20390. * @returns the default orientation
  20391. * @hidden
  20392. */
  20393. static _GetDefaultSideOrientation(orientation?: number): number;
  20394. private _onBeforeRenderObservable;
  20395. private _onBeforeBindObservable;
  20396. private _onAfterRenderObservable;
  20397. private _onBeforeDrawObservable;
  20398. /**
  20399. * An event triggered before rendering the mesh
  20400. */
  20401. readonly onBeforeRenderObservable: Observable<Mesh>;
  20402. /**
  20403. * An event triggered before binding the mesh
  20404. */
  20405. readonly onBeforeBindObservable: Observable<Mesh>;
  20406. /**
  20407. * An event triggered after rendering the mesh
  20408. */
  20409. readonly onAfterRenderObservable: Observable<Mesh>;
  20410. /**
  20411. * An event triggered before drawing the mesh
  20412. */
  20413. readonly onBeforeDrawObservable: Observable<Mesh>;
  20414. private _onBeforeDrawObserver;
  20415. /**
  20416. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20417. */
  20418. onBeforeDraw: () => void;
  20419. /**
  20420. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20421. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20422. */
  20423. delayLoadState: number;
  20424. /**
  20425. * Gets the list of instances created from this mesh
  20426. * it is not supposed to be modified manually.
  20427. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20428. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20429. */
  20430. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20431. /**
  20432. * Gets the file containing delay loading data for this mesh
  20433. */
  20434. delayLoadingFile: string;
  20435. /** @hidden */
  20436. _binaryInfo: any;
  20437. private _LODLevels;
  20438. /**
  20439. * User defined function used to change how LOD level selection is done
  20440. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20441. */
  20442. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20443. private _morphTargetManager;
  20444. /**
  20445. * Gets or sets the morph target manager
  20446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20447. */
  20448. morphTargetManager: Nullable<MorphTargetManager>;
  20449. /** @hidden */
  20450. _creationDataStorage: Nullable<_CreationDataStorage>;
  20451. /** @hidden */
  20452. _geometry: Nullable<Geometry>;
  20453. /** @hidden */
  20454. _delayInfo: Array<string>;
  20455. /** @hidden */
  20456. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20457. /** @hidden */
  20458. _instanceDataStorage: _InstanceDataStorage;
  20459. private _effectiveMaterial;
  20460. /** @hidden */
  20461. _shouldGenerateFlatShading: boolean;
  20462. private _preActivateId;
  20463. /** @hidden */
  20464. _originalBuilderSideOrientation: number;
  20465. /**
  20466. * Use this property to change the original side orientation defined at construction time
  20467. */
  20468. overrideMaterialSideOrientation: Nullable<number>;
  20469. private _areNormalsFrozen;
  20470. private _sourcePositions;
  20471. private _sourceNormals;
  20472. private _source;
  20473. private meshMap;
  20474. /**
  20475. * Gets the source mesh (the one used to clone this one from)
  20476. */
  20477. readonly source: Nullable<Mesh>;
  20478. /**
  20479. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20480. */
  20481. isUnIndexed: boolean;
  20482. /**
  20483. * @constructor
  20484. * @param name The value used by scene.getMeshByName() to do a lookup.
  20485. * @param scene The scene to add this mesh to.
  20486. * @param parent The parent of this mesh, if it has one
  20487. * @param source An optional Mesh from which geometry is shared, cloned.
  20488. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20489. * When false, achieved by calling a clone(), also passing False.
  20490. * This will make creation of children, recursive.
  20491. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20492. */
  20493. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20494. /**
  20495. * Gets the class name
  20496. * @returns the string "Mesh".
  20497. */
  20498. getClassName(): string;
  20499. /** @hidden */
  20500. readonly _isMesh: boolean;
  20501. /**
  20502. * Returns a description of this mesh
  20503. * @param fullDetails define if full details about this mesh must be used
  20504. * @returns a descriptive string representing this mesh
  20505. */
  20506. toString(fullDetails?: boolean): string;
  20507. /** @hidden */
  20508. _unBindEffect(): void;
  20509. /**
  20510. * Gets a boolean indicating if this mesh has LOD
  20511. */
  20512. readonly hasLODLevels: boolean;
  20513. /**
  20514. * Gets the list of MeshLODLevel associated with the current mesh
  20515. * @returns an array of MeshLODLevel
  20516. */
  20517. getLODLevels(): MeshLODLevel[];
  20518. private _sortLODLevels;
  20519. /**
  20520. * Add a mesh as LOD level triggered at the given distance.
  20521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20522. * @param distance The distance from the center of the object to show this level
  20523. * @param mesh The mesh to be added as LOD level (can be null)
  20524. * @return This mesh (for chaining)
  20525. */
  20526. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20527. /**
  20528. * Returns the LOD level mesh at the passed distance or null if not found.
  20529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20530. * @param distance The distance from the center of the object to show this level
  20531. * @returns a Mesh or `null`
  20532. */
  20533. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20534. /**
  20535. * Remove a mesh from the LOD array
  20536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20537. * @param mesh defines the mesh to be removed
  20538. * @return This mesh (for chaining)
  20539. */
  20540. removeLODLevel(mesh: Mesh): Mesh;
  20541. /**
  20542. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20544. * @param camera defines the camera to use to compute distance
  20545. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20546. * @return This mesh (for chaining)
  20547. */
  20548. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20549. /**
  20550. * Gets the mesh internal Geometry object
  20551. */
  20552. readonly geometry: Nullable<Geometry>;
  20553. /**
  20554. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20555. * @returns the total number of vertices
  20556. */
  20557. getTotalVertices(): number;
  20558. /**
  20559. * Returns the content of an associated vertex buffer
  20560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20561. * - VertexBuffer.PositionKind
  20562. * - VertexBuffer.UVKind
  20563. * - VertexBuffer.UV2Kind
  20564. * - VertexBuffer.UV3Kind
  20565. * - VertexBuffer.UV4Kind
  20566. * - VertexBuffer.UV5Kind
  20567. * - VertexBuffer.UV6Kind
  20568. * - VertexBuffer.ColorKind
  20569. * - VertexBuffer.MatricesIndicesKind
  20570. * - VertexBuffer.MatricesIndicesExtraKind
  20571. * - VertexBuffer.MatricesWeightsKind
  20572. * - VertexBuffer.MatricesWeightsExtraKind
  20573. * @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
  20574. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20575. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20576. */
  20577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20578. /**
  20579. * Returns the mesh VertexBuffer object from the requested `kind`
  20580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20581. * - VertexBuffer.PositionKind
  20582. * - VertexBuffer.UVKind
  20583. * - VertexBuffer.UV2Kind
  20584. * - VertexBuffer.UV3Kind
  20585. * - VertexBuffer.UV4Kind
  20586. * - VertexBuffer.UV5Kind
  20587. * - VertexBuffer.UV6Kind
  20588. * - VertexBuffer.ColorKind
  20589. * - VertexBuffer.MatricesIndicesKind
  20590. * - VertexBuffer.MatricesIndicesExtraKind
  20591. * - VertexBuffer.MatricesWeightsKind
  20592. * - VertexBuffer.MatricesWeightsExtraKind
  20593. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20594. */
  20595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20596. /**
  20597. * Tests if a specific vertex buffer is associated with this mesh
  20598. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20599. * - VertexBuffer.PositionKind
  20600. * - VertexBuffer.UVKind
  20601. * - VertexBuffer.UV2Kind
  20602. * - VertexBuffer.UV3Kind
  20603. * - VertexBuffer.UV4Kind
  20604. * - VertexBuffer.UV5Kind
  20605. * - VertexBuffer.UV6Kind
  20606. * - VertexBuffer.ColorKind
  20607. * - VertexBuffer.MatricesIndicesKind
  20608. * - VertexBuffer.MatricesIndicesExtraKind
  20609. * - VertexBuffer.MatricesWeightsKind
  20610. * - VertexBuffer.MatricesWeightsExtraKind
  20611. * @returns a boolean
  20612. */
  20613. isVerticesDataPresent(kind: string): boolean;
  20614. /**
  20615. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20616. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20617. * - VertexBuffer.PositionKind
  20618. * - VertexBuffer.UVKind
  20619. * - VertexBuffer.UV2Kind
  20620. * - VertexBuffer.UV3Kind
  20621. * - VertexBuffer.UV4Kind
  20622. * - VertexBuffer.UV5Kind
  20623. * - VertexBuffer.UV6Kind
  20624. * - VertexBuffer.ColorKind
  20625. * - VertexBuffer.MatricesIndicesKind
  20626. * - VertexBuffer.MatricesIndicesExtraKind
  20627. * - VertexBuffer.MatricesWeightsKind
  20628. * - VertexBuffer.MatricesWeightsExtraKind
  20629. * @returns a boolean
  20630. */
  20631. isVertexBufferUpdatable(kind: string): boolean;
  20632. /**
  20633. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20634. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20635. * - VertexBuffer.PositionKind
  20636. * - VertexBuffer.UVKind
  20637. * - VertexBuffer.UV2Kind
  20638. * - VertexBuffer.UV3Kind
  20639. * - VertexBuffer.UV4Kind
  20640. * - VertexBuffer.UV5Kind
  20641. * - VertexBuffer.UV6Kind
  20642. * - VertexBuffer.ColorKind
  20643. * - VertexBuffer.MatricesIndicesKind
  20644. * - VertexBuffer.MatricesIndicesExtraKind
  20645. * - VertexBuffer.MatricesWeightsKind
  20646. * - VertexBuffer.MatricesWeightsExtraKind
  20647. * @returns an array of strings
  20648. */
  20649. getVerticesDataKinds(): string[];
  20650. /**
  20651. * Returns a positive integer : the total number of indices in this mesh geometry.
  20652. * @returns the numner of indices or zero if the mesh has no geometry.
  20653. */
  20654. getTotalIndices(): number;
  20655. /**
  20656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20657. * @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.
  20658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20659. * @returns the indices array or an empty array if the mesh has no geometry
  20660. */
  20661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20662. readonly isBlocked: boolean;
  20663. /**
  20664. * Determine if the current mesh is ready to be rendered
  20665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20667. * @returns true if all associated assets are ready (material, textures, shaders)
  20668. */
  20669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20670. /**
  20671. * 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.
  20672. */
  20673. readonly areNormalsFrozen: boolean;
  20674. /**
  20675. * 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.
  20676. * @returns the current mesh
  20677. */
  20678. freezeNormals(): Mesh;
  20679. /**
  20680. * 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
  20681. * @returns the current mesh
  20682. */
  20683. unfreezeNormals(): Mesh;
  20684. /**
  20685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20686. */
  20687. overridenInstanceCount: number;
  20688. /** @hidden */
  20689. _preActivate(): Mesh;
  20690. /** @hidden */
  20691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20692. /** @hidden */
  20693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20694. /**
  20695. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20696. * This means the mesh underlying bounding box and sphere are recomputed.
  20697. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20698. * @returns the current mesh
  20699. */
  20700. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20701. /** @hidden */
  20702. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20703. /**
  20704. * This function will subdivide the mesh into multiple submeshes
  20705. * @param count defines the expected number of submeshes
  20706. */
  20707. subdivide(count: number): void;
  20708. /**
  20709. * Copy a FloatArray into a specific associated vertex buffer
  20710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @param data defines the data source
  20724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20725. * @param stride defines the data stride size (can be null)
  20726. * @returns the current mesh
  20727. */
  20728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20729. /**
  20730. * Flags an associated vertex buffer as updatable
  20731. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20732. * - VertexBuffer.PositionKind
  20733. * - VertexBuffer.UVKind
  20734. * - VertexBuffer.UV2Kind
  20735. * - VertexBuffer.UV3Kind
  20736. * - VertexBuffer.UV4Kind
  20737. * - VertexBuffer.UV5Kind
  20738. * - VertexBuffer.UV6Kind
  20739. * - VertexBuffer.ColorKind
  20740. * - VertexBuffer.MatricesIndicesKind
  20741. * - VertexBuffer.MatricesIndicesExtraKind
  20742. * - VertexBuffer.MatricesWeightsKind
  20743. * - VertexBuffer.MatricesWeightsExtraKind
  20744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20745. */
  20746. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20747. /**
  20748. * Sets the mesh global Vertex Buffer
  20749. * @param buffer defines the buffer to use
  20750. * @returns the current mesh
  20751. */
  20752. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20753. /**
  20754. * Update a specific associated vertex buffer
  20755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20756. * - VertexBuffer.PositionKind
  20757. * - VertexBuffer.UVKind
  20758. * - VertexBuffer.UV2Kind
  20759. * - VertexBuffer.UV3Kind
  20760. * - VertexBuffer.UV4Kind
  20761. * - VertexBuffer.UV5Kind
  20762. * - VertexBuffer.UV6Kind
  20763. * - VertexBuffer.ColorKind
  20764. * - VertexBuffer.MatricesIndicesKind
  20765. * - VertexBuffer.MatricesIndicesExtraKind
  20766. * - VertexBuffer.MatricesWeightsKind
  20767. * - VertexBuffer.MatricesWeightsExtraKind
  20768. * @param data defines the data source
  20769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20770. * @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)
  20771. * @returns the current mesh
  20772. */
  20773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20774. /**
  20775. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20777. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20778. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20779. * @returns the current mesh
  20780. */
  20781. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20782. /**
  20783. * Creates a un-shared specific occurence of the geometry for the mesh.
  20784. * @returns the current mesh
  20785. */
  20786. makeGeometryUnique(): Mesh;
  20787. /**
  20788. * Set the index buffer of this mesh
  20789. * @param indices defines the source data
  20790. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20791. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20792. * @returns the current mesh
  20793. */
  20794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20795. /**
  20796. * Update the current index buffer
  20797. * @param indices defines the source data
  20798. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20799. * @returns the current mesh
  20800. */
  20801. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20802. /**
  20803. * Invert the geometry to move from a right handed system to a left handed one.
  20804. * @returns the current mesh
  20805. */
  20806. toLeftHanded(): Mesh;
  20807. /** @hidden */
  20808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20809. /** @hidden */
  20810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20811. /**
  20812. * Registers for this mesh a javascript function called just before the rendering process
  20813. * @param func defines the function to call before rendering this mesh
  20814. * @returns the current mesh
  20815. */
  20816. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20817. /**
  20818. * Disposes a previously registered javascript function called before the rendering
  20819. * @param func defines the function to remove
  20820. * @returns the current mesh
  20821. */
  20822. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20823. /**
  20824. * Registers for this mesh a javascript function called just after the rendering is complete
  20825. * @param func defines the function to call after rendering this mesh
  20826. * @returns the current mesh
  20827. */
  20828. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20829. /**
  20830. * Disposes a previously registered javascript function called after the rendering.
  20831. * @param func defines the function to remove
  20832. * @returns the current mesh
  20833. */
  20834. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20835. /** @hidden */
  20836. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20837. /** @hidden */
  20838. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20839. /** @hidden */
  20840. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20841. /**
  20842. * 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
  20843. * @param subMesh defines the subMesh to render
  20844. * @param enableAlphaMode defines if alpha mode can be changed
  20845. * @returns the current mesh
  20846. */
  20847. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20848. private _onBeforeDraw;
  20849. /**
  20850. * Renormalize the mesh and patch it up if there are no weights
  20851. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20852. * However in the case of zero weights then we set just a single influence to 1.
  20853. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20854. */
  20855. cleanMatrixWeights(): void;
  20856. private normalizeSkinFourWeights;
  20857. private normalizeSkinWeightsAndExtra;
  20858. /**
  20859. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20860. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20861. * the user know there was an issue with importing the mesh
  20862. * @returns a validation object with skinned, valid and report string
  20863. */
  20864. validateSkinning(): {
  20865. skinned: boolean;
  20866. valid: boolean;
  20867. report: string;
  20868. };
  20869. /** @hidden */
  20870. _checkDelayState(): Mesh;
  20871. private _queueLoad;
  20872. /**
  20873. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20874. * A mesh is in the frustum if its bounding box intersects the frustum
  20875. * @param frustumPlanes defines the frustum to test
  20876. * @returns true if the mesh is in the frustum planes
  20877. */
  20878. isInFrustum(frustumPlanes: Plane[]): boolean;
  20879. /**
  20880. * Sets the mesh material by the material or multiMaterial `id` property
  20881. * @param id is a string identifying the material or the multiMaterial
  20882. * @returns the current mesh
  20883. */
  20884. setMaterialByID(id: string): Mesh;
  20885. /**
  20886. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20887. * @returns an array of IAnimatable
  20888. */
  20889. getAnimatables(): IAnimatable[];
  20890. /**
  20891. * Modifies the mesh geometry according to the passed transformation matrix.
  20892. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20893. * The mesh normals are modified using the same transformation.
  20894. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20895. * @param transform defines the transform matrix to use
  20896. * @see http://doc.babylonjs.com/resources/baking_transformations
  20897. * @returns the current mesh
  20898. */
  20899. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20900. /**
  20901. * Modifies the mesh geometry according to its own current World Matrix.
  20902. * The mesh World Matrix is then reset.
  20903. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20904. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20905. * @see http://doc.babylonjs.com/resources/baking_transformations
  20906. * @returns the current mesh
  20907. */
  20908. bakeCurrentTransformIntoVertices(): Mesh;
  20909. /** @hidden */
  20910. readonly _positions: Nullable<Vector3[]>;
  20911. /** @hidden */
  20912. _resetPointsArrayCache(): Mesh;
  20913. /** @hidden */
  20914. _generatePointsArray(): boolean;
  20915. /**
  20916. * Returns a new Mesh object generated from the current mesh properties.
  20917. * This method must not get confused with createInstance()
  20918. * @param name is a string, the name given to the new mesh
  20919. * @param newParent can be any Node object (default `null`)
  20920. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20921. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20922. * @returns a new mesh
  20923. */
  20924. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20925. /**
  20926. * Releases resources associated with this mesh.
  20927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20929. */
  20930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20931. /**
  20932. * Modifies the mesh geometry according to a displacement map.
  20933. * 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.
  20934. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20935. * @param url is a string, the URL from the image file is to be downloaded.
  20936. * @param minHeight is the lower limit of the displacement.
  20937. * @param maxHeight is the upper limit of the displacement.
  20938. * @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.
  20939. * @param uvOffset is an optional vector2 used to offset UV.
  20940. * @param uvScale is an optional vector2 used to scale UV.
  20941. * @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.
  20942. * @returns the Mesh.
  20943. */
  20944. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20945. /**
  20946. * Modifies the mesh geometry according to a displacementMap buffer.
  20947. * 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.
  20948. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20949. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20950. * @param heightMapWidth is the width of the buffer image.
  20951. * @param heightMapHeight is the height of the buffer image.
  20952. * @param minHeight is the lower limit of the displacement.
  20953. * @param maxHeight is the upper limit of the displacement.
  20954. * @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.
  20955. * @param uvOffset is an optional vector2 used to offset UV.
  20956. * @param uvScale is an optional vector2 used to scale UV.
  20957. * @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.
  20958. * @returns the Mesh.
  20959. */
  20960. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20961. /**
  20962. * Modify the mesh to get a flat shading rendering.
  20963. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20964. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20965. * @returns current mesh
  20966. */
  20967. convertToFlatShadedMesh(): Mesh;
  20968. /**
  20969. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20970. * In other words, more vertices, no more indices and a single bigger VBO.
  20971. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20972. * @returns current mesh
  20973. */
  20974. convertToUnIndexedMesh(): Mesh;
  20975. /**
  20976. * Inverses facet orientations.
  20977. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20978. * @param flipNormals will also inverts the normals
  20979. * @returns current mesh
  20980. */
  20981. flipFaces(flipNormals?: boolean): Mesh;
  20982. /** @hidden */
  20983. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20984. /** @hidden */
  20985. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20986. /**
  20987. * Creates a new InstancedMesh object from the mesh model.
  20988. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20989. * @param name defines the name of the new instance
  20990. * @returns a new InstancedMesh
  20991. */
  20992. createInstance(name: string): InstancedMesh;
  20993. /**
  20994. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20995. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20996. * @returns the current mesh
  20997. */
  20998. synchronizeInstances(): Mesh;
  20999. /**
  21000. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21001. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21002. * This should be used together with the simplification to avoid disappearing triangles.
  21003. * @param successCallback an optional success callback to be called after the optimization finished.
  21004. * @returns the current mesh
  21005. */
  21006. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21007. /**
  21008. * Serialize current mesh
  21009. * @param serializationObject defines the object which will receive the serialization data
  21010. */
  21011. serialize(serializationObject: any): void;
  21012. /** @hidden */
  21013. _syncGeometryWithMorphTargetManager(): void;
  21014. /** @hidden */
  21015. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21016. /**
  21017. * Returns a new Mesh object parsed from the source provided.
  21018. * @param parsedMesh is the source
  21019. * @param scene defines the hosting scene
  21020. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21021. * @returns a new Mesh
  21022. */
  21023. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21024. /**
  21025. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21026. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21027. * @param name defines the name of the mesh to create
  21028. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21029. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21030. * @param closePath creates a seam between the first and the last points of each path of the path array
  21031. * @param offset is taken in account only if the `pathArray` is containing a single path
  21032. * @param scene defines the hosting scene
  21033. * @param updatable defines if the mesh must be flagged as updatable
  21034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21035. * @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)
  21036. * @returns a new Mesh
  21037. */
  21038. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21039. /**
  21040. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21041. * @param name defines the name of the mesh to create
  21042. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21043. * @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
  21044. * @param scene defines the hosting scene
  21045. * @param updatable defines if the mesh must be flagged as updatable
  21046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21047. * @returns a new Mesh
  21048. */
  21049. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21050. /**
  21051. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21052. * @param name defines the name of the mesh to create
  21053. * @param size sets the size (float) of each box side (default 1)
  21054. * @param scene defines the hosting scene
  21055. * @param updatable defines if the mesh must be flagged as updatable
  21056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21057. * @returns a new Mesh
  21058. */
  21059. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21060. /**
  21061. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21062. * @param name defines the name of the mesh to create
  21063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21065. * @param scene defines the hosting scene
  21066. * @param updatable defines if the mesh must be flagged as updatable
  21067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21068. * @returns a new Mesh
  21069. */
  21070. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21071. /**
  21072. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21073. * @param name defines the name of the mesh to create
  21074. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21075. * @param diameterTop set the top cap diameter (floats, default 1)
  21076. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21077. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21078. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21079. * @param scene defines the hosting scene
  21080. * @param updatable defines if the mesh must be flagged as updatable
  21081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21082. * @returns a new Mesh
  21083. */
  21084. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21085. /**
  21086. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21087. * @param name defines the name of the mesh to create
  21088. * @param diameter sets the diameter size (float) of the torus (default 1)
  21089. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21090. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21091. * @param scene defines the hosting scene
  21092. * @param updatable defines if the mesh must be flagged as updatable
  21093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21094. * @returns a new Mesh
  21095. */
  21096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21097. /**
  21098. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21099. * @param name defines the name of the mesh to create
  21100. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21101. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21102. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21103. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21104. * @param p the number of windings on X axis (positive integers, default 2)
  21105. * @param q the number of windings on Y axis (positive integers, default 3)
  21106. * @param scene defines the hosting scene
  21107. * @param updatable defines if the mesh must be flagged as updatable
  21108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21109. * @returns a new Mesh
  21110. */
  21111. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21112. /**
  21113. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21114. * @param name defines the name of the mesh to create
  21115. * @param points is an array successive Vector3
  21116. * @param scene defines the hosting scene
  21117. * @param updatable defines if the mesh must be flagged as updatable
  21118. * @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).
  21119. * @returns a new Mesh
  21120. */
  21121. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21122. /**
  21123. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21124. * @param name defines the name of the mesh to create
  21125. * @param points is an array successive Vector3
  21126. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21127. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21128. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21129. * @param scene defines the hosting scene
  21130. * @param updatable defines if the mesh must be flagged as updatable
  21131. * @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)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21135. /**
  21136. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21138. * 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.
  21139. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21141. * Remember you can only change the shape positions, not their number when updating a polygon.
  21142. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21143. * @param name defines the name of the mesh to create
  21144. * @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
  21145. * @param scene defines the hosting scene
  21146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21147. * @param updatable defines if the mesh must be flagged as updatable
  21148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21149. * @param earcutInjection can be used to inject your own earcut reference
  21150. * @returns a new Mesh
  21151. */
  21152. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21153. /**
  21154. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21156. * @param name defines the name of the mesh to create
  21157. * @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
  21158. * @param depth defines the height of extrusion
  21159. * @param scene defines the hosting scene
  21160. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21161. * @param updatable defines if the mesh must be flagged as updatable
  21162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21163. * @param earcutInjection can be used to inject your own earcut reference
  21164. * @returns a new Mesh
  21165. */
  21166. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21167. /**
  21168. * Creates an extruded shape mesh.
  21169. * 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
  21170. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21172. * @param name defines the name of the mesh to create
  21173. * @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
  21174. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21175. * @param scale is the value to scale the shape
  21176. * @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
  21177. * @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
  21178. * @param scene defines the hosting scene
  21179. * @param updatable defines if the mesh must be flagged as updatable
  21180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21181. * @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)
  21182. * @returns a new Mesh
  21183. */
  21184. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21185. /**
  21186. * Creates an custom extruded shape mesh.
  21187. * The custom extrusion is a parametric shape.
  21188. * It has no predefined shape. Its final shape will depend on the input parameters.
  21189. * Please consider using the same method from the MeshBuilder class instead
  21190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21191. * @param name defines the name of the mesh to create
  21192. * @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
  21193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21194. * @param scaleFunction is a custom Javascript function called on each path point
  21195. * @param rotationFunction is a custom Javascript function called on each path point
  21196. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21197. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21198. * @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
  21199. * @param scene defines the hosting scene
  21200. * @param updatable defines if the mesh must be flagged as updatable
  21201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21202. * @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)
  21203. * @returns a new Mesh
  21204. */
  21205. 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;
  21206. /**
  21207. * Creates lathe mesh.
  21208. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21209. * Please consider using the same method from the MeshBuilder class instead
  21210. * @param name defines the name of the mesh to create
  21211. * @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
  21212. * @param radius is the radius value of the lathe
  21213. * @param tessellation is the side number of the lathe.
  21214. * @param scene defines the hosting scene
  21215. * @param updatable defines if the mesh must be flagged as updatable
  21216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21217. * @returns a new Mesh
  21218. */
  21219. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21220. /**
  21221. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21222. * @param name defines the name of the mesh to create
  21223. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21224. * @param scene defines the hosting scene
  21225. * @param updatable defines if the mesh must be flagged as updatable
  21226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21227. * @returns a new Mesh
  21228. */
  21229. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21230. /**
  21231. * Creates a ground mesh.
  21232. * Please consider using the same method from the MeshBuilder class instead
  21233. * @param name defines the name of the mesh to create
  21234. * @param width set the width of the ground
  21235. * @param height set the height of the ground
  21236. * @param subdivisions sets the number of subdivisions per side
  21237. * @param scene defines the hosting scene
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @returns a new Mesh
  21240. */
  21241. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21242. /**
  21243. * Creates a tiled ground mesh.
  21244. * Please consider using the same method from the MeshBuilder class instead
  21245. * @param name defines the name of the mesh to create
  21246. * @param xmin set the ground minimum X coordinate
  21247. * @param zmin set the ground minimum Y coordinate
  21248. * @param xmax set the ground maximum X coordinate
  21249. * @param zmax set the ground maximum Z coordinate
  21250. * @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
  21251. * @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
  21252. * @param scene defines the hosting scene
  21253. * @param updatable defines if the mesh must be flagged as updatable
  21254. * @returns a new Mesh
  21255. */
  21256. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21257. w: number;
  21258. h: number;
  21259. }, precision: {
  21260. w: number;
  21261. h: number;
  21262. }, scene: Scene, updatable?: boolean): Mesh;
  21263. /**
  21264. * Creates a ground mesh from a height map.
  21265. * Please consider using the same method from the MeshBuilder class instead
  21266. * @see http://doc.babylonjs.com/babylon101/height_map
  21267. * @param name defines the name of the mesh to create
  21268. * @param url sets the URL of the height map image resource
  21269. * @param width set the ground width size
  21270. * @param height set the ground height size
  21271. * @param subdivisions sets the number of subdivision per side
  21272. * @param minHeight is the minimum altitude on the ground
  21273. * @param maxHeight is the maximum altitude on the ground
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21277. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21278. * @returns a new Mesh
  21279. */
  21280. 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;
  21281. /**
  21282. * Creates a tube mesh.
  21283. * The tube is a parametric shape.
  21284. * It has no predefined shape. Its final shape will depend on the input parameters.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21287. * @param name defines the name of the mesh to create
  21288. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21289. * @param radius sets the tube radius size
  21290. * @param tessellation is the number of sides on the tubular surface
  21291. * @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
  21292. * @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
  21293. * @param scene defines the hosting scene
  21294. * @param updatable defines if the mesh must be flagged as updatable
  21295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21296. * @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)
  21297. * @returns a new Mesh
  21298. */
  21299. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21300. (i: number, distance: number): number;
  21301. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21302. /**
  21303. * Creates a polyhedron mesh.
  21304. * Please consider using the same method from the MeshBuilder class instead.
  21305. * * 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
  21306. * * The parameter `size` (positive float, default 1) sets the polygon size
  21307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21308. * * 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`
  21309. * * 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
  21310. * * 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)`)
  21311. * * 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
  21312. * * 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
  21313. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21314. * * If you create a double-sided mesh, you can choose what parts of 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
  21315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21316. * @param name defines the name of the mesh to create
  21317. * @param options defines the options used to create the mesh
  21318. * @param scene defines the hosting scene
  21319. * @returns a new Mesh
  21320. */
  21321. static CreatePolyhedron(name: string, options: {
  21322. type?: number;
  21323. size?: number;
  21324. sizeX?: number;
  21325. sizeY?: number;
  21326. sizeZ?: number;
  21327. custom?: any;
  21328. faceUV?: Vector4[];
  21329. faceColors?: Color4[];
  21330. updatable?: boolean;
  21331. sideOrientation?: number;
  21332. }, scene: Scene): Mesh;
  21333. /**
  21334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21336. * * 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`)
  21337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21338. * * 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
  21339. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21340. * * If you create a double-sided mesh, you can choose what parts of 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
  21341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21342. * @param name defines the name of the mesh
  21343. * @param options defines the options used to create the mesh
  21344. * @param scene defines the hosting scene
  21345. * @returns a new Mesh
  21346. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21347. */
  21348. static CreateIcoSphere(name: string, options: {
  21349. radius?: number;
  21350. flat?: boolean;
  21351. subdivisions?: number;
  21352. sideOrientation?: number;
  21353. updatable?: boolean;
  21354. }, scene: Scene): Mesh;
  21355. /**
  21356. * Creates a decal mesh.
  21357. * Please consider using the same method from the MeshBuilder class instead.
  21358. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21359. * @param name defines the name of the mesh
  21360. * @param sourceMesh defines the mesh receiving the decal
  21361. * @param position sets the position of the decal in world coordinates
  21362. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21363. * @param size sets the decal scaling
  21364. * @param angle sets the angle to rotate the decal
  21365. * @returns a new Mesh
  21366. */
  21367. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21368. /**
  21369. * Prepare internal position array for software CPU skinning
  21370. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21371. */
  21372. setPositionsForCPUSkinning(): Float32Array;
  21373. /**
  21374. * Prepare internal normal array for software CPU skinning
  21375. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21376. */
  21377. setNormalsForCPUSkinning(): Float32Array;
  21378. /**
  21379. * Updates the vertex buffer by applying transformation from the bones
  21380. * @param skeleton defines the skeleton to apply to current mesh
  21381. * @returns the current mesh
  21382. */
  21383. applySkeleton(skeleton: Skeleton): Mesh;
  21384. /**
  21385. * 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
  21386. * @param meshes defines the list of meshes to scan
  21387. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21388. */
  21389. static MinMax(meshes: AbstractMesh[]): {
  21390. min: Vector3;
  21391. max: Vector3;
  21392. };
  21393. /**
  21394. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21395. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21396. * @returns a vector3
  21397. */
  21398. static Center(meshesOrMinMaxVector: {
  21399. min: Vector3;
  21400. max: Vector3;
  21401. } | AbstractMesh[]): Vector3;
  21402. /**
  21403. * Merge the array of meshes into a single mesh for performance reasons.
  21404. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21405. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21406. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21407. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21408. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21409. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21410. * @returns a new mesh
  21411. */
  21412. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21413. /** @hidden */
  21414. addInstance(instance: InstancedMesh): void;
  21415. /** @hidden */
  21416. removeInstance(instance: InstancedMesh): void;
  21417. }
  21418. }
  21419. declare module "babylonjs/Materials/material" {
  21420. import { IAnimatable } from "babylonjs/Misc/tools";
  21421. import { SmartArray } from "babylonjs/Misc/smartArray";
  21422. import { Observable } from "babylonjs/Misc/observable";
  21423. import { Nullable } from "babylonjs/types";
  21424. import { Scene } from "babylonjs/scene";
  21425. import { Matrix } from "babylonjs/Maths/math";
  21426. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21428. import { Mesh } from "babylonjs/Meshes/mesh";
  21429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21430. import { Effect } from "babylonjs/Materials/effect";
  21431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21434. import { Animation } from "babylonjs/Animations/animation";
  21435. /**
  21436. * Base class for the main features of a material in Babylon.js
  21437. */
  21438. export class Material implements IAnimatable {
  21439. /**
  21440. * Returns the triangle fill mode
  21441. */
  21442. static readonly TriangleFillMode: number;
  21443. /**
  21444. * Returns the wireframe mode
  21445. */
  21446. static readonly WireFrameFillMode: number;
  21447. /**
  21448. * Returns the point fill mode
  21449. */
  21450. static readonly PointFillMode: number;
  21451. /**
  21452. * Returns the point list draw mode
  21453. */
  21454. static readonly PointListDrawMode: number;
  21455. /**
  21456. * Returns the line list draw mode
  21457. */
  21458. static readonly LineListDrawMode: number;
  21459. /**
  21460. * Returns the line loop draw mode
  21461. */
  21462. static readonly LineLoopDrawMode: number;
  21463. /**
  21464. * Returns the line strip draw mode
  21465. */
  21466. static readonly LineStripDrawMode: number;
  21467. /**
  21468. * Returns the triangle strip draw mode
  21469. */
  21470. static readonly TriangleStripDrawMode: number;
  21471. /**
  21472. * Returns the triangle fan draw mode
  21473. */
  21474. static readonly TriangleFanDrawMode: number;
  21475. /**
  21476. * Stores the clock-wise side orientation
  21477. */
  21478. static readonly ClockWiseSideOrientation: number;
  21479. /**
  21480. * Stores the counter clock-wise side orientation
  21481. */
  21482. static readonly CounterClockWiseSideOrientation: number;
  21483. /**
  21484. * The dirty texture flag value
  21485. */
  21486. static readonly TextureDirtyFlag: number;
  21487. /**
  21488. * The dirty light flag value
  21489. */
  21490. static readonly LightDirtyFlag: number;
  21491. /**
  21492. * The dirty fresnel flag value
  21493. */
  21494. static readonly FresnelDirtyFlag: number;
  21495. /**
  21496. * The dirty attribute flag value
  21497. */
  21498. static readonly AttributesDirtyFlag: number;
  21499. /**
  21500. * The dirty misc flag value
  21501. */
  21502. static readonly MiscDirtyFlag: number;
  21503. /**
  21504. * The all dirty flag value
  21505. */
  21506. static readonly AllDirtyFlag: number;
  21507. /**
  21508. * The ID of the material
  21509. */
  21510. id: string;
  21511. /**
  21512. * Gets or sets the unique id of the material
  21513. */
  21514. uniqueId: number;
  21515. /**
  21516. * The name of the material
  21517. */
  21518. name: string;
  21519. /**
  21520. * Gets or sets user defined metadata
  21521. */
  21522. metadata: any;
  21523. /**
  21524. * For internal use only. Please do not use.
  21525. */
  21526. reservedDataStore: any;
  21527. /**
  21528. * Specifies if the ready state should be checked on each call
  21529. */
  21530. checkReadyOnEveryCall: boolean;
  21531. /**
  21532. * Specifies if the ready state should be checked once
  21533. */
  21534. checkReadyOnlyOnce: boolean;
  21535. /**
  21536. * The state of the material
  21537. */
  21538. state: string;
  21539. /**
  21540. * The alpha value of the material
  21541. */
  21542. protected _alpha: number;
  21543. /**
  21544. * Sets the alpha value of the material
  21545. */
  21546. /**
  21547. * Gets the alpha value of the material
  21548. */
  21549. alpha: number;
  21550. /**
  21551. * Specifies if back face culling is enabled
  21552. */
  21553. protected _backFaceCulling: boolean;
  21554. /**
  21555. * Sets the back-face culling state
  21556. */
  21557. /**
  21558. * Gets the back-face culling state
  21559. */
  21560. backFaceCulling: boolean;
  21561. /**
  21562. * Stores the value for side orientation
  21563. */
  21564. sideOrientation: number;
  21565. /**
  21566. * Callback triggered when the material is compiled
  21567. */
  21568. onCompiled: (effect: Effect) => void;
  21569. /**
  21570. * Callback triggered when an error occurs
  21571. */
  21572. onError: (effect: Effect, errors: string) => void;
  21573. /**
  21574. * Callback triggered to get the render target textures
  21575. */
  21576. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21577. /**
  21578. * Gets a boolean indicating that current material needs to register RTT
  21579. */
  21580. readonly hasRenderTargetTextures: boolean;
  21581. /**
  21582. * Specifies if the material should be serialized
  21583. */
  21584. doNotSerialize: boolean;
  21585. /**
  21586. * @hidden
  21587. */
  21588. _storeEffectOnSubMeshes: boolean;
  21589. /**
  21590. * Stores the animations for the material
  21591. */
  21592. animations: Array<Animation>;
  21593. /**
  21594. * An event triggered when the material is disposed
  21595. */
  21596. onDisposeObservable: Observable<Material>;
  21597. /**
  21598. * An observer which watches for dispose events
  21599. */
  21600. private _onDisposeObserver;
  21601. private _onUnBindObservable;
  21602. /**
  21603. * Called during a dispose event
  21604. */
  21605. onDispose: () => void;
  21606. private _onBindObservable;
  21607. /**
  21608. * An event triggered when the material is bound
  21609. */
  21610. readonly onBindObservable: Observable<AbstractMesh>;
  21611. /**
  21612. * An observer which watches for bind events
  21613. */
  21614. private _onBindObserver;
  21615. /**
  21616. * Called during a bind event
  21617. */
  21618. onBind: (Mesh: AbstractMesh) => void;
  21619. /**
  21620. * An event triggered when the material is unbound
  21621. */
  21622. readonly onUnBindObservable: Observable<Material>;
  21623. /**
  21624. * Stores the value of the alpha mode
  21625. */
  21626. private _alphaMode;
  21627. /**
  21628. * Sets the value of the alpha mode.
  21629. *
  21630. * | Value | Type | Description |
  21631. * | --- | --- | --- |
  21632. * | 0 | ALPHA_DISABLE | |
  21633. * | 1 | ALPHA_ADD | |
  21634. * | 2 | ALPHA_COMBINE | |
  21635. * | 3 | ALPHA_SUBTRACT | |
  21636. * | 4 | ALPHA_MULTIPLY | |
  21637. * | 5 | ALPHA_MAXIMIZED | |
  21638. * | 6 | ALPHA_ONEONE | |
  21639. * | 7 | ALPHA_PREMULTIPLIED | |
  21640. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21641. * | 9 | ALPHA_INTERPOLATE | |
  21642. * | 10 | ALPHA_SCREENMODE | |
  21643. *
  21644. */
  21645. /**
  21646. * Gets the value of the alpha mode
  21647. */
  21648. alphaMode: number;
  21649. /**
  21650. * Stores the state of the need depth pre-pass value
  21651. */
  21652. private _needDepthPrePass;
  21653. /**
  21654. * Sets the need depth pre-pass value
  21655. */
  21656. /**
  21657. * Gets the depth pre-pass value
  21658. */
  21659. needDepthPrePass: boolean;
  21660. /**
  21661. * Specifies if depth writing should be disabled
  21662. */
  21663. disableDepthWrite: boolean;
  21664. /**
  21665. * Specifies if depth writing should be forced
  21666. */
  21667. forceDepthWrite: boolean;
  21668. /**
  21669. * Specifies if there should be a separate pass for culling
  21670. */
  21671. separateCullingPass: boolean;
  21672. /**
  21673. * Stores the state specifing if fog should be enabled
  21674. */
  21675. private _fogEnabled;
  21676. /**
  21677. * Sets the state for enabling fog
  21678. */
  21679. /**
  21680. * Gets the value of the fog enabled state
  21681. */
  21682. fogEnabled: boolean;
  21683. /**
  21684. * Stores the size of points
  21685. */
  21686. pointSize: number;
  21687. /**
  21688. * Stores the z offset value
  21689. */
  21690. zOffset: number;
  21691. /**
  21692. * Gets a value specifying if wireframe mode is enabled
  21693. */
  21694. /**
  21695. * Sets the state of wireframe mode
  21696. */
  21697. wireframe: boolean;
  21698. /**
  21699. * Gets the value specifying if point clouds are enabled
  21700. */
  21701. /**
  21702. * Sets the state of point cloud mode
  21703. */
  21704. pointsCloud: boolean;
  21705. /**
  21706. * Gets the material fill mode
  21707. */
  21708. /**
  21709. * Sets the material fill mode
  21710. */
  21711. fillMode: number;
  21712. /**
  21713. * @hidden
  21714. * Stores the effects for the material
  21715. */
  21716. _effect: Nullable<Effect>;
  21717. /**
  21718. * @hidden
  21719. * Specifies if the material was previously ready
  21720. */
  21721. _wasPreviouslyReady: boolean;
  21722. /**
  21723. * Specifies if uniform buffers should be used
  21724. */
  21725. private _useUBO;
  21726. /**
  21727. * Stores a reference to the scene
  21728. */
  21729. private _scene;
  21730. /**
  21731. * Stores the fill mode state
  21732. */
  21733. private _fillMode;
  21734. /**
  21735. * Specifies if the depth write state should be cached
  21736. */
  21737. private _cachedDepthWriteState;
  21738. /**
  21739. * Stores the uniform buffer
  21740. */
  21741. protected _uniformBuffer: UniformBuffer;
  21742. /** @hidden */
  21743. _indexInSceneMaterialArray: number;
  21744. /** @hidden */
  21745. meshMap: Nullable<{
  21746. [id: string]: AbstractMesh | undefined;
  21747. }>;
  21748. /**
  21749. * Creates a material instance
  21750. * @param name defines the name of the material
  21751. * @param scene defines the scene to reference
  21752. * @param doNotAdd specifies if the material should be added to the scene
  21753. */
  21754. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21755. /**
  21756. * Returns a string representation of the current material
  21757. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21758. * @returns a string with material information
  21759. */
  21760. toString(fullDetails?: boolean): string;
  21761. /**
  21762. * Gets the class name of the material
  21763. * @returns a string with the class name of the material
  21764. */
  21765. getClassName(): string;
  21766. /**
  21767. * Specifies if updates for the material been locked
  21768. */
  21769. readonly isFrozen: boolean;
  21770. /**
  21771. * Locks updates for the material
  21772. */
  21773. freeze(): void;
  21774. /**
  21775. * Unlocks updates for the material
  21776. */
  21777. unfreeze(): void;
  21778. /**
  21779. * Specifies if the material is ready to be used
  21780. * @param mesh defines the mesh to check
  21781. * @param useInstances specifies if instances should be used
  21782. * @returns a boolean indicating if the material is ready to be used
  21783. */
  21784. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21785. /**
  21786. * Specifies that the submesh is ready to be used
  21787. * @param mesh defines the mesh to check
  21788. * @param subMesh defines which submesh to check
  21789. * @param useInstances specifies that instances should be used
  21790. * @returns a boolean indicating that the submesh is ready or not
  21791. */
  21792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21793. /**
  21794. * Returns the material effect
  21795. * @returns the effect associated with the material
  21796. */
  21797. getEffect(): Nullable<Effect>;
  21798. /**
  21799. * Returns the current scene
  21800. * @returns a Scene
  21801. */
  21802. getScene(): Scene;
  21803. /**
  21804. * Specifies if the material will require alpha blending
  21805. * @returns a boolean specifying if alpha blending is needed
  21806. */
  21807. needAlphaBlending(): boolean;
  21808. /**
  21809. * Specifies if the mesh will require alpha blending
  21810. * @param mesh defines the mesh to check
  21811. * @returns a boolean specifying if alpha blending is needed for the mesh
  21812. */
  21813. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21814. /**
  21815. * Specifies if this material should be rendered in alpha test mode
  21816. * @returns a boolean specifying if an alpha test is needed.
  21817. */
  21818. needAlphaTesting(): boolean;
  21819. /**
  21820. * Gets the texture used for the alpha test
  21821. * @returns the texture to use for alpha testing
  21822. */
  21823. getAlphaTestTexture(): Nullable<BaseTexture>;
  21824. /**
  21825. * Marks the material to indicate that it needs to be re-calculated
  21826. */
  21827. markDirty(): void;
  21828. /** @hidden */
  21829. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21830. /**
  21831. * Binds the material to the mesh
  21832. * @param world defines the world transformation matrix
  21833. * @param mesh defines the mesh to bind the material to
  21834. */
  21835. bind(world: Matrix, mesh?: Mesh): void;
  21836. /**
  21837. * Binds the submesh to the material
  21838. * @param world defines the world transformation matrix
  21839. * @param mesh defines the mesh containing the submesh
  21840. * @param subMesh defines the submesh to bind the material to
  21841. */
  21842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21843. /**
  21844. * Binds the world matrix to the material
  21845. * @param world defines the world transformation matrix
  21846. */
  21847. bindOnlyWorldMatrix(world: Matrix): void;
  21848. /**
  21849. * Binds the scene's uniform buffer to the effect.
  21850. * @param effect defines the effect to bind to the scene uniform buffer
  21851. * @param sceneUbo defines the uniform buffer storing scene data
  21852. */
  21853. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21854. /**
  21855. * Binds the view matrix to the effect
  21856. * @param effect defines the effect to bind the view matrix to
  21857. */
  21858. bindView(effect: Effect): void;
  21859. /**
  21860. * Binds the view projection matrix to the effect
  21861. * @param effect defines the effect to bind the view projection matrix to
  21862. */
  21863. bindViewProjection(effect: Effect): void;
  21864. /**
  21865. * Specifies if material alpha testing should be turned on for the mesh
  21866. * @param mesh defines the mesh to check
  21867. */
  21868. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21869. /**
  21870. * Processes to execute after binding the material to a mesh
  21871. * @param mesh defines the rendered mesh
  21872. */
  21873. protected _afterBind(mesh?: Mesh): void;
  21874. /**
  21875. * Unbinds the material from the mesh
  21876. */
  21877. unbind(): void;
  21878. /**
  21879. * Gets the active textures from the material
  21880. * @returns an array of textures
  21881. */
  21882. getActiveTextures(): BaseTexture[];
  21883. /**
  21884. * Specifies if the material uses a texture
  21885. * @param texture defines the texture to check against the material
  21886. * @returns a boolean specifying if the material uses the texture
  21887. */
  21888. hasTexture(texture: BaseTexture): boolean;
  21889. /**
  21890. * Makes a duplicate of the material, and gives it a new name
  21891. * @param name defines the new name for the duplicated material
  21892. * @returns the cloned material
  21893. */
  21894. clone(name: string): Nullable<Material>;
  21895. /**
  21896. * Gets the meshes bound to the material
  21897. * @returns an array of meshes bound to the material
  21898. */
  21899. getBindedMeshes(): AbstractMesh[];
  21900. /**
  21901. * Force shader compilation
  21902. * @param mesh defines the mesh associated with this material
  21903. * @param onCompiled defines a function to execute once the material is compiled
  21904. * @param options defines the options to configure the compilation
  21905. */
  21906. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21907. clipPlane: boolean;
  21908. }>): void;
  21909. /**
  21910. * Force shader compilation
  21911. * @param mesh defines the mesh that will use this material
  21912. * @param options defines additional options for compiling the shaders
  21913. * @returns a promise that resolves when the compilation completes
  21914. */
  21915. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21916. clipPlane: boolean;
  21917. }>): Promise<void>;
  21918. private static readonly _ImageProcessingDirtyCallBack;
  21919. private static readonly _TextureDirtyCallBack;
  21920. private static readonly _FresnelDirtyCallBack;
  21921. private static readonly _MiscDirtyCallBack;
  21922. private static readonly _LightsDirtyCallBack;
  21923. private static readonly _AttributeDirtyCallBack;
  21924. private static _FresnelAndMiscDirtyCallBack;
  21925. private static _TextureAndMiscDirtyCallBack;
  21926. private static readonly _DirtyCallbackArray;
  21927. private static readonly _RunDirtyCallBacks;
  21928. /**
  21929. * Marks a define in the material to indicate that it needs to be re-computed
  21930. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21931. */
  21932. markAsDirty(flag: number): void;
  21933. /**
  21934. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21935. * @param func defines a function which checks material defines against the submeshes
  21936. */
  21937. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21938. /**
  21939. * Indicates that image processing needs to be re-calculated for all submeshes
  21940. */
  21941. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21942. /**
  21943. * Indicates that textures need to be re-calculated for all submeshes
  21944. */
  21945. protected _markAllSubMeshesAsTexturesDirty(): void;
  21946. /**
  21947. * Indicates that fresnel needs to be re-calculated for all submeshes
  21948. */
  21949. protected _markAllSubMeshesAsFresnelDirty(): void;
  21950. /**
  21951. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21952. */
  21953. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21954. /**
  21955. * Indicates that lights need to be re-calculated for all submeshes
  21956. */
  21957. protected _markAllSubMeshesAsLightsDirty(): void;
  21958. /**
  21959. * Indicates that attributes need to be re-calculated for all submeshes
  21960. */
  21961. protected _markAllSubMeshesAsAttributesDirty(): void;
  21962. /**
  21963. * Indicates that misc needs to be re-calculated for all submeshes
  21964. */
  21965. protected _markAllSubMeshesAsMiscDirty(): void;
  21966. /**
  21967. * Indicates that textures and misc need to be re-calculated for all submeshes
  21968. */
  21969. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21970. /**
  21971. * Disposes the material
  21972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21975. */
  21976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21977. /** @hidden */
  21978. private releaseVertexArrayObject;
  21979. /**
  21980. * Serializes this material
  21981. * @returns the serialized material object
  21982. */
  21983. serialize(): any;
  21984. /**
  21985. * Creates a material from parsed material data
  21986. * @param parsedMaterial defines parsed material data
  21987. * @param scene defines the hosting scene
  21988. * @param rootUrl defines the root URL to use to load textures
  21989. * @returns a new material
  21990. */
  21991. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21992. }
  21993. }
  21994. declare module "babylonjs/Meshes/subMesh" {
  21995. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21996. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21997. import { Engine } from "babylonjs/Engines/engine";
  21998. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21999. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22000. import { Effect } from "babylonjs/Materials/effect";
  22001. import { Collider } from "babylonjs/Collisions/collider";
  22002. import { Material } from "babylonjs/Materials/material";
  22003. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { Mesh } from "babylonjs/Meshes/mesh";
  22006. import { Ray } from "babylonjs/Culling/ray";
  22007. /**
  22008. * Base class for submeshes
  22009. */
  22010. export class BaseSubMesh {
  22011. /** @hidden */
  22012. _materialDefines: Nullable<MaterialDefines>;
  22013. /** @hidden */
  22014. _materialEffect: Nullable<Effect>;
  22015. /**
  22016. * Gets associated effect
  22017. */
  22018. readonly effect: Nullable<Effect>;
  22019. /**
  22020. * Sets associated effect (effect used to render this submesh)
  22021. * @param effect defines the effect to associate with
  22022. * @param defines defines the set of defines used to compile this effect
  22023. */
  22024. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22025. }
  22026. /**
  22027. * Defines a subdivision inside a mesh
  22028. */
  22029. export class SubMesh extends BaseSubMesh implements ICullable {
  22030. /** the material index to use */
  22031. materialIndex: number;
  22032. /** vertex index start */
  22033. verticesStart: number;
  22034. /** vertices count */
  22035. verticesCount: number;
  22036. /** index start */
  22037. indexStart: number;
  22038. /** indices count */
  22039. indexCount: number;
  22040. /** @hidden */
  22041. _linesIndexCount: number;
  22042. private _mesh;
  22043. private _renderingMesh;
  22044. private _boundingInfo;
  22045. private _linesIndexBuffer;
  22046. /** @hidden */
  22047. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22048. /** @hidden */
  22049. _trianglePlanes: Plane[];
  22050. /** @hidden */
  22051. _lastColliderTransformMatrix: Matrix;
  22052. /** @hidden */
  22053. _renderId: number;
  22054. /** @hidden */
  22055. _alphaIndex: number;
  22056. /** @hidden */
  22057. _distanceToCamera: number;
  22058. /** @hidden */
  22059. _id: number;
  22060. private _currentMaterial;
  22061. /**
  22062. * Add a new submesh to a mesh
  22063. * @param materialIndex defines the material index to use
  22064. * @param verticesStart defines vertex index start
  22065. * @param verticesCount defines vertices count
  22066. * @param indexStart defines index start
  22067. * @param indexCount defines indices count
  22068. * @param mesh defines the parent mesh
  22069. * @param renderingMesh defines an optional rendering mesh
  22070. * @param createBoundingBox defines if bounding box should be created for this submesh
  22071. * @returns the new submesh
  22072. */
  22073. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22074. /**
  22075. * Creates a new submesh
  22076. * @param materialIndex defines the material index to use
  22077. * @param verticesStart defines vertex index start
  22078. * @param verticesCount defines vertices count
  22079. * @param indexStart defines index start
  22080. * @param indexCount defines indices count
  22081. * @param mesh defines the parent mesh
  22082. * @param renderingMesh defines an optional rendering mesh
  22083. * @param createBoundingBox defines if bounding box should be created for this submesh
  22084. */
  22085. constructor(
  22086. /** the material index to use */
  22087. materialIndex: number,
  22088. /** vertex index start */
  22089. verticesStart: number,
  22090. /** vertices count */
  22091. verticesCount: number,
  22092. /** index start */
  22093. indexStart: number,
  22094. /** indices count */
  22095. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22096. /**
  22097. * Returns true if this submesh covers the entire parent mesh
  22098. * @ignorenaming
  22099. */
  22100. readonly IsGlobal: boolean;
  22101. /**
  22102. * Returns the submesh BoudingInfo object
  22103. * @returns current bounding info (or mesh's one if the submesh is global)
  22104. */
  22105. getBoundingInfo(): BoundingInfo;
  22106. /**
  22107. * Sets the submesh BoundingInfo
  22108. * @param boundingInfo defines the new bounding info to use
  22109. * @returns the SubMesh
  22110. */
  22111. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22112. /**
  22113. * Returns the mesh of the current submesh
  22114. * @return the parent mesh
  22115. */
  22116. getMesh(): AbstractMesh;
  22117. /**
  22118. * Returns the rendering mesh of the submesh
  22119. * @returns the rendering mesh (could be different from parent mesh)
  22120. */
  22121. getRenderingMesh(): Mesh;
  22122. /**
  22123. * Returns the submesh material
  22124. * @returns null or the current material
  22125. */
  22126. getMaterial(): Nullable<Material>;
  22127. /**
  22128. * Sets a new updated BoundingInfo object to the submesh
  22129. * @returns the SubMesh
  22130. */
  22131. refreshBoundingInfo(): SubMesh;
  22132. /** @hidden */
  22133. _checkCollision(collider: Collider): boolean;
  22134. /**
  22135. * Updates the submesh BoundingInfo
  22136. * @param world defines the world matrix to use to update the bounding info
  22137. * @returns the submesh
  22138. */
  22139. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22140. /**
  22141. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22142. * @param frustumPlanes defines the frustum planes
  22143. * @returns true if the submesh is intersecting with the frustum
  22144. */
  22145. isInFrustum(frustumPlanes: Plane[]): boolean;
  22146. /**
  22147. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22148. * @param frustumPlanes defines the frustum planes
  22149. * @returns true if the submesh is inside the frustum
  22150. */
  22151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22152. /**
  22153. * Renders the submesh
  22154. * @param enableAlphaMode defines if alpha needs to be used
  22155. * @returns the submesh
  22156. */
  22157. render(enableAlphaMode: boolean): SubMesh;
  22158. /**
  22159. * @hidden
  22160. */
  22161. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22162. /**
  22163. * Checks if the submesh intersects with a ray
  22164. * @param ray defines the ray to test
  22165. * @returns true is the passed ray intersects the submesh bounding box
  22166. */
  22167. canIntersects(ray: Ray): boolean;
  22168. /**
  22169. * Intersects current submesh with a ray
  22170. * @param ray defines the ray to test
  22171. * @param positions defines mesh's positions array
  22172. * @param indices defines mesh's indices array
  22173. * @param fastCheck defines if only bounding info should be used
  22174. * @returns intersection info or null if no intersection
  22175. */
  22176. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22177. /** @hidden */
  22178. private _intersectLines;
  22179. /** @hidden */
  22180. private _intersectTriangles;
  22181. /** @hidden */
  22182. _rebuild(): void;
  22183. /**
  22184. * Creates a new submesh from the passed mesh
  22185. * @param newMesh defines the new hosting mesh
  22186. * @param newRenderingMesh defines an optional rendering mesh
  22187. * @returns the new submesh
  22188. */
  22189. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22190. /**
  22191. * Release associated resources
  22192. */
  22193. dispose(): void;
  22194. /**
  22195. * Gets the class name
  22196. * @returns the string "SubMesh".
  22197. */
  22198. getClassName(): string;
  22199. /**
  22200. * Creates a new submesh from indices data
  22201. * @param materialIndex the index of the main mesh material
  22202. * @param startIndex the index where to start the copy in the mesh indices array
  22203. * @param indexCount the number of indices to copy then from the startIndex
  22204. * @param mesh the main mesh to create the submesh from
  22205. * @param renderingMesh the optional rendering mesh
  22206. * @returns a new submesh
  22207. */
  22208. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22209. }
  22210. }
  22211. declare module "babylonjs/Meshes/geometry" {
  22212. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22213. import { Scene } from "babylonjs/scene";
  22214. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22215. import { Engine } from "babylonjs/Engines/engine";
  22216. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22217. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22218. import { Effect } from "babylonjs/Materials/effect";
  22219. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22220. import { Mesh } from "babylonjs/Meshes/mesh";
  22221. /**
  22222. * Class used to store geometry data (vertex buffers + index buffer)
  22223. */
  22224. export class Geometry implements IGetSetVerticesData {
  22225. /**
  22226. * Gets or sets the ID of the geometry
  22227. */
  22228. id: string;
  22229. /**
  22230. * Gets or sets the unique ID of the geometry
  22231. */
  22232. uniqueId: number;
  22233. /**
  22234. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22235. */
  22236. delayLoadState: number;
  22237. /**
  22238. * Gets the file containing the data to load when running in delay load state
  22239. */
  22240. delayLoadingFile: Nullable<string>;
  22241. /**
  22242. * Callback called when the geometry is updated
  22243. */
  22244. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22245. private _scene;
  22246. private _engine;
  22247. private _meshes;
  22248. private _totalVertices;
  22249. /** @hidden */
  22250. _indices: IndicesArray;
  22251. /** @hidden */
  22252. _vertexBuffers: {
  22253. [key: string]: VertexBuffer;
  22254. };
  22255. private _isDisposed;
  22256. private _extend;
  22257. private _boundingBias;
  22258. /** @hidden */
  22259. _delayInfo: Array<string>;
  22260. private _indexBuffer;
  22261. private _indexBufferIsUpdatable;
  22262. /** @hidden */
  22263. _boundingInfo: Nullable<BoundingInfo>;
  22264. /** @hidden */
  22265. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22266. /** @hidden */
  22267. _softwareSkinningFrameId: number;
  22268. private _vertexArrayObjects;
  22269. private _updatable;
  22270. /** @hidden */
  22271. _positions: Nullable<Vector3[]>;
  22272. /**
  22273. * 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
  22274. */
  22275. /**
  22276. * 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
  22277. */
  22278. boundingBias: Vector2;
  22279. /**
  22280. * Static function used to attach a new empty geometry to a mesh
  22281. * @param mesh defines the mesh to attach the geometry to
  22282. * @returns the new Geometry
  22283. */
  22284. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22285. /**
  22286. * Creates a new geometry
  22287. * @param id defines the unique ID
  22288. * @param scene defines the hosting scene
  22289. * @param vertexData defines the VertexData used to get geometry data
  22290. * @param updatable defines if geometry must be updatable (false by default)
  22291. * @param mesh defines the mesh that will be associated with the geometry
  22292. */
  22293. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22294. /**
  22295. * Gets the current extend of the geometry
  22296. */
  22297. readonly extend: {
  22298. minimum: Vector3;
  22299. maximum: Vector3;
  22300. };
  22301. /**
  22302. * Gets the hosting scene
  22303. * @returns the hosting Scene
  22304. */
  22305. getScene(): Scene;
  22306. /**
  22307. * Gets the hosting engine
  22308. * @returns the hosting Engine
  22309. */
  22310. getEngine(): Engine;
  22311. /**
  22312. * Defines if the geometry is ready to use
  22313. * @returns true if the geometry is ready to be used
  22314. */
  22315. isReady(): boolean;
  22316. /**
  22317. * Gets a value indicating that the geometry should not be serialized
  22318. */
  22319. readonly doNotSerialize: boolean;
  22320. /** @hidden */
  22321. _rebuild(): void;
  22322. /**
  22323. * Affects all geometry data in one call
  22324. * @param vertexData defines the geometry data
  22325. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22326. */
  22327. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22328. /**
  22329. * Set specific vertex data
  22330. * @param kind defines the data kind (Position, normal, etc...)
  22331. * @param data defines the vertex data to use
  22332. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22333. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22334. */
  22335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22336. /**
  22337. * Removes a specific vertex data
  22338. * @param kind defines the data kind (Position, normal, etc...)
  22339. */
  22340. removeVerticesData(kind: string): void;
  22341. /**
  22342. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22343. * @param buffer defines the vertex buffer to use
  22344. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22345. */
  22346. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22347. /**
  22348. * Update a specific vertex buffer
  22349. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22350. * It will do nothing if the buffer is not updatable
  22351. * @param kind defines the data kind (Position, normal, etc...)
  22352. * @param data defines the data to use
  22353. * @param offset defines the offset in the target buffer where to store the data
  22354. * @param useBytes set to true if the offset is in bytes
  22355. */
  22356. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22357. /**
  22358. * Update a specific vertex buffer
  22359. * This function will create a new buffer if the current one is not updatable
  22360. * @param kind defines the data kind (Position, normal, etc...)
  22361. * @param data defines the data to use
  22362. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22363. */
  22364. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22365. private _updateBoundingInfo;
  22366. /** @hidden */
  22367. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22368. /**
  22369. * Gets total number of vertices
  22370. * @returns the total number of vertices
  22371. */
  22372. getTotalVertices(): number;
  22373. /**
  22374. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22375. * @param kind defines the data kind (Position, normal, etc...)
  22376. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22377. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22378. * @returns a float array containing vertex data
  22379. */
  22380. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22381. /**
  22382. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22383. * @param kind defines the data kind (Position, normal, etc...)
  22384. * @returns true if the vertex buffer with the specified kind is updatable
  22385. */
  22386. isVertexBufferUpdatable(kind: string): boolean;
  22387. /**
  22388. * Gets a specific vertex buffer
  22389. * @param kind defines the data kind (Position, normal, etc...)
  22390. * @returns a VertexBuffer
  22391. */
  22392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22393. /**
  22394. * Returns all vertex buffers
  22395. * @return an object holding all vertex buffers indexed by kind
  22396. */
  22397. getVertexBuffers(): Nullable<{
  22398. [key: string]: VertexBuffer;
  22399. }>;
  22400. /**
  22401. * Gets a boolean indicating if specific vertex buffer is present
  22402. * @param kind defines the data kind (Position, normal, etc...)
  22403. * @returns true if data is present
  22404. */
  22405. isVerticesDataPresent(kind: string): boolean;
  22406. /**
  22407. * Gets a list of all attached data kinds (Position, normal, etc...)
  22408. * @returns a list of string containing all kinds
  22409. */
  22410. getVerticesDataKinds(): string[];
  22411. /**
  22412. * Update index buffer
  22413. * @param indices defines the indices to store in the index buffer
  22414. * @param offset defines the offset in the target buffer where to store the data
  22415. */
  22416. updateIndices(indices: IndicesArray, offset?: number): void;
  22417. /**
  22418. * Creates a new index buffer
  22419. * @param indices defines the indices to store in the index buffer
  22420. * @param totalVertices defines the total number of vertices (could be null)
  22421. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22422. */
  22423. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22424. /**
  22425. * Return the total number of indices
  22426. * @returns the total number of indices
  22427. */
  22428. getTotalIndices(): number;
  22429. /**
  22430. * Gets the index buffer array
  22431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22433. * @returns the index buffer array
  22434. */
  22435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22436. /**
  22437. * Gets the index buffer
  22438. * @return the index buffer
  22439. */
  22440. getIndexBuffer(): Nullable<WebGLBuffer>;
  22441. /** @hidden */
  22442. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22443. /**
  22444. * Release the associated resources for a specific mesh
  22445. * @param mesh defines the source mesh
  22446. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22447. */
  22448. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22449. /**
  22450. * Apply current geometry to a given mesh
  22451. * @param mesh defines the mesh to apply geometry to
  22452. */
  22453. applyToMesh(mesh: Mesh): void;
  22454. private _updateExtend;
  22455. private _applyToMesh;
  22456. private notifyUpdate;
  22457. /**
  22458. * Load the geometry if it was flagged as delay loaded
  22459. * @param scene defines the hosting scene
  22460. * @param onLoaded defines a callback called when the geometry is loaded
  22461. */
  22462. load(scene: Scene, onLoaded?: () => void): void;
  22463. private _queueLoad;
  22464. /**
  22465. * Invert the geometry to move from a right handed system to a left handed one.
  22466. */
  22467. toLeftHanded(): void;
  22468. /** @hidden */
  22469. _resetPointsArrayCache(): void;
  22470. /** @hidden */
  22471. _generatePointsArray(): boolean;
  22472. /**
  22473. * Gets a value indicating if the geometry is disposed
  22474. * @returns true if the geometry was disposed
  22475. */
  22476. isDisposed(): boolean;
  22477. private _disposeVertexArrayObjects;
  22478. /**
  22479. * Free all associated resources
  22480. */
  22481. dispose(): void;
  22482. /**
  22483. * Clone the current geometry into a new geometry
  22484. * @param id defines the unique ID of the new geometry
  22485. * @returns a new geometry object
  22486. */
  22487. copy(id: string): Geometry;
  22488. /**
  22489. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22490. * @return a JSON representation of the current geometry data (without the vertices data)
  22491. */
  22492. serialize(): any;
  22493. private toNumberArray;
  22494. /**
  22495. * Serialize all vertices data into a JSON oject
  22496. * @returns a JSON representation of the current geometry data
  22497. */
  22498. serializeVerticeData(): any;
  22499. /**
  22500. * Extracts a clone of a mesh geometry
  22501. * @param mesh defines the source mesh
  22502. * @param id defines the unique ID of the new geometry object
  22503. * @returns the new geometry object
  22504. */
  22505. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22506. /**
  22507. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22509. * Be aware Math.random() could cause collisions, but:
  22510. * "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"
  22511. * @returns a string containing a new GUID
  22512. */
  22513. static RandomId(): string;
  22514. /** @hidden */
  22515. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22516. private static _CleanMatricesWeights;
  22517. /**
  22518. * Create a new geometry from persisted data (Using .babylon file format)
  22519. * @param parsedVertexData defines the persisted data
  22520. * @param scene defines the hosting scene
  22521. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22522. * @returns the new geometry object
  22523. */
  22524. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22525. }
  22526. }
  22527. declare module "babylonjs/Meshes/mesh.vertexData" {
  22528. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22529. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22530. import { Geometry } from "babylonjs/Meshes/geometry";
  22531. import { Mesh } from "babylonjs/Meshes/mesh";
  22532. /**
  22533. * Define an interface for all classes that will get and set the data on vertices
  22534. */
  22535. export interface IGetSetVerticesData {
  22536. /**
  22537. * Gets a boolean indicating if specific vertex data is present
  22538. * @param kind defines the vertex data kind to use
  22539. * @returns true is data kind is present
  22540. */
  22541. isVerticesDataPresent(kind: string): boolean;
  22542. /**
  22543. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22544. * @param kind defines the data kind (Position, normal, etc...)
  22545. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22546. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22547. * @returns a float array containing vertex data
  22548. */
  22549. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22550. /**
  22551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22552. * @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.
  22553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22554. * @returns the indices array or an empty array if the mesh has no geometry
  22555. */
  22556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22557. /**
  22558. * Set specific vertex data
  22559. * @param kind defines the data kind (Position, normal, etc...)
  22560. * @param data defines the vertex data to use
  22561. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22562. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22563. */
  22564. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22565. /**
  22566. * Update a specific associated vertex buffer
  22567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22568. * - VertexBuffer.PositionKind
  22569. * - VertexBuffer.UVKind
  22570. * - VertexBuffer.UV2Kind
  22571. * - VertexBuffer.UV3Kind
  22572. * - VertexBuffer.UV4Kind
  22573. * - VertexBuffer.UV5Kind
  22574. * - VertexBuffer.UV6Kind
  22575. * - VertexBuffer.ColorKind
  22576. * - VertexBuffer.MatricesIndicesKind
  22577. * - VertexBuffer.MatricesIndicesExtraKind
  22578. * - VertexBuffer.MatricesWeightsKind
  22579. * - VertexBuffer.MatricesWeightsExtraKind
  22580. * @param data defines the data source
  22581. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22582. * @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)
  22583. */
  22584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22585. /**
  22586. * Creates a new index buffer
  22587. * @param indices defines the indices to store in the index buffer
  22588. * @param totalVertices defines the total number of vertices (could be null)
  22589. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22590. */
  22591. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22592. }
  22593. /**
  22594. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22595. */
  22596. export class VertexData {
  22597. /**
  22598. * Mesh side orientation : usually the external or front surface
  22599. */
  22600. static readonly FRONTSIDE: number;
  22601. /**
  22602. * Mesh side orientation : usually the internal or back surface
  22603. */
  22604. static readonly BACKSIDE: number;
  22605. /**
  22606. * Mesh side orientation : both internal and external or front and back surfaces
  22607. */
  22608. static readonly DOUBLESIDE: number;
  22609. /**
  22610. * Mesh side orientation : by default, `FRONTSIDE`
  22611. */
  22612. static readonly DEFAULTSIDE: number;
  22613. /**
  22614. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22615. */
  22616. positions: Nullable<FloatArray>;
  22617. /**
  22618. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22619. */
  22620. normals: Nullable<FloatArray>;
  22621. /**
  22622. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22623. */
  22624. tangents: Nullable<FloatArray>;
  22625. /**
  22626. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22627. */
  22628. uvs: Nullable<FloatArray>;
  22629. /**
  22630. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22631. */
  22632. uvs2: Nullable<FloatArray>;
  22633. /**
  22634. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22635. */
  22636. uvs3: Nullable<FloatArray>;
  22637. /**
  22638. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22639. */
  22640. uvs4: Nullable<FloatArray>;
  22641. /**
  22642. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22643. */
  22644. uvs5: Nullable<FloatArray>;
  22645. /**
  22646. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22647. */
  22648. uvs6: Nullable<FloatArray>;
  22649. /**
  22650. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22651. */
  22652. colors: Nullable<FloatArray>;
  22653. /**
  22654. * 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).
  22655. */
  22656. matricesIndices: Nullable<FloatArray>;
  22657. /**
  22658. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22659. */
  22660. matricesWeights: Nullable<FloatArray>;
  22661. /**
  22662. * An array extending the number of possible indices
  22663. */
  22664. matricesIndicesExtra: Nullable<FloatArray>;
  22665. /**
  22666. * An array extending the number of possible weights when the number of indices is extended
  22667. */
  22668. matricesWeightsExtra: Nullable<FloatArray>;
  22669. /**
  22670. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22671. */
  22672. indices: Nullable<IndicesArray>;
  22673. /**
  22674. * Uses the passed data array to set the set the values for the specified kind of data
  22675. * @param data a linear array of floating numbers
  22676. * @param kind the type of data that is being set, eg positions, colors etc
  22677. */
  22678. set(data: FloatArray, kind: string): void;
  22679. /**
  22680. * Associates the vertexData to the passed Mesh.
  22681. * Sets it as updatable or not (default `false`)
  22682. * @param mesh the mesh the vertexData is applied to
  22683. * @param updatable when used and having the value true allows new data to update the vertexData
  22684. * @returns the VertexData
  22685. */
  22686. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22687. /**
  22688. * Associates the vertexData to the passed Geometry.
  22689. * Sets it as updatable or not (default `false`)
  22690. * @param geometry the geometry the vertexData is applied to
  22691. * @param updatable when used and having the value true allows new data to update the vertexData
  22692. * @returns VertexData
  22693. */
  22694. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22695. /**
  22696. * Updates the associated mesh
  22697. * @param mesh the mesh to be updated
  22698. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22699. * @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
  22700. * @returns VertexData
  22701. */
  22702. updateMesh(mesh: Mesh): VertexData;
  22703. /**
  22704. * Updates the associated geometry
  22705. * @param geometry the geometry to be updated
  22706. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22707. * @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
  22708. * @returns VertexData.
  22709. */
  22710. updateGeometry(geometry: Geometry): VertexData;
  22711. private _applyTo;
  22712. private _update;
  22713. /**
  22714. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22715. * @param matrix the transforming matrix
  22716. * @returns the VertexData
  22717. */
  22718. transform(matrix: Matrix): VertexData;
  22719. /**
  22720. * Merges the passed VertexData into the current one
  22721. * @param other the VertexData to be merged into the current one
  22722. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22723. * @returns the modified VertexData
  22724. */
  22725. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22726. private _mergeElement;
  22727. private _validate;
  22728. /**
  22729. * Serializes the VertexData
  22730. * @returns a serialized object
  22731. */
  22732. serialize(): any;
  22733. /**
  22734. * Extracts the vertexData from a mesh
  22735. * @param mesh the mesh from which to extract the VertexData
  22736. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22737. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22738. * @returns the object VertexData associated to the passed mesh
  22739. */
  22740. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22741. /**
  22742. * Extracts the vertexData from the geometry
  22743. * @param geometry the geometry from which to extract the VertexData
  22744. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22745. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22746. * @returns the object VertexData associated to the passed mesh
  22747. */
  22748. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22749. private static _ExtractFrom;
  22750. /**
  22751. * Creates the VertexData for a Ribbon
  22752. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22753. * * pathArray array of paths, each of which an array of successive Vector3
  22754. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22755. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22756. * * 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
  22757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22758. * * 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)
  22759. * * 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)
  22760. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22761. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22762. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22763. * @returns the VertexData of the ribbon
  22764. */
  22765. static CreateRibbon(options: {
  22766. pathArray: Vector3[][];
  22767. closeArray?: boolean;
  22768. closePath?: boolean;
  22769. offset?: number;
  22770. sideOrientation?: number;
  22771. frontUVs?: Vector4;
  22772. backUVs?: Vector4;
  22773. invertUV?: boolean;
  22774. uvs?: Vector2[];
  22775. colors?: Color4[];
  22776. }): VertexData;
  22777. /**
  22778. * Creates the VertexData for a box
  22779. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22780. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22781. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22782. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22783. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22784. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22785. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22787. * * 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)
  22788. * * 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)
  22789. * @returns the VertexData of the box
  22790. */
  22791. static CreateBox(options: {
  22792. size?: number;
  22793. width?: number;
  22794. height?: number;
  22795. depth?: number;
  22796. faceUV?: Vector4[];
  22797. faceColors?: Color4[];
  22798. sideOrientation?: number;
  22799. frontUVs?: Vector4;
  22800. backUVs?: Vector4;
  22801. }): VertexData;
  22802. /**
  22803. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22805. * * segments sets the number of horizontal strips optional, default 32
  22806. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22807. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22808. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22809. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22810. * * 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
  22811. * * 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
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * @returns the VertexData of the ellipsoid
  22816. */
  22817. static CreateSphere(options: {
  22818. segments?: number;
  22819. diameter?: number;
  22820. diameterX?: number;
  22821. diameterY?: number;
  22822. diameterZ?: number;
  22823. arc?: number;
  22824. slice?: number;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. }): VertexData;
  22829. /**
  22830. * Creates the VertexData for a cylinder, cone or prism
  22831. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22832. * * height sets the height (y direction) of the cylinder, optional, default 2
  22833. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22834. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22835. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22836. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22837. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22838. * * 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
  22839. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22841. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22842. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22844. * * 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)
  22845. * * 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)
  22846. * @returns the VertexData of the cylinder, cone or prism
  22847. */
  22848. static CreateCylinder(options: {
  22849. height?: number;
  22850. diameterTop?: number;
  22851. diameterBottom?: number;
  22852. diameter?: number;
  22853. tessellation?: number;
  22854. subdivisions?: number;
  22855. arc?: number;
  22856. faceColors?: Color4[];
  22857. faceUV?: Vector4[];
  22858. hasRings?: boolean;
  22859. enclose?: boolean;
  22860. sideOrientation?: number;
  22861. frontUVs?: Vector4;
  22862. backUVs?: Vector4;
  22863. }): VertexData;
  22864. /**
  22865. * Creates the VertexData for a torus
  22866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22867. * * diameter the diameter of the torus, optional default 1
  22868. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22869. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  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. * @returns the VertexData of the torus
  22874. */
  22875. static CreateTorus(options: {
  22876. diameter?: number;
  22877. thickness?: number;
  22878. tessellation?: number;
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData of the LineSystem
  22885. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22886. * - lines an array of lines, each line being an array of successive Vector3
  22887. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22888. * @returns the VertexData of the LineSystem
  22889. */
  22890. static CreateLineSystem(options: {
  22891. lines: Vector3[][];
  22892. colors?: Nullable<Color4[][]>;
  22893. }): VertexData;
  22894. /**
  22895. * Create the VertexData for a DashedLines
  22896. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22897. * - points an array successive Vector3
  22898. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22899. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22900. * - dashNb the intended total number of dashes, optional, default 200
  22901. * @returns the VertexData for the DashedLines
  22902. */
  22903. static CreateDashedLines(options: {
  22904. points: Vector3[];
  22905. dashSize?: number;
  22906. gapSize?: number;
  22907. dashNb?: number;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a Ground
  22911. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22912. * - width the width (x direction) of the ground, optional, default 1
  22913. * - height the height (z direction) of the ground, optional, default 1
  22914. * - subdivisions the number of subdivisions per side, optional, default 1
  22915. * @returns the VertexData of the Ground
  22916. */
  22917. static CreateGround(options: {
  22918. width?: number;
  22919. height?: number;
  22920. subdivisions?: number;
  22921. subdivisionsX?: number;
  22922. subdivisionsY?: number;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22927. * * xmin the ground minimum X coordinate, optional, default -1
  22928. * * zmin the ground minimum Z coordinate, optional, default -1
  22929. * * xmax the ground maximum X coordinate, optional, default 1
  22930. * * zmax the ground maximum Z coordinate, optional, default 1
  22931. * * 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}
  22932. * * 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}
  22933. * @returns the VertexData of the TiledGround
  22934. */
  22935. static CreateTiledGround(options: {
  22936. xmin: number;
  22937. zmin: number;
  22938. xmax: number;
  22939. zmax: number;
  22940. subdivisions?: {
  22941. w: number;
  22942. h: number;
  22943. };
  22944. precision?: {
  22945. w: number;
  22946. h: number;
  22947. };
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData of the Ground designed from a heightmap
  22951. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22952. * * width the width (x direction) of the ground
  22953. * * height the height (z direction) of the ground
  22954. * * subdivisions the number of subdivisions per side
  22955. * * minHeight the minimum altitude on the ground, optional, default 0
  22956. * * maxHeight the maximum altitude on the ground, optional default 1
  22957. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22958. * * buffer the array holding the image color data
  22959. * * bufferWidth the width of image
  22960. * * bufferHeight the height of image
  22961. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22962. * @returns the VertexData of the Ground designed from a heightmap
  22963. */
  22964. static CreateGroundFromHeightMap(options: {
  22965. width: number;
  22966. height: number;
  22967. subdivisions: number;
  22968. minHeight: number;
  22969. maxHeight: number;
  22970. colorFilter: Color3;
  22971. buffer: Uint8Array;
  22972. bufferWidth: number;
  22973. bufferHeight: number;
  22974. alphaFilter: number;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData for a Plane
  22978. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22979. * * size sets the width and height of the plane to the value of size, optional default 1
  22980. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22981. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22983. * * 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)
  22984. * * 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)
  22985. * @returns the VertexData of the box
  22986. */
  22987. static CreatePlane(options: {
  22988. size?: number;
  22989. width?: number;
  22990. height?: number;
  22991. sideOrientation?: number;
  22992. frontUVs?: Vector4;
  22993. backUVs?: Vector4;
  22994. }): VertexData;
  22995. /**
  22996. * Creates the VertexData of the Disc or regular Polygon
  22997. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22998. * * radius the radius of the disc, optional default 0.5
  22999. * * tessellation the number of polygon sides, optional, default 64
  23000. * * 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
  23001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23002. * * 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)
  23003. * * 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)
  23004. * @returns the VertexData of the box
  23005. */
  23006. static CreateDisc(options: {
  23007. radius?: number;
  23008. tessellation?: number;
  23009. arc?: number;
  23010. sideOrientation?: number;
  23011. frontUVs?: Vector4;
  23012. backUVs?: Vector4;
  23013. }): VertexData;
  23014. /**
  23015. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23016. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23017. * @param polygon a mesh built from polygonTriangulation.build()
  23018. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23019. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23020. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23021. * @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)
  23022. * @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)
  23023. * @returns the VertexData of the Polygon
  23024. */
  23025. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23026. /**
  23027. * Creates the VertexData of the IcoSphere
  23028. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23029. * * radius the radius of the IcoSphere, optional default 1
  23030. * * radiusX allows stretching in the x direction, optional, default radius
  23031. * * radiusY allows stretching in the y direction, optional, default radius
  23032. * * radiusZ allows stretching in the z direction, optional, default radius
  23033. * * flat when true creates a flat shaded mesh, optional, default true
  23034. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23036. * * 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)
  23037. * * 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)
  23038. * @returns the VertexData of the IcoSphere
  23039. */
  23040. static CreateIcoSphere(options: {
  23041. radius?: number;
  23042. radiusX?: number;
  23043. radiusY?: number;
  23044. radiusZ?: number;
  23045. flat?: boolean;
  23046. subdivisions?: number;
  23047. sideOrientation?: number;
  23048. frontUVs?: Vector4;
  23049. backUVs?: Vector4;
  23050. }): VertexData;
  23051. /**
  23052. * Creates the VertexData for a Polyhedron
  23053. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23054. * * type provided types are:
  23055. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23056. * * 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)
  23057. * * size the size of the IcoSphere, optional default 1
  23058. * * sizeX allows stretching in the x direction, optional, default size
  23059. * * sizeY allows stretching in the y direction, optional, default size
  23060. * * sizeZ allows stretching in the z direction, optional, default size
  23061. * * 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
  23062. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23063. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23064. * * flat when true creates a flat shaded mesh, optional, default true
  23065. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23067. * * 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)
  23068. * * 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)
  23069. * @returns the VertexData of the Polyhedron
  23070. */
  23071. static CreatePolyhedron(options: {
  23072. type?: number;
  23073. size?: number;
  23074. sizeX?: number;
  23075. sizeY?: number;
  23076. sizeZ?: number;
  23077. custom?: any;
  23078. faceUV?: Vector4[];
  23079. faceColors?: Color4[];
  23080. flat?: boolean;
  23081. sideOrientation?: number;
  23082. frontUVs?: Vector4;
  23083. backUVs?: Vector4;
  23084. }): VertexData;
  23085. /**
  23086. * Creates the VertexData for a TorusKnot
  23087. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23088. * * radius the radius of the torus knot, optional, default 2
  23089. * * tube the thickness of the tube, optional, default 0.5
  23090. * * radialSegments the number of sides on each tube segments, optional, default 32
  23091. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23092. * * p the number of windings around the z axis, optional, default 2
  23093. * * q the number of windings around the x axis, optional, default 3
  23094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23095. * * 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)
  23096. * * 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)
  23097. * @returns the VertexData of the Torus Knot
  23098. */
  23099. static CreateTorusKnot(options: {
  23100. radius?: number;
  23101. tube?: number;
  23102. radialSegments?: number;
  23103. tubularSegments?: number;
  23104. p?: number;
  23105. q?: number;
  23106. sideOrientation?: number;
  23107. frontUVs?: Vector4;
  23108. backUVs?: Vector4;
  23109. }): VertexData;
  23110. /**
  23111. * Compute normals for given positions and indices
  23112. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23113. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23114. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23115. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23116. * * facetNormals : optional array of facet normals (vector3)
  23117. * * facetPositions : optional array of facet positions (vector3)
  23118. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23119. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23120. * * bInfo : optional bounding info, required for facetPartitioning computation
  23121. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23122. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23123. * * useRightHandedSystem: optional boolean to for right handed system computation
  23124. * * depthSort : optional boolean to enable the facet depth sort computation
  23125. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23126. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23127. */
  23128. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23129. facetNormals?: any;
  23130. facetPositions?: any;
  23131. facetPartitioning?: any;
  23132. ratio?: number;
  23133. bInfo?: any;
  23134. bbSize?: Vector3;
  23135. subDiv?: any;
  23136. useRightHandedSystem?: boolean;
  23137. depthSort?: boolean;
  23138. distanceTo?: Vector3;
  23139. depthSortedFacets?: any;
  23140. }): void;
  23141. /** @hidden */
  23142. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23143. /**
  23144. * Applies VertexData created from the imported parameters to the geometry
  23145. * @param parsedVertexData the parsed data from an imported file
  23146. * @param geometry the geometry to apply the VertexData to
  23147. */
  23148. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23149. }
  23150. }
  23151. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { Scene } from "babylonjs/scene";
  23154. import { Vector4 } from "babylonjs/Maths/math";
  23155. import { Mesh } from "babylonjs/Meshes/mesh";
  23156. /**
  23157. * Class containing static functions to help procedurally build meshes
  23158. */
  23159. export class DiscBuilder {
  23160. /**
  23161. * Creates a plane polygonal mesh. By default, this is a disc
  23162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23163. * * 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
  23164. * * 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
  23165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23168. * @param name defines the name of the mesh
  23169. * @param options defines the options used to create the mesh
  23170. * @param scene defines the hosting scene
  23171. * @returns the plane polygonal mesh
  23172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23173. */
  23174. static CreateDisc(name: string, options: {
  23175. radius?: number;
  23176. tessellation?: number;
  23177. arc?: number;
  23178. updatable?: boolean;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }, scene?: Nullable<Scene>): Mesh;
  23183. }
  23184. }
  23185. declare module "babylonjs/Particles/solidParticleSystem" {
  23186. import { Vector3 } from "babylonjs/Maths/math";
  23187. import { Mesh } from "babylonjs/Meshes/mesh";
  23188. import { Scene, IDisposable } from "babylonjs/scene";
  23189. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23190. /**
  23191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23192. *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.
  23193. * The SPS is also a particle system. It provides some methods to manage the particles.
  23194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23195. *
  23196. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23197. */
  23198. export class SolidParticleSystem implements IDisposable {
  23199. /**
  23200. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23201. * Example : var p = SPS.particles[i];
  23202. */
  23203. particles: SolidParticle[];
  23204. /**
  23205. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23206. */
  23207. nbParticles: number;
  23208. /**
  23209. * If the particles must ever face the camera (default false). Useful for planar particles.
  23210. */
  23211. billboard: boolean;
  23212. /**
  23213. * Recompute normals when adding a shape
  23214. */
  23215. recomputeNormals: boolean;
  23216. /**
  23217. * This a counter ofr your own usage. It's not set by any SPS functions.
  23218. */
  23219. counter: number;
  23220. /**
  23221. * The SPS name. This name is also given to the underlying mesh.
  23222. */
  23223. name: string;
  23224. /**
  23225. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23226. */
  23227. mesh: Mesh;
  23228. /**
  23229. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23230. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23231. */
  23232. vars: any;
  23233. /**
  23234. * This array is populated when the SPS is set as 'pickable'.
  23235. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23236. * Each element of this array is an object `{idx: int, faceId: int}`.
  23237. * `idx` is the picked particle index in the `SPS.particles` array
  23238. * `faceId` is the picked face index counted within this particle.
  23239. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23240. */
  23241. pickedParticles: {
  23242. idx: number;
  23243. faceId: number;
  23244. }[];
  23245. /**
  23246. * This array is populated when `enableDepthSort` is set to true.
  23247. * Each element of this array is an instance of the class DepthSortedParticle.
  23248. */
  23249. depthSortedParticles: DepthSortedParticle[];
  23250. /**
  23251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23252. * @hidden
  23253. */
  23254. _bSphereOnly: boolean;
  23255. /**
  23256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23257. * @hidden
  23258. */
  23259. _bSphereRadiusFactor: number;
  23260. private _scene;
  23261. private _positions;
  23262. private _indices;
  23263. private _normals;
  23264. private _colors;
  23265. private _uvs;
  23266. private _indices32;
  23267. private _positions32;
  23268. private _normals32;
  23269. private _fixedNormal32;
  23270. private _colors32;
  23271. private _uvs32;
  23272. private _index;
  23273. private _updatable;
  23274. private _pickable;
  23275. private _isVisibilityBoxLocked;
  23276. private _alwaysVisible;
  23277. private _depthSort;
  23278. private _shapeCounter;
  23279. private _copy;
  23280. private _color;
  23281. private _computeParticleColor;
  23282. private _computeParticleTexture;
  23283. private _computeParticleRotation;
  23284. private _computeParticleVertex;
  23285. private _computeBoundingBox;
  23286. private _depthSortParticles;
  23287. private _camera;
  23288. private _mustUnrotateFixedNormals;
  23289. private _particlesIntersect;
  23290. private _needs32Bits;
  23291. /**
  23292. * Creates a SPS (Solid Particle System) object.
  23293. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23294. * @param scene (Scene) is the scene in which the SPS is added.
  23295. * @param options defines the options of the sps e.g.
  23296. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23297. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23298. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23299. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23300. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23301. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23302. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23303. */
  23304. constructor(name: string, scene: Scene, options?: {
  23305. updatable?: boolean;
  23306. isPickable?: boolean;
  23307. enableDepthSort?: boolean;
  23308. particleIntersection?: boolean;
  23309. boundingSphereOnly?: boolean;
  23310. bSphereRadiusFactor?: number;
  23311. });
  23312. /**
  23313. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23314. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23315. * @returns the created mesh
  23316. */
  23317. buildMesh(): Mesh;
  23318. /**
  23319. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23320. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23321. * Thus the particles generated from `digest()` have their property `position` set yet.
  23322. * @param mesh ( Mesh ) is the mesh to be digested
  23323. * @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
  23324. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23325. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23326. * @returns the current SPS
  23327. */
  23328. digest(mesh: Mesh, options?: {
  23329. facetNb?: number;
  23330. number?: number;
  23331. delta?: number;
  23332. }): SolidParticleSystem;
  23333. private _unrotateFixedNormals;
  23334. private _resetCopy;
  23335. private _meshBuilder;
  23336. private _posToShape;
  23337. private _uvsToShapeUV;
  23338. private _addParticle;
  23339. /**
  23340. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23341. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23342. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23343. * @param nb (positive integer) the number of particles to be created from this model
  23344. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23345. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23346. * @returns the number of shapes in the system
  23347. */
  23348. addShape(mesh: Mesh, nb: number, options?: {
  23349. positionFunction?: any;
  23350. vertexFunction?: any;
  23351. }): number;
  23352. private _rebuildParticle;
  23353. /**
  23354. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23355. * @returns the SPS.
  23356. */
  23357. rebuildMesh(): SolidParticleSystem;
  23358. /**
  23359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23360. * This method calls `updateParticle()` for each particle of the SPS.
  23361. * For an animated SPS, it is usually called within the render loop.
  23362. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23363. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23364. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23365. * @returns the SPS.
  23366. */
  23367. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23368. /**
  23369. * Disposes the SPS.
  23370. */
  23371. dispose(): void;
  23372. /**
  23373. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23374. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23375. * @returns the SPS.
  23376. */
  23377. refreshVisibleSize(): SolidParticleSystem;
  23378. /**
  23379. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23380. * @param size the size (float) of the visibility box
  23381. * note : this doesn't lock the SPS mesh bounding box.
  23382. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23383. */
  23384. setVisibilityBox(size: number): void;
  23385. /**
  23386. * Gets whether the SPS as always visible or not
  23387. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23388. */
  23389. /**
  23390. * Sets the SPS as always visible or not
  23391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23392. */
  23393. isAlwaysVisible: boolean;
  23394. /**
  23395. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23397. */
  23398. /**
  23399. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23400. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23401. */
  23402. isVisibilityBoxLocked: boolean;
  23403. /**
  23404. * Tells to `setParticles()` to compute the particle rotations or not.
  23405. * Default value : true. The SPS is faster when it's set to false.
  23406. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23407. */
  23408. /**
  23409. * Gets if `setParticles()` computes the particle rotations or not.
  23410. * Default value : true. The SPS is faster when it's set to false.
  23411. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23412. */
  23413. computeParticleRotation: boolean;
  23414. /**
  23415. * Tells to `setParticles()` to compute the particle colors or not.
  23416. * Default value : true. The SPS is faster when it's set to false.
  23417. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23418. */
  23419. /**
  23420. * Gets if `setParticles()` computes the particle colors or not.
  23421. * Default value : true. The SPS is faster when it's set to false.
  23422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23423. */
  23424. computeParticleColor: boolean;
  23425. /**
  23426. * Gets if `setParticles()` computes the particle textures or not.
  23427. * Default value : true. The SPS is faster when it's set to false.
  23428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23429. */
  23430. computeParticleTexture: boolean;
  23431. /**
  23432. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23433. * Default value : false. The SPS is faster when it's set to false.
  23434. * Note : the particle custom vertex positions aren't stored values.
  23435. */
  23436. /**
  23437. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23438. * Default value : false. The SPS is faster when it's set to false.
  23439. * Note : the particle custom vertex positions aren't stored values.
  23440. */
  23441. computeParticleVertex: boolean;
  23442. /**
  23443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23444. */
  23445. /**
  23446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23447. */
  23448. computeBoundingBox: boolean;
  23449. /**
  23450. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23451. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23452. * Default : `true`
  23453. */
  23454. /**
  23455. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23456. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23457. * Default : `true`
  23458. */
  23459. depthSortParticles: boolean;
  23460. /**
  23461. * This function does nothing. It may be overwritten to set all the particle first values.
  23462. * The SPS doesn't call this function, you may have to call it by your own.
  23463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23464. */
  23465. initParticles(): void;
  23466. /**
  23467. * This function does nothing. It may be overwritten to recycle a particle.
  23468. * The SPS doesn't call this function, you may have to call it by your own.
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23470. * @param particle The particle to recycle
  23471. * @returns the recycled particle
  23472. */
  23473. recycleParticle(particle: SolidParticle): SolidParticle;
  23474. /**
  23475. * Updates a particle : this function should be overwritten by the user.
  23476. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23478. * @example : just set a particle position or velocity and recycle conditions
  23479. * @param particle The particle to update
  23480. * @returns the updated particle
  23481. */
  23482. updateParticle(particle: SolidParticle): SolidParticle;
  23483. /**
  23484. * Updates a vertex of a particle : it can be overwritten by the user.
  23485. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23486. * @param particle the current particle
  23487. * @param vertex the current index of the current particle
  23488. * @param pt the index of the current vertex in the particle shape
  23489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23490. * @example : just set a vertex particle position
  23491. * @returns the updated vertex
  23492. */
  23493. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23494. /**
  23495. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23496. * This does nothing and may be overwritten by the user.
  23497. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23498. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23499. * @param update the boolean update value actually passed to setParticles()
  23500. */
  23501. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23502. /**
  23503. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23504. * This will be passed three parameters.
  23505. * This does nothing and may be overwritten by the user.
  23506. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23507. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23508. * @param update the boolean update value actually passed to setParticles()
  23509. */
  23510. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23511. }
  23512. }
  23513. declare module "babylonjs/Particles/solidParticle" {
  23514. import { Nullable } from "babylonjs/types";
  23515. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23516. import { Mesh } from "babylonjs/Meshes/mesh";
  23517. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23518. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23519. /**
  23520. * Represents one particle of a solid particle system.
  23521. */
  23522. export class SolidParticle {
  23523. /**
  23524. * particle global index
  23525. */
  23526. idx: number;
  23527. /**
  23528. * The color of the particle
  23529. */
  23530. color: Nullable<Color4>;
  23531. /**
  23532. * The world space position of the particle.
  23533. */
  23534. position: Vector3;
  23535. /**
  23536. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23537. */
  23538. rotation: Vector3;
  23539. /**
  23540. * The world space rotation quaternion of the particle.
  23541. */
  23542. rotationQuaternion: Nullable<Quaternion>;
  23543. /**
  23544. * The scaling of the particle.
  23545. */
  23546. scaling: Vector3;
  23547. /**
  23548. * The uvs of the particle.
  23549. */
  23550. uvs: Vector4;
  23551. /**
  23552. * The current speed of the particle.
  23553. */
  23554. velocity: Vector3;
  23555. /**
  23556. * The pivot point in the particle local space.
  23557. */
  23558. pivot: Vector3;
  23559. /**
  23560. * Must the particle be translated from its pivot point in its local space ?
  23561. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23562. * Default : false
  23563. */
  23564. translateFromPivot: boolean;
  23565. /**
  23566. * Is the particle active or not ?
  23567. */
  23568. alive: boolean;
  23569. /**
  23570. * Is the particle visible or not ?
  23571. */
  23572. isVisible: boolean;
  23573. /**
  23574. * Index of this particle in the global "positions" array (Internal use)
  23575. * @hidden
  23576. */
  23577. _pos: number;
  23578. /**
  23579. * @hidden Index of this particle in the global "indices" array (Internal use)
  23580. */
  23581. _ind: number;
  23582. /**
  23583. * @hidden ModelShape of this particle (Internal use)
  23584. */
  23585. _model: ModelShape;
  23586. /**
  23587. * ModelShape id of this particle
  23588. */
  23589. shapeId: number;
  23590. /**
  23591. * Index of the particle in its shape id (Internal use)
  23592. */
  23593. idxInShape: number;
  23594. /**
  23595. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23596. */
  23597. _modelBoundingInfo: BoundingInfo;
  23598. /**
  23599. * @hidden Particle BoundingInfo object (Internal use)
  23600. */
  23601. _boundingInfo: BoundingInfo;
  23602. /**
  23603. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23604. */
  23605. _sps: SolidParticleSystem;
  23606. /**
  23607. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23608. */
  23609. _stillInvisible: boolean;
  23610. /**
  23611. * @hidden Last computed particle rotation matrix
  23612. */
  23613. _rotationMatrix: number[];
  23614. /**
  23615. * Parent particle Id, if any.
  23616. * Default null.
  23617. */
  23618. parentId: Nullable<number>;
  23619. /**
  23620. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23621. * The possible values are :
  23622. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23623. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23624. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23625. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23626. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23627. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23628. * */
  23629. cullingStrategy: number;
  23630. /**
  23631. * @hidden Internal global position in the SPS.
  23632. */
  23633. _globalPosition: Vector3;
  23634. /**
  23635. * Creates a Solid Particle object.
  23636. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23637. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23638. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23639. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23640. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23641. * @param shapeId (integer) is the model shape identifier in the SPS.
  23642. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23643. * @param sps defines the sps it is associated to
  23644. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23645. */
  23646. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23647. /**
  23648. * Legacy support, changed scale to scaling
  23649. */
  23650. /**
  23651. * Legacy support, changed scale to scaling
  23652. */
  23653. scale: Vector3;
  23654. /**
  23655. * Legacy support, changed quaternion to rotationQuaternion
  23656. */
  23657. /**
  23658. * Legacy support, changed quaternion to rotationQuaternion
  23659. */
  23660. quaternion: Nullable<Quaternion>;
  23661. /**
  23662. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23663. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23664. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23665. * @returns true if it intersects
  23666. */
  23667. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23668. /**
  23669. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23670. * A particle is in the frustum if its bounding box intersects the frustum
  23671. * @param frustumPlanes defines the frustum to test
  23672. * @returns true if the particle is in the frustum planes
  23673. */
  23674. isInFrustum(frustumPlanes: Plane[]): boolean;
  23675. /**
  23676. * get the rotation matrix of the particle
  23677. * @hidden
  23678. */
  23679. getRotationMatrix(m: Matrix): void;
  23680. }
  23681. /**
  23682. * Represents the shape of the model used by one particle of a solid particle system.
  23683. * SPS internal tool, don't use it manually.
  23684. */
  23685. export class ModelShape {
  23686. /**
  23687. * The shape id
  23688. * @hidden
  23689. */
  23690. shapeID: number;
  23691. /**
  23692. * flat array of model positions (internal use)
  23693. * @hidden
  23694. */
  23695. _shape: Vector3[];
  23696. /**
  23697. * flat array of model UVs (internal use)
  23698. * @hidden
  23699. */
  23700. _shapeUV: number[];
  23701. /**
  23702. * length of the shape in the model indices array (internal use)
  23703. * @hidden
  23704. */
  23705. _indicesLength: number;
  23706. /**
  23707. * Custom position function (internal use)
  23708. * @hidden
  23709. */
  23710. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23711. /**
  23712. * Custom vertex function (internal use)
  23713. * @hidden
  23714. */
  23715. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23716. /**
  23717. * 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.
  23718. * SPS internal tool, don't use it manually.
  23719. * @hidden
  23720. */
  23721. 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>);
  23722. }
  23723. /**
  23724. * Represents a Depth Sorted Particle in the solid particle system.
  23725. */
  23726. export class DepthSortedParticle {
  23727. /**
  23728. * Index of the particle in the "indices" array
  23729. */
  23730. ind: number;
  23731. /**
  23732. * Length of the particle shape in the "indices" array
  23733. */
  23734. indicesLength: number;
  23735. /**
  23736. * Squared distance from the particle to the camera
  23737. */
  23738. sqDistance: number;
  23739. }
  23740. }
  23741. declare module "babylonjs/Meshes/abstractMesh" {
  23742. import { Observable } from "babylonjs/Misc/observable";
  23743. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23744. import { Camera } from "babylonjs/Cameras/camera";
  23745. import { Scene, IDisposable } from "babylonjs/scene";
  23746. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23747. import { Node } from "babylonjs/node";
  23748. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23749. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23752. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23753. import { Material } from "babylonjs/Materials/material";
  23754. import { Light } from "babylonjs/Lights/light";
  23755. import { Skeleton } from "babylonjs/Bones/skeleton";
  23756. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23757. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23759. import { Ray } from "babylonjs/Culling/ray";
  23760. import { Collider } from "babylonjs/Collisions/collider";
  23761. /**
  23762. * Class used to store all common mesh properties
  23763. */
  23764. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23765. /** No occlusion */
  23766. static OCCLUSION_TYPE_NONE: number;
  23767. /** Occlusion set to optimisitic */
  23768. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23769. /** Occlusion set to strict */
  23770. static OCCLUSION_TYPE_STRICT: number;
  23771. /** Use an accurante occlusion algorithm */
  23772. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23773. /** Use a conservative occlusion algorithm */
  23774. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23775. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23776. * Test order :
  23777. * Is the bounding sphere outside the frustum ?
  23778. * If not, are the bounding box vertices outside the frustum ?
  23779. * It not, then the cullable object is in the frustum.
  23780. */
  23781. static readonly CULLINGSTRATEGY_STANDARD: number;
  23782. /** Culling strategy : Bounding Sphere Only.
  23783. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23784. * It's also less accurate than the standard because some not visible objects can still be selected.
  23785. * Test : is the bounding sphere outside the frustum ?
  23786. * If not, then the cullable object is in the frustum.
  23787. */
  23788. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23789. /** Culling strategy : Optimistic Inclusion.
  23790. * This in an inclusion test first, then the standard exclusion test.
  23791. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23792. * 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.
  23793. * Anyway, it's as accurate as the standard strategy.
  23794. * Test :
  23795. * Is the cullable object bounding sphere center in the frustum ?
  23796. * If not, apply the default culling strategy.
  23797. */
  23798. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23799. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23800. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23801. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23802. * 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.
  23803. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23804. * Test :
  23805. * Is the cullable object bounding sphere center in the frustum ?
  23806. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23807. */
  23808. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23809. /**
  23810. * No billboard
  23811. */
  23812. static readonly BILLBOARDMODE_NONE: number;
  23813. /** Billboard on X axis */
  23814. static readonly BILLBOARDMODE_X: number;
  23815. /** Billboard on Y axis */
  23816. static readonly BILLBOARDMODE_Y: number;
  23817. /** Billboard on Z axis */
  23818. static readonly BILLBOARDMODE_Z: number;
  23819. /** Billboard on all axes */
  23820. static readonly BILLBOARDMODE_ALL: number;
  23821. private _facetData;
  23822. /**
  23823. * The culling strategy to use to check whether the mesh must be rendered or not.
  23824. * This value can be changed at any time and will be used on the next render mesh selection.
  23825. * The possible values are :
  23826. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23827. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23828. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23829. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23830. * Please read each static variable documentation to get details about the culling process.
  23831. * */
  23832. cullingStrategy: number;
  23833. /**
  23834. * Gets the number of facets in the mesh
  23835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23836. */
  23837. readonly facetNb: number;
  23838. /**
  23839. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23841. */
  23842. partitioningSubdivisions: number;
  23843. /**
  23844. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23845. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23847. */
  23848. partitioningBBoxRatio: number;
  23849. /**
  23850. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23851. * Works only for updatable meshes.
  23852. * Doesn't work with multi-materials
  23853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23854. */
  23855. mustDepthSortFacets: boolean;
  23856. /**
  23857. * The location (Vector3) where the facet depth sort must be computed from.
  23858. * By default, the active camera position.
  23859. * Used only when facet depth sort is enabled
  23860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23861. */
  23862. facetDepthSortFrom: Vector3;
  23863. /**
  23864. * gets a boolean indicating if facetData is enabled
  23865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23866. */
  23867. readonly isFacetDataEnabled: boolean;
  23868. /** @hidden */
  23869. _updateNonUniformScalingState(value: boolean): boolean;
  23870. /**
  23871. * An event triggered when this mesh collides with another one
  23872. */
  23873. onCollideObservable: Observable<AbstractMesh>;
  23874. private _onCollideObserver;
  23875. /** Set a function to call when this mesh collides with another one */
  23876. onCollide: () => void;
  23877. /**
  23878. * An event triggered when the collision's position changes
  23879. */
  23880. onCollisionPositionChangeObservable: Observable<Vector3>;
  23881. private _onCollisionPositionChangeObserver;
  23882. /** Set a function to call when the collision's position changes */
  23883. onCollisionPositionChange: () => void;
  23884. /**
  23885. * An event triggered when material is changed
  23886. */
  23887. onMaterialChangedObservable: Observable<AbstractMesh>;
  23888. /**
  23889. * Gets or sets the orientation for POV movement & rotation
  23890. */
  23891. definedFacingForward: boolean;
  23892. /** @hidden */
  23893. _occlusionQuery: Nullable<WebGLQuery>;
  23894. private _visibility;
  23895. /**
  23896. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23897. */
  23898. /**
  23899. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23900. */
  23901. visibility: number;
  23902. /** Gets or sets the alpha index used to sort transparent meshes
  23903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23904. */
  23905. alphaIndex: number;
  23906. /**
  23907. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23908. */
  23909. isVisible: boolean;
  23910. /**
  23911. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23912. */
  23913. isPickable: boolean;
  23914. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23915. showSubMeshesBoundingBox: boolean;
  23916. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23918. */
  23919. isBlocker: boolean;
  23920. /**
  23921. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23922. */
  23923. enablePointerMoveEvents: boolean;
  23924. /**
  23925. * Specifies the rendering group id for this mesh (0 by default)
  23926. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23927. */
  23928. renderingGroupId: number;
  23929. private _material;
  23930. /** Gets or sets current material */
  23931. material: Nullable<Material>;
  23932. private _receiveShadows;
  23933. /**
  23934. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23935. * @see http://doc.babylonjs.com/babylon101/shadows
  23936. */
  23937. receiveShadows: boolean;
  23938. /** Defines color to use when rendering outline */
  23939. outlineColor: Color3;
  23940. /** Define width to use when rendering outline */
  23941. outlineWidth: number;
  23942. /** Defines color to use when rendering overlay */
  23943. overlayColor: Color3;
  23944. /** Defines alpha to use when rendering overlay */
  23945. overlayAlpha: number;
  23946. private _hasVertexAlpha;
  23947. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23948. hasVertexAlpha: boolean;
  23949. private _useVertexColors;
  23950. /** 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) */
  23951. useVertexColors: boolean;
  23952. private _computeBonesUsingShaders;
  23953. /**
  23954. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23955. */
  23956. computeBonesUsingShaders: boolean;
  23957. private _numBoneInfluencers;
  23958. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23959. numBoneInfluencers: number;
  23960. private _applyFog;
  23961. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23962. applyFog: boolean;
  23963. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23964. useOctreeForRenderingSelection: boolean;
  23965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23966. useOctreeForPicking: boolean;
  23967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23968. useOctreeForCollisions: boolean;
  23969. private _layerMask;
  23970. /**
  23971. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23972. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23973. */
  23974. layerMask: number;
  23975. /**
  23976. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23977. */
  23978. alwaysSelectAsActiveMesh: boolean;
  23979. /**
  23980. * Gets or sets the current action manager
  23981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23982. */
  23983. actionManager: Nullable<AbstractActionManager>;
  23984. private _checkCollisions;
  23985. private _collisionMask;
  23986. private _collisionGroup;
  23987. /**
  23988. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23990. */
  23991. ellipsoid: Vector3;
  23992. /**
  23993. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23995. */
  23996. ellipsoidOffset: Vector3;
  23997. private _collider;
  23998. private _oldPositionForCollisions;
  23999. private _diffPositionForCollisions;
  24000. /**
  24001. * Gets or sets a collision mask used to mask collisions (default is -1).
  24002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24003. */
  24004. collisionMask: number;
  24005. /**
  24006. * Gets or sets the current collision group mask (-1 by default).
  24007. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24008. */
  24009. collisionGroup: number;
  24010. /**
  24011. * Defines edge width used when edgesRenderer is enabled
  24012. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24013. */
  24014. edgesWidth: number;
  24015. /**
  24016. * Defines edge color used when edgesRenderer is enabled
  24017. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24018. */
  24019. edgesColor: Color4;
  24020. /** @hidden */
  24021. _edgesRenderer: Nullable<IEdgesRenderer>;
  24022. /** @hidden */
  24023. _masterMesh: Nullable<AbstractMesh>;
  24024. /** @hidden */
  24025. _boundingInfo: Nullable<BoundingInfo>;
  24026. /** @hidden */
  24027. _renderId: number;
  24028. /**
  24029. * Gets or sets the list of subMeshes
  24030. * @see http://doc.babylonjs.com/how_to/multi_materials
  24031. */
  24032. subMeshes: SubMesh[];
  24033. /** @hidden */
  24034. _intersectionsInProgress: AbstractMesh[];
  24035. /** @hidden */
  24036. _unIndexed: boolean;
  24037. /** @hidden */
  24038. _lightSources: Light[];
  24039. /** @hidden */
  24040. readonly _positions: Nullable<Vector3[]>;
  24041. /** @hidden */
  24042. _waitingActions: any;
  24043. /** @hidden */
  24044. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24045. private _skeleton;
  24046. /** @hidden */
  24047. _bonesTransformMatrices: Nullable<Float32Array>;
  24048. /**
  24049. * Gets or sets a skeleton to apply skining transformations
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24051. */
  24052. skeleton: Nullable<Skeleton>;
  24053. /**
  24054. * An event triggered when the mesh is rebuilt.
  24055. */
  24056. onRebuildObservable: Observable<AbstractMesh>;
  24057. /**
  24058. * Creates a new AbstractMesh
  24059. * @param name defines the name of the mesh
  24060. * @param scene defines the hosting scene
  24061. */
  24062. constructor(name: string, scene?: Nullable<Scene>);
  24063. /**
  24064. * Returns the string "AbstractMesh"
  24065. * @returns "AbstractMesh"
  24066. */
  24067. getClassName(): string;
  24068. /**
  24069. * Gets a string representation of the current mesh
  24070. * @param fullDetails defines a boolean indicating if full details must be included
  24071. * @returns a string representation of the current mesh
  24072. */
  24073. toString(fullDetails?: boolean): string;
  24074. /** @hidden */
  24075. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24076. /** @hidden */
  24077. _rebuild(): void;
  24078. /** @hidden */
  24079. _resyncLightSources(): void;
  24080. /** @hidden */
  24081. _resyncLighSource(light: Light): void;
  24082. /** @hidden */
  24083. _unBindEffect(): void;
  24084. /** @hidden */
  24085. _removeLightSource(light: Light): void;
  24086. private _markSubMeshesAsDirty;
  24087. /** @hidden */
  24088. _markSubMeshesAsLightDirty(): void;
  24089. /** @hidden */
  24090. _markSubMeshesAsAttributesDirty(): void;
  24091. /** @hidden */
  24092. _markSubMeshesAsMiscDirty(): void;
  24093. /**
  24094. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24095. */
  24096. scaling: Vector3;
  24097. /**
  24098. * Returns true if the mesh is blocked. Implemented by child classes
  24099. */
  24100. readonly isBlocked: boolean;
  24101. /**
  24102. * Returns the mesh itself by default. Implemented by child classes
  24103. * @param camera defines the camera to use to pick the right LOD level
  24104. * @returns the currentAbstractMesh
  24105. */
  24106. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24107. /**
  24108. * Returns 0 by default. Implemented by child classes
  24109. * @returns an integer
  24110. */
  24111. getTotalVertices(): number;
  24112. /**
  24113. * Returns a positive integer : the total number of indices in this mesh geometry.
  24114. * @returns the numner of indices or zero if the mesh has no geometry.
  24115. */
  24116. getTotalIndices(): number;
  24117. /**
  24118. * Returns null by default. Implemented by child classes
  24119. * @returns null
  24120. */
  24121. getIndices(): Nullable<IndicesArray>;
  24122. /**
  24123. * Returns the array of the requested vertex data kind. Implemented by child classes
  24124. * @param kind defines the vertex data kind to use
  24125. * @returns null
  24126. */
  24127. getVerticesData(kind: string): Nullable<FloatArray>;
  24128. /**
  24129. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24130. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24131. * Note that a new underlying VertexBuffer object is created each call.
  24132. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24133. * @param kind defines vertex data kind:
  24134. * * VertexBuffer.PositionKind
  24135. * * VertexBuffer.UVKind
  24136. * * VertexBuffer.UV2Kind
  24137. * * VertexBuffer.UV3Kind
  24138. * * VertexBuffer.UV4Kind
  24139. * * VertexBuffer.UV5Kind
  24140. * * VertexBuffer.UV6Kind
  24141. * * VertexBuffer.ColorKind
  24142. * * VertexBuffer.MatricesIndicesKind
  24143. * * VertexBuffer.MatricesIndicesExtraKind
  24144. * * VertexBuffer.MatricesWeightsKind
  24145. * * VertexBuffer.MatricesWeightsExtraKind
  24146. * @param data defines the data source
  24147. * @param updatable defines if the data must be flagged as updatable (or static)
  24148. * @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
  24149. * @returns the current mesh
  24150. */
  24151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24152. /**
  24153. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24154. * If the mesh has no geometry, it is simply returned as it is.
  24155. * @param kind defines vertex data kind:
  24156. * * VertexBuffer.PositionKind
  24157. * * VertexBuffer.UVKind
  24158. * * VertexBuffer.UV2Kind
  24159. * * VertexBuffer.UV3Kind
  24160. * * VertexBuffer.UV4Kind
  24161. * * VertexBuffer.UV5Kind
  24162. * * VertexBuffer.UV6Kind
  24163. * * VertexBuffer.ColorKind
  24164. * * VertexBuffer.MatricesIndicesKind
  24165. * * VertexBuffer.MatricesIndicesExtraKind
  24166. * * VertexBuffer.MatricesWeightsKind
  24167. * * VertexBuffer.MatricesWeightsExtraKind
  24168. * @param data defines the data source
  24169. * @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
  24170. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24171. * @returns the current mesh
  24172. */
  24173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24174. /**
  24175. * Sets the mesh indices,
  24176. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24177. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24178. * @param totalVertices Defines the total number of vertices
  24179. * @returns the current mesh
  24180. */
  24181. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24182. /**
  24183. * Gets a boolean indicating if specific vertex data is present
  24184. * @param kind defines the vertex data kind to use
  24185. * @returns true is data kind is present
  24186. */
  24187. isVerticesDataPresent(kind: string): boolean;
  24188. /**
  24189. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24190. * @returns a BoundingInfo
  24191. */
  24192. getBoundingInfo(): BoundingInfo;
  24193. /**
  24194. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24195. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24196. * @returns the current mesh
  24197. */
  24198. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24199. /**
  24200. * Overwrite the current bounding info
  24201. * @param boundingInfo defines the new bounding info
  24202. * @returns the current mesh
  24203. */
  24204. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24205. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24206. readonly useBones: boolean;
  24207. /** @hidden */
  24208. _preActivate(): void;
  24209. /** @hidden */
  24210. _preActivateForIntermediateRendering(renderId: number): void;
  24211. /** @hidden */
  24212. _activate(renderId: number): void;
  24213. /**
  24214. * Gets the current world matrix
  24215. * @returns a Matrix
  24216. */
  24217. getWorldMatrix(): Matrix;
  24218. /** @hidden */
  24219. _getWorldMatrixDeterminant(): number;
  24220. /**
  24221. * Perform relative position change from the point of view of behind the front of the mesh.
  24222. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24223. * Supports definition of mesh facing forward or backward
  24224. * @param amountRight defines the distance on the right axis
  24225. * @param amountUp defines the distance on the up axis
  24226. * @param amountForward defines the distance on the forward axis
  24227. * @returns the current mesh
  24228. */
  24229. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24230. /**
  24231. * Calculate relative position change from the point of view of behind the front of the mesh.
  24232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24233. * Supports definition of mesh facing forward or backward
  24234. * @param amountRight defines the distance on the right axis
  24235. * @param amountUp defines the distance on the up axis
  24236. * @param amountForward defines the distance on the forward axis
  24237. * @returns the new displacement vector
  24238. */
  24239. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24240. /**
  24241. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24242. * Supports definition of mesh facing forward or backward
  24243. * @param flipBack defines the flip
  24244. * @param twirlClockwise defines the twirl
  24245. * @param tiltRight defines the tilt
  24246. * @returns the current mesh
  24247. */
  24248. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24249. /**
  24250. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24251. * Supports definition of mesh facing forward or backward.
  24252. * @param flipBack defines the flip
  24253. * @param twirlClockwise defines the twirl
  24254. * @param tiltRight defines the tilt
  24255. * @returns the new rotation vector
  24256. */
  24257. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24258. /**
  24259. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24260. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24261. * @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
  24262. * @returns the new bounding vectors
  24263. */
  24264. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24265. min: Vector3;
  24266. max: Vector3;
  24267. };
  24268. /**
  24269. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24270. * This means the mesh underlying bounding box and sphere are recomputed.
  24271. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24272. * @returns the current mesh
  24273. */
  24274. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24275. /** @hidden */
  24276. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24277. /** @hidden */
  24278. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24279. /** @hidden */
  24280. _updateBoundingInfo(): AbstractMesh;
  24281. /** @hidden */
  24282. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24283. /** @hidden */
  24284. protected _afterComputeWorldMatrix(): void;
  24285. /**
  24286. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24287. * A mesh is in the frustum if its bounding box intersects the frustum
  24288. * @param frustumPlanes defines the frustum to test
  24289. * @returns true if the mesh is in the frustum planes
  24290. */
  24291. isInFrustum(frustumPlanes: Plane[]): boolean;
  24292. /**
  24293. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24294. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24295. * @param frustumPlanes defines the frustum to test
  24296. * @returns true if the mesh is completely in the frustum planes
  24297. */
  24298. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24299. /**
  24300. * True if the mesh intersects another mesh or a SolidParticle object
  24301. * @param mesh defines a target mesh or SolidParticle to test
  24302. * @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)
  24303. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24304. * @returns true if there is an intersection
  24305. */
  24306. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24307. /**
  24308. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24309. * @param point defines the point to test
  24310. * @returns true if there is an intersection
  24311. */
  24312. intersectsPoint(point: Vector3): boolean;
  24313. /**
  24314. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24316. */
  24317. checkCollisions: boolean;
  24318. /**
  24319. * Gets Collider object used to compute collisions (not physics)
  24320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24321. */
  24322. readonly collider: Collider;
  24323. /**
  24324. * Move the mesh using collision engine
  24325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24326. * @param displacement defines the requested displacement vector
  24327. * @returns the current mesh
  24328. */
  24329. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24330. private _onCollisionPositionChange;
  24331. /** @hidden */
  24332. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24333. /** @hidden */
  24334. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24335. /** @hidden */
  24336. _checkCollision(collider: Collider): AbstractMesh;
  24337. /** @hidden */
  24338. _generatePointsArray(): boolean;
  24339. /**
  24340. * Checks if the passed Ray intersects with the mesh
  24341. * @param ray defines the ray to use
  24342. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24343. * @returns the picking info
  24344. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24345. */
  24346. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24347. /**
  24348. * Clones the current mesh
  24349. * @param name defines the mesh name
  24350. * @param newParent defines the new mesh parent
  24351. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24352. * @returns the new mesh
  24353. */
  24354. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24355. /**
  24356. * Disposes all the submeshes of the current meshnp
  24357. * @returns the current mesh
  24358. */
  24359. releaseSubMeshes(): AbstractMesh;
  24360. /**
  24361. * Releases resources associated with this abstract mesh.
  24362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24364. */
  24365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24366. /**
  24367. * Adds the passed mesh as a child to the current mesh
  24368. * @param mesh defines the child mesh
  24369. * @returns the current mesh
  24370. */
  24371. addChild(mesh: AbstractMesh): AbstractMesh;
  24372. /**
  24373. * Removes the passed mesh from the current mesh children list
  24374. * @param mesh defines the child mesh
  24375. * @returns the current mesh
  24376. */
  24377. removeChild(mesh: AbstractMesh): AbstractMesh;
  24378. /** @hidden */
  24379. private _initFacetData;
  24380. /**
  24381. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24382. * This method can be called within the render loop.
  24383. * 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
  24384. * @returns the current mesh
  24385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24386. */
  24387. updateFacetData(): AbstractMesh;
  24388. /**
  24389. * Returns the facetLocalNormals array.
  24390. * The normals are expressed in the mesh local spac
  24391. * @returns an array of Vector3
  24392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24393. */
  24394. getFacetLocalNormals(): Vector3[];
  24395. /**
  24396. * Returns the facetLocalPositions array.
  24397. * The facet positions are expressed in the mesh local space
  24398. * @returns an array of Vector3
  24399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24400. */
  24401. getFacetLocalPositions(): Vector3[];
  24402. /**
  24403. * Returns the facetLocalPartioning array
  24404. * @returns an array of array of numbers
  24405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24406. */
  24407. getFacetLocalPartitioning(): number[][];
  24408. /**
  24409. * Returns the i-th facet position in the world system.
  24410. * This method allocates a new Vector3 per call
  24411. * @param i defines the facet index
  24412. * @returns a new Vector3
  24413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24414. */
  24415. getFacetPosition(i: number): Vector3;
  24416. /**
  24417. * Sets the reference Vector3 with the i-th facet position in the world system
  24418. * @param i defines the facet index
  24419. * @param ref defines the target vector
  24420. * @returns the current mesh
  24421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24422. */
  24423. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24424. /**
  24425. * Returns the i-th facet normal in the world system.
  24426. * This method allocates a new Vector3 per call
  24427. * @param i defines the facet index
  24428. * @returns a new Vector3
  24429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24430. */
  24431. getFacetNormal(i: number): Vector3;
  24432. /**
  24433. * Sets the reference Vector3 with the i-th facet normal in the world system
  24434. * @param i defines the facet index
  24435. * @param ref defines the target vector
  24436. * @returns the current mesh
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24438. */
  24439. getFacetNormalToRef(i: number, ref: Vector3): this;
  24440. /**
  24441. * 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)
  24442. * @param x defines x coordinate
  24443. * @param y defines y coordinate
  24444. * @param z defines z coordinate
  24445. * @returns the array of facet indexes
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24447. */
  24448. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24449. /**
  24450. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24451. * @param projected sets as the (x,y,z) world projection on the facet
  24452. * @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
  24453. * @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
  24454. * @param x defines x coordinate
  24455. * @param y defines y coordinate
  24456. * @param z defines z coordinate
  24457. * @returns the face index if found (or null instead)
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24461. /**
  24462. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24463. * @param projected sets as the (x,y,z) local projection on the facet
  24464. * @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
  24465. * @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
  24466. * @param x defines x coordinate
  24467. * @param y defines y coordinate
  24468. * @param z defines z coordinate
  24469. * @returns the face index if found (or null instead)
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24473. /**
  24474. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24475. * @returns the parameters
  24476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24477. */
  24478. getFacetDataParameters(): any;
  24479. /**
  24480. * Disables the feature FacetData and frees the related memory
  24481. * @returns the current mesh
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. disableFacetData(): AbstractMesh;
  24485. /**
  24486. * Updates the AbstractMesh indices array
  24487. * @param indices defines the data source
  24488. * @returns the current mesh
  24489. */
  24490. updateIndices(indices: IndicesArray): AbstractMesh;
  24491. /**
  24492. * Creates new normals data for the mesh
  24493. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24494. * @returns the current mesh
  24495. */
  24496. createNormals(updatable: boolean): AbstractMesh;
  24497. /**
  24498. * Align the mesh with a normal
  24499. * @param normal defines the normal to use
  24500. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24501. * @returns the current mesh
  24502. */
  24503. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24504. /** @hidden */
  24505. _checkOcclusionQuery(): boolean;
  24506. }
  24507. }
  24508. declare module "babylonjs/Actions/actionEvent" {
  24509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24510. import { Nullable } from "babylonjs/types";
  24511. import { Sprite } from "babylonjs/Sprites/sprite";
  24512. import { Scene } from "babylonjs/scene";
  24513. import { Vector2 } from "babylonjs/Maths/math";
  24514. /**
  24515. * Interface used to define ActionEvent
  24516. */
  24517. export interface IActionEvent {
  24518. /** The mesh or sprite that triggered the action */
  24519. source: any;
  24520. /** The X mouse cursor position at the time of the event */
  24521. pointerX: number;
  24522. /** The Y mouse cursor position at the time of the event */
  24523. pointerY: number;
  24524. /** The mesh that is currently pointed at (can be null) */
  24525. meshUnderPointer: Nullable<AbstractMesh>;
  24526. /** the original (browser) event that triggered the ActionEvent */
  24527. sourceEvent?: any;
  24528. /** additional data for the event */
  24529. additionalData?: any;
  24530. }
  24531. /**
  24532. * ActionEvent is the event being sent when an action is triggered.
  24533. */
  24534. export class ActionEvent implements IActionEvent {
  24535. /** The mesh or sprite that triggered the action */
  24536. source: any;
  24537. /** The X mouse cursor position at the time of the event */
  24538. pointerX: number;
  24539. /** The Y mouse cursor position at the time of the event */
  24540. pointerY: number;
  24541. /** The mesh that is currently pointed at (can be null) */
  24542. meshUnderPointer: Nullable<AbstractMesh>;
  24543. /** the original (browser) event that triggered the ActionEvent */
  24544. sourceEvent?: any;
  24545. /** additional data for the event */
  24546. additionalData?: any;
  24547. /**
  24548. * Creates a new ActionEvent
  24549. * @param source The mesh or sprite that triggered the action
  24550. * @param pointerX The X mouse cursor position at the time of the event
  24551. * @param pointerY The Y mouse cursor position at the time of the event
  24552. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24553. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24554. * @param additionalData additional data for the event
  24555. */
  24556. constructor(
  24557. /** The mesh or sprite that triggered the action */
  24558. source: any,
  24559. /** The X mouse cursor position at the time of the event */
  24560. pointerX: number,
  24561. /** The Y mouse cursor position at the time of the event */
  24562. pointerY: number,
  24563. /** The mesh that is currently pointed at (can be null) */
  24564. meshUnderPointer: Nullable<AbstractMesh>,
  24565. /** the original (browser) event that triggered the ActionEvent */
  24566. sourceEvent?: any,
  24567. /** additional data for the event */
  24568. additionalData?: any);
  24569. /**
  24570. * Helper function to auto-create an ActionEvent from a source mesh.
  24571. * @param source The source mesh that triggered the event
  24572. * @param evt The original (browser) event
  24573. * @param additionalData additional data for the event
  24574. * @returns the new ActionEvent
  24575. */
  24576. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24577. /**
  24578. * Helper function to auto-create an ActionEvent from a source sprite
  24579. * @param source The source sprite that triggered the event
  24580. * @param scene Scene associated with the sprite
  24581. * @param evt The original (browser) event
  24582. * @param additionalData additional data for the event
  24583. * @returns the new ActionEvent
  24584. */
  24585. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24586. /**
  24587. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24588. * @param scene the scene where the event occurred
  24589. * @param evt The original (browser) event
  24590. * @returns the new ActionEvent
  24591. */
  24592. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24593. /**
  24594. * Helper function to auto-create an ActionEvent from a primitive
  24595. * @param prim defines the target primitive
  24596. * @param pointerPos defines the pointer position
  24597. * @param evt The original (browser) event
  24598. * @param additionalData additional data for the event
  24599. * @returns the new ActionEvent
  24600. */
  24601. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24602. }
  24603. }
  24604. declare module "babylonjs/Actions/abstractActionManager" {
  24605. import { IDisposable } from "babylonjs/scene";
  24606. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24607. import { IAction } from "babylonjs/Actions/action";
  24608. /**
  24609. * Abstract class used to decouple action Manager from scene and meshes.
  24610. * Do not instantiate.
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24612. */
  24613. export abstract class AbstractActionManager implements IDisposable {
  24614. /** Gets the list of active triggers */
  24615. static Triggers: {
  24616. [key: string]: number;
  24617. };
  24618. /** Gets the cursor to use when hovering items */
  24619. hoverCursor: string;
  24620. /** Gets the list of actions */
  24621. actions: IAction[];
  24622. /**
  24623. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24624. */
  24625. isRecursive: boolean;
  24626. /**
  24627. * Releases all associated resources
  24628. */
  24629. abstract dispose(): void;
  24630. /**
  24631. * Does this action manager has pointer triggers
  24632. */
  24633. abstract readonly hasPointerTriggers: boolean;
  24634. /**
  24635. * Does this action manager has pick triggers
  24636. */
  24637. abstract readonly hasPickTriggers: boolean;
  24638. /**
  24639. * Process a specific trigger
  24640. * @param trigger defines the trigger to process
  24641. * @param evt defines the event details to be processed
  24642. */
  24643. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24644. /**
  24645. * Does this action manager handles actions of any of the given triggers
  24646. * @param triggers defines the triggers to be tested
  24647. * @return a boolean indicating whether one (or more) of the triggers is handled
  24648. */
  24649. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24650. /**
  24651. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24652. * speed.
  24653. * @param triggerA defines the trigger to be tested
  24654. * @param triggerB defines the trigger to be tested
  24655. * @return a boolean indicating whether one (or more) of the triggers is handled
  24656. */
  24657. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24658. /**
  24659. * Does this action manager handles actions of a given trigger
  24660. * @param trigger defines the trigger to be tested
  24661. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24662. * @return whether the trigger is handled
  24663. */
  24664. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24665. /**
  24666. * Serialize this manager to a JSON object
  24667. * @param name defines the property name to store this manager
  24668. * @returns a JSON representation of this manager
  24669. */
  24670. abstract serialize(name: string): any;
  24671. /**
  24672. * Does exist one action manager with at least one trigger
  24673. **/
  24674. static readonly HasTriggers: boolean;
  24675. /**
  24676. * Does exist one action manager with at least one pick trigger
  24677. **/
  24678. static readonly HasPickTriggers: boolean;
  24679. /**
  24680. * Does exist one action manager that handles actions of a given trigger
  24681. * @param trigger defines the trigger to be tested
  24682. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24683. **/
  24684. static HasSpecificTrigger(trigger: number): boolean;
  24685. }
  24686. }
  24687. declare module "babylonjs/node" {
  24688. import { Scene } from "babylonjs/scene";
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Matrix } from "babylonjs/Maths/math";
  24691. import { Engine } from "babylonjs/Engines/engine";
  24692. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24693. import { Observable } from "babylonjs/Misc/observable";
  24694. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24695. import { Animatable } from "babylonjs/Animations/animatable";
  24696. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24697. import { Animation } from "babylonjs/Animations/animation";
  24698. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24700. /**
  24701. * Defines how a node can be built from a string name.
  24702. */
  24703. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24704. /**
  24705. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24706. */
  24707. export class Node implements IBehaviorAware<Node> {
  24708. /** @hidden */
  24709. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24710. private static _NodeConstructors;
  24711. /**
  24712. * Add a new node constructor
  24713. * @param type defines the type name of the node to construct
  24714. * @param constructorFunc defines the constructor function
  24715. */
  24716. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24717. /**
  24718. * Returns a node constructor based on type name
  24719. * @param type defines the type name
  24720. * @param name defines the new node name
  24721. * @param scene defines the hosting scene
  24722. * @param options defines optional options to transmit to constructors
  24723. * @returns the new constructor or null
  24724. */
  24725. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24726. /**
  24727. * Gets or sets the name of the node
  24728. */
  24729. name: string;
  24730. /**
  24731. * Gets or sets the id of the node
  24732. */
  24733. id: string;
  24734. /**
  24735. * Gets or sets the unique id of the node
  24736. */
  24737. uniqueId: number;
  24738. /**
  24739. * Gets or sets a string used to store user defined state for the node
  24740. */
  24741. state: string;
  24742. /**
  24743. * Gets or sets an object used to store user defined information for the node
  24744. */
  24745. metadata: any;
  24746. /**
  24747. * For internal use only. Please do not use.
  24748. */
  24749. reservedDataStore: any;
  24750. /**
  24751. * Gets or sets a boolean used to define if the node must be serialized
  24752. */
  24753. doNotSerialize: boolean;
  24754. /** @hidden */
  24755. _isDisposed: boolean;
  24756. /**
  24757. * Gets a list of Animations associated with the node
  24758. */
  24759. animations: import("babylonjs/Animations/animation").Animation[];
  24760. protected _ranges: {
  24761. [name: string]: Nullable<AnimationRange>;
  24762. };
  24763. /**
  24764. * Callback raised when the node is ready to be used
  24765. */
  24766. onReady: (node: Node) => void;
  24767. private _isEnabled;
  24768. private _isParentEnabled;
  24769. private _isReady;
  24770. /** @hidden */
  24771. _currentRenderId: number;
  24772. private _parentRenderId;
  24773. protected _childRenderId: number;
  24774. /** @hidden */
  24775. _waitingParentId: Nullable<string>;
  24776. /** @hidden */
  24777. _scene: Scene;
  24778. /** @hidden */
  24779. _cache: any;
  24780. private _parentNode;
  24781. private _children;
  24782. /** @hidden */
  24783. _worldMatrix: Matrix;
  24784. /** @hidden */
  24785. _worldMatrixDeterminant: number;
  24786. /** @hidden */
  24787. private _sceneRootNodesIndex;
  24788. /**
  24789. * Gets a boolean indicating if the node has been disposed
  24790. * @returns true if the node was disposed
  24791. */
  24792. isDisposed(): boolean;
  24793. /**
  24794. * Gets or sets the parent of the node
  24795. */
  24796. parent: Nullable<Node>;
  24797. private addToSceneRootNodes;
  24798. private removeFromSceneRootNodes;
  24799. private _animationPropertiesOverride;
  24800. /**
  24801. * Gets or sets the animation properties override
  24802. */
  24803. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24804. /**
  24805. * Gets a string idenfifying the name of the class
  24806. * @returns "Node" string
  24807. */
  24808. getClassName(): string;
  24809. /** @hidden */
  24810. readonly _isNode: boolean;
  24811. /**
  24812. * An event triggered when the mesh is disposed
  24813. */
  24814. onDisposeObservable: Observable<Node>;
  24815. private _onDisposeObserver;
  24816. /**
  24817. * Sets a callback that will be raised when the node will be disposed
  24818. */
  24819. onDispose: () => void;
  24820. /**
  24821. * Creates a new Node
  24822. * @param name the name and id to be given to this node
  24823. * @param scene the scene this node will be added to
  24824. * @param addToRootNodes the node will be added to scene.rootNodes
  24825. */
  24826. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24827. /**
  24828. * Gets the scene of the node
  24829. * @returns a scene
  24830. */
  24831. getScene(): Scene;
  24832. /**
  24833. * Gets the engine of the node
  24834. * @returns a Engine
  24835. */
  24836. getEngine(): Engine;
  24837. private _behaviors;
  24838. /**
  24839. * Attach a behavior to the node
  24840. * @see http://doc.babylonjs.com/features/behaviour
  24841. * @param behavior defines the behavior to attach
  24842. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24843. * @returns the current Node
  24844. */
  24845. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24846. /**
  24847. * Remove an attached behavior
  24848. * @see http://doc.babylonjs.com/features/behaviour
  24849. * @param behavior defines the behavior to attach
  24850. * @returns the current Node
  24851. */
  24852. removeBehavior(behavior: Behavior<Node>): Node;
  24853. /**
  24854. * Gets the list of attached behaviors
  24855. * @see http://doc.babylonjs.com/features/behaviour
  24856. */
  24857. readonly behaviors: Behavior<Node>[];
  24858. /**
  24859. * Gets an attached behavior by name
  24860. * @param name defines the name of the behavior to look for
  24861. * @see http://doc.babylonjs.com/features/behaviour
  24862. * @returns null if behavior was not found else the requested behavior
  24863. */
  24864. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24865. /**
  24866. * Returns the latest update of the World matrix
  24867. * @returns a Matrix
  24868. */
  24869. getWorldMatrix(): Matrix;
  24870. /** @hidden */
  24871. _getWorldMatrixDeterminant(): number;
  24872. /**
  24873. * Returns directly the latest state of the mesh World matrix.
  24874. * A Matrix is returned.
  24875. */
  24876. readonly worldMatrixFromCache: Matrix;
  24877. /** @hidden */
  24878. _initCache(): void;
  24879. /** @hidden */
  24880. updateCache(force?: boolean): void;
  24881. /** @hidden */
  24882. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24883. /** @hidden */
  24884. _updateCache(ignoreParentClass?: boolean): void;
  24885. /** @hidden */
  24886. _isSynchronized(): boolean;
  24887. /** @hidden */
  24888. _markSyncedWithParent(): void;
  24889. /** @hidden */
  24890. isSynchronizedWithParent(): boolean;
  24891. /** @hidden */
  24892. isSynchronized(): boolean;
  24893. /**
  24894. * Is this node ready to be used/rendered
  24895. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24896. * @return true if the node is ready
  24897. */
  24898. isReady(completeCheck?: boolean): boolean;
  24899. /**
  24900. * Is this node enabled?
  24901. * 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
  24902. * @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
  24903. * @return whether this node (and its parent) is enabled
  24904. */
  24905. isEnabled(checkAncestors?: boolean): boolean;
  24906. /** @hidden */
  24907. protected _syncParentEnabledState(): void;
  24908. /**
  24909. * Set the enabled state of this node
  24910. * @param value defines the new enabled state
  24911. */
  24912. setEnabled(value: boolean): void;
  24913. /**
  24914. * Is this node a descendant of the given node?
  24915. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24916. * @param ancestor defines the parent node to inspect
  24917. * @returns a boolean indicating if this node is a descendant of the given node
  24918. */
  24919. isDescendantOf(ancestor: Node): boolean;
  24920. /** @hidden */
  24921. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24922. /**
  24923. * Will return all nodes that have this node as ascendant
  24924. * @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
  24925. * @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
  24926. * @return all children nodes of all types
  24927. */
  24928. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24929. /**
  24930. * Get all child-meshes of this node
  24931. * @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)
  24932. * @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
  24933. * @returns an array of AbstractMesh
  24934. */
  24935. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24936. /**
  24937. * Get all direct children of this node
  24938. * @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
  24939. * @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)
  24940. * @returns an array of Node
  24941. */
  24942. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24943. /** @hidden */
  24944. _setReady(state: boolean): void;
  24945. /**
  24946. * Get an animation by name
  24947. * @param name defines the name of the animation to look for
  24948. * @returns null if not found else the requested animation
  24949. */
  24950. getAnimationByName(name: string): Nullable<Animation>;
  24951. /**
  24952. * Creates an animation range for this node
  24953. * @param name defines the name of the range
  24954. * @param from defines the starting key
  24955. * @param to defines the end key
  24956. */
  24957. createAnimationRange(name: string, from: number, to: number): void;
  24958. /**
  24959. * Delete a specific animation range
  24960. * @param name defines the name of the range to delete
  24961. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24962. */
  24963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24964. /**
  24965. * Get an animation range by name
  24966. * @param name defines the name of the animation range to look for
  24967. * @returns null if not found else the requested animation range
  24968. */
  24969. getAnimationRange(name: string): Nullable<AnimationRange>;
  24970. /**
  24971. * Will start the animation sequence
  24972. * @param name defines the range frames for animation sequence
  24973. * @param loop defines if the animation should loop (false by default)
  24974. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24975. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24976. * @returns the object created for this animation. If range does not exist, it will return null
  24977. */
  24978. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24979. /**
  24980. * Serialize animation ranges into a JSON compatible object
  24981. * @returns serialization object
  24982. */
  24983. serializeAnimationRanges(): any;
  24984. /**
  24985. * Computes the world matrix of the node
  24986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24987. * @returns the world matrix
  24988. */
  24989. computeWorldMatrix(force?: boolean): Matrix;
  24990. /**
  24991. * Releases resources associated with this node.
  24992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24994. */
  24995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24996. /**
  24997. * Parse animation range data from a serialization object and store them into a given node
  24998. * @param node defines where to store the animation ranges
  24999. * @param parsedNode defines the serialization object to read data from
  25000. * @param scene defines the hosting scene
  25001. */
  25002. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25003. }
  25004. }
  25005. declare module "babylonjs/Animations/animation" {
  25006. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25007. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25008. import { Nullable } from "babylonjs/types";
  25009. import { Scene } from "babylonjs/scene";
  25010. import { IAnimatable } from "babylonjs/Misc/tools";
  25011. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25012. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25013. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25014. import { Node } from "babylonjs/node";
  25015. import { Animatable } from "babylonjs/Animations/animatable";
  25016. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25017. /**
  25018. * Class used to store any kind of animation
  25019. */
  25020. export class Animation {
  25021. /**Name of the animation */
  25022. name: string;
  25023. /**Property to animate */
  25024. targetProperty: string;
  25025. /**The frames per second of the animation */
  25026. framePerSecond: number;
  25027. /**The data type of the animation */
  25028. dataType: number;
  25029. /**The loop mode of the animation */
  25030. loopMode?: number | undefined;
  25031. /**Specifies if blending should be enabled */
  25032. enableBlending?: boolean | undefined;
  25033. /**
  25034. * Use matrix interpolation instead of using direct key value when animating matrices
  25035. */
  25036. static AllowMatricesInterpolation: boolean;
  25037. /**
  25038. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25039. */
  25040. static AllowMatrixDecomposeForInterpolation: boolean;
  25041. /**
  25042. * Stores the key frames of the animation
  25043. */
  25044. private _keys;
  25045. /**
  25046. * Stores the easing function of the animation
  25047. */
  25048. private _easingFunction;
  25049. /**
  25050. * @hidden Internal use only
  25051. */
  25052. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25053. /**
  25054. * The set of event that will be linked to this animation
  25055. */
  25056. private _events;
  25057. /**
  25058. * Stores an array of target property paths
  25059. */
  25060. targetPropertyPath: string[];
  25061. /**
  25062. * Stores the blending speed of the animation
  25063. */
  25064. blendingSpeed: number;
  25065. /**
  25066. * Stores the animation ranges for the animation
  25067. */
  25068. private _ranges;
  25069. /**
  25070. * @hidden Internal use
  25071. */
  25072. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25073. /**
  25074. * Sets up an animation
  25075. * @param property The property to animate
  25076. * @param animationType The animation type to apply
  25077. * @param framePerSecond The frames per second of the animation
  25078. * @param easingFunction The easing function used in the animation
  25079. * @returns The created animation
  25080. */
  25081. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25082. /**
  25083. * Create and start an animation on a node
  25084. * @param name defines the name of the global animation that will be run on all nodes
  25085. * @param node defines the root node where the animation will take place
  25086. * @param targetProperty defines property to animate
  25087. * @param framePerSecond defines the number of frame per second yo use
  25088. * @param totalFrame defines the number of frames in total
  25089. * @param from defines the initial value
  25090. * @param to defines the final value
  25091. * @param loopMode defines which loop mode you want to use (off by default)
  25092. * @param easingFunction defines the easing function to use (linear by default)
  25093. * @param onAnimationEnd defines the callback to call when animation end
  25094. * @returns the animatable created for this animation
  25095. */
  25096. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25097. /**
  25098. * Create and start an animation on a node and its descendants
  25099. * @param name defines the name of the global animation that will be run on all nodes
  25100. * @param node defines the root node where the animation will take place
  25101. * @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
  25102. * @param targetProperty defines property to animate
  25103. * @param framePerSecond defines the number of frame per second to use
  25104. * @param totalFrame defines the number of frames in total
  25105. * @param from defines the initial value
  25106. * @param to defines the final value
  25107. * @param loopMode defines which loop mode you want to use (off by default)
  25108. * @param easingFunction defines the easing function to use (linear by default)
  25109. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25110. * @returns the list of animatables created for all nodes
  25111. * @example https://www.babylonjs-playground.com/#MH0VLI
  25112. */
  25113. 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[]>;
  25114. /**
  25115. * Creates a new animation, merges it with the existing animations and starts it
  25116. * @param name Name of the animation
  25117. * @param node Node which contains the scene that begins the animations
  25118. * @param targetProperty Specifies which property to animate
  25119. * @param framePerSecond The frames per second of the animation
  25120. * @param totalFrame The total number of frames
  25121. * @param from The frame at the beginning of the animation
  25122. * @param to The frame at the end of the animation
  25123. * @param loopMode Specifies the loop mode of the animation
  25124. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25125. * @param onAnimationEnd Callback to run once the animation is complete
  25126. * @returns Nullable animation
  25127. */
  25128. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25129. /**
  25130. * Transition property of an host to the target Value
  25131. * @param property The property to transition
  25132. * @param targetValue The target Value of the property
  25133. * @param host The object where the property to animate belongs
  25134. * @param scene Scene used to run the animation
  25135. * @param frameRate Framerate (in frame/s) to use
  25136. * @param transition The transition type we want to use
  25137. * @param duration The duration of the animation, in milliseconds
  25138. * @param onAnimationEnd Callback trigger at the end of the animation
  25139. * @returns Nullable animation
  25140. */
  25141. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25142. /**
  25143. * Return the array of runtime animations currently using this animation
  25144. */
  25145. readonly runtimeAnimations: RuntimeAnimation[];
  25146. /**
  25147. * Specifies if any of the runtime animations are currently running
  25148. */
  25149. readonly hasRunningRuntimeAnimations: boolean;
  25150. /**
  25151. * Initializes the animation
  25152. * @param name Name of the animation
  25153. * @param targetProperty Property to animate
  25154. * @param framePerSecond The frames per second of the animation
  25155. * @param dataType The data type of the animation
  25156. * @param loopMode The loop mode of the animation
  25157. * @param enableBlending Specifies if blending should be enabled
  25158. */
  25159. constructor(
  25160. /**Name of the animation */
  25161. name: string,
  25162. /**Property to animate */
  25163. targetProperty: string,
  25164. /**The frames per second of the animation */
  25165. framePerSecond: number,
  25166. /**The data type of the animation */
  25167. dataType: number,
  25168. /**The loop mode of the animation */
  25169. loopMode?: number | undefined,
  25170. /**Specifies if blending should be enabled */
  25171. enableBlending?: boolean | undefined);
  25172. /**
  25173. * Converts the animation to a string
  25174. * @param fullDetails support for multiple levels of logging within scene loading
  25175. * @returns String form of the animation
  25176. */
  25177. toString(fullDetails?: boolean): string;
  25178. /**
  25179. * Add an event to this animation
  25180. * @param event Event to add
  25181. */
  25182. addEvent(event: AnimationEvent): void;
  25183. /**
  25184. * Remove all events found at the given frame
  25185. * @param frame The frame to remove events from
  25186. */
  25187. removeEvents(frame: number): void;
  25188. /**
  25189. * Retrieves all the events from the animation
  25190. * @returns Events from the animation
  25191. */
  25192. getEvents(): AnimationEvent[];
  25193. /**
  25194. * Creates an animation range
  25195. * @param name Name of the animation range
  25196. * @param from Starting frame of the animation range
  25197. * @param to Ending frame of the animation
  25198. */
  25199. createRange(name: string, from: number, to: number): void;
  25200. /**
  25201. * Deletes an animation range by name
  25202. * @param name Name of the animation range to delete
  25203. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25204. */
  25205. deleteRange(name: string, deleteFrames?: boolean): void;
  25206. /**
  25207. * Gets the animation range by name, or null if not defined
  25208. * @param name Name of the animation range
  25209. * @returns Nullable animation range
  25210. */
  25211. getRange(name: string): Nullable<AnimationRange>;
  25212. /**
  25213. * Gets the key frames from the animation
  25214. * @returns The key frames of the animation
  25215. */
  25216. getKeys(): Array<IAnimationKey>;
  25217. /**
  25218. * Gets the highest frame rate of the animation
  25219. * @returns Highest frame rate of the animation
  25220. */
  25221. getHighestFrame(): number;
  25222. /**
  25223. * Gets the easing function of the animation
  25224. * @returns Easing function of the animation
  25225. */
  25226. getEasingFunction(): IEasingFunction;
  25227. /**
  25228. * Sets the easing function of the animation
  25229. * @param easingFunction A custom mathematical formula for animation
  25230. */
  25231. setEasingFunction(easingFunction: EasingFunction): void;
  25232. /**
  25233. * Interpolates a scalar linearly
  25234. * @param startValue Start value of the animation curve
  25235. * @param endValue End value of the animation curve
  25236. * @param gradient Scalar amount to interpolate
  25237. * @returns Interpolated scalar value
  25238. */
  25239. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25240. /**
  25241. * Interpolates a scalar cubically
  25242. * @param startValue Start value of the animation curve
  25243. * @param outTangent End tangent of the animation
  25244. * @param endValue End value of the animation curve
  25245. * @param inTangent Start tangent of the animation curve
  25246. * @param gradient Scalar amount to interpolate
  25247. * @returns Interpolated scalar value
  25248. */
  25249. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25250. /**
  25251. * Interpolates a quaternion using a spherical linear interpolation
  25252. * @param startValue Start value of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param gradient Scalar amount to interpolate
  25255. * @returns Interpolated quaternion value
  25256. */
  25257. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25258. /**
  25259. * Interpolates a quaternion cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation curve
  25262. * @param endValue End value of the animation curve
  25263. * @param inTangent Start tangent of the animation curve
  25264. * @param gradient Scalar amount to interpolate
  25265. * @returns Interpolated quaternion value
  25266. */
  25267. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25268. /**
  25269. * Interpolates a Vector3 linearl
  25270. * @param startValue Start value of the animation curve
  25271. * @param endValue End value of the animation curve
  25272. * @param gradient Scalar amount to interpolate
  25273. * @returns Interpolated scalar value
  25274. */
  25275. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25276. /**
  25277. * Interpolates a Vector3 cubically
  25278. * @param startValue Start value of the animation curve
  25279. * @param outTangent End tangent of the animation
  25280. * @param endValue End value of the animation curve
  25281. * @param inTangent Start tangent of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns InterpolatedVector3 value
  25284. */
  25285. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25286. /**
  25287. * Interpolates a Vector2 linearly
  25288. * @param startValue Start value of the animation curve
  25289. * @param endValue End value of the animation curve
  25290. * @param gradient Scalar amount to interpolate
  25291. * @returns Interpolated Vector2 value
  25292. */
  25293. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25294. /**
  25295. * Interpolates a Vector2 cubically
  25296. * @param startValue Start value of the animation curve
  25297. * @param outTangent End tangent of the animation
  25298. * @param endValue End value of the animation curve
  25299. * @param inTangent Start tangent of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns Interpolated Vector2 value
  25302. */
  25303. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25304. /**
  25305. * Interpolates a size linearly
  25306. * @param startValue Start value of the animation curve
  25307. * @param endValue End value of the animation curve
  25308. * @param gradient Scalar amount to interpolate
  25309. * @returns Interpolated Size value
  25310. */
  25311. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25312. /**
  25313. * Interpolates a Color3 linearly
  25314. * @param startValue Start value of the animation curve
  25315. * @param endValue End value of the animation curve
  25316. * @param gradient Scalar amount to interpolate
  25317. * @returns Interpolated Color3 value
  25318. */
  25319. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25320. /**
  25321. * @hidden Internal use only
  25322. */
  25323. _getKeyValue(value: any): any;
  25324. /**
  25325. * @hidden Internal use only
  25326. */
  25327. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25328. /**
  25329. * Defines the function to use to interpolate matrices
  25330. * @param startValue defines the start matrix
  25331. * @param endValue defines the end matrix
  25332. * @param gradient defines the gradient between both matrices
  25333. * @param result defines an optional target matrix where to store the interpolation
  25334. * @returns the interpolated matrix
  25335. */
  25336. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25337. /**
  25338. * Makes a copy of the animation
  25339. * @returns Cloned animation
  25340. */
  25341. clone(): Animation;
  25342. /**
  25343. * Sets the key frames of the animation
  25344. * @param values The animation key frames to set
  25345. */
  25346. setKeys(values: Array<IAnimationKey>): void;
  25347. /**
  25348. * Serializes the animation to an object
  25349. * @returns Serialized object
  25350. */
  25351. serialize(): any;
  25352. /**
  25353. * Float animation type
  25354. */
  25355. private static _ANIMATIONTYPE_FLOAT;
  25356. /**
  25357. * Vector3 animation type
  25358. */
  25359. private static _ANIMATIONTYPE_VECTOR3;
  25360. /**
  25361. * Quaternion animation type
  25362. */
  25363. private static _ANIMATIONTYPE_QUATERNION;
  25364. /**
  25365. * Matrix animation type
  25366. */
  25367. private static _ANIMATIONTYPE_MATRIX;
  25368. /**
  25369. * Color3 animation type
  25370. */
  25371. private static _ANIMATIONTYPE_COLOR3;
  25372. /**
  25373. * Vector2 animation type
  25374. */
  25375. private static _ANIMATIONTYPE_VECTOR2;
  25376. /**
  25377. * Size animation type
  25378. */
  25379. private static _ANIMATIONTYPE_SIZE;
  25380. /**
  25381. * Relative Loop Mode
  25382. */
  25383. private static _ANIMATIONLOOPMODE_RELATIVE;
  25384. /**
  25385. * Cycle Loop Mode
  25386. */
  25387. private static _ANIMATIONLOOPMODE_CYCLE;
  25388. /**
  25389. * Constant Loop Mode
  25390. */
  25391. private static _ANIMATIONLOOPMODE_CONSTANT;
  25392. /**
  25393. * Get the float animation type
  25394. */
  25395. static readonly ANIMATIONTYPE_FLOAT: number;
  25396. /**
  25397. * Get the Vector3 animation type
  25398. */
  25399. static readonly ANIMATIONTYPE_VECTOR3: number;
  25400. /**
  25401. * Get the Vector2 animation type
  25402. */
  25403. static readonly ANIMATIONTYPE_VECTOR2: number;
  25404. /**
  25405. * Get the Size animation type
  25406. */
  25407. static readonly ANIMATIONTYPE_SIZE: number;
  25408. /**
  25409. * Get the Quaternion animation type
  25410. */
  25411. static readonly ANIMATIONTYPE_QUATERNION: number;
  25412. /**
  25413. * Get the Matrix animation type
  25414. */
  25415. static readonly ANIMATIONTYPE_MATRIX: number;
  25416. /**
  25417. * Get the Color3 animation type
  25418. */
  25419. static readonly ANIMATIONTYPE_COLOR3: number;
  25420. /**
  25421. * Get the Relative Loop Mode
  25422. */
  25423. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25424. /**
  25425. * Get the Cycle Loop Mode
  25426. */
  25427. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25428. /**
  25429. * Get the Constant Loop Mode
  25430. */
  25431. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25432. /** @hidden */
  25433. static _UniversalLerp(left: any, right: any, amount: number): any;
  25434. /**
  25435. * Parses an animation object and creates an animation
  25436. * @param parsedAnimation Parsed animation object
  25437. * @returns Animation object
  25438. */
  25439. static Parse(parsedAnimation: any): Animation;
  25440. /**
  25441. * Appends the serialized animations from the source animations
  25442. * @param source Source containing the animations
  25443. * @param destination Target to store the animations
  25444. */
  25445. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25446. }
  25447. }
  25448. declare module "babylonjs/Materials/Textures/baseTexture" {
  25449. import { Observable } from "babylonjs/Misc/observable";
  25450. import { IAnimatable } from "babylonjs/Misc/tools";
  25451. import { Nullable } from "babylonjs/types";
  25452. import { Scene } from "babylonjs/scene";
  25453. import { Matrix, ISize } from "babylonjs/Maths/math";
  25454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25456. /**
  25457. * Base class of all the textures in babylon.
  25458. * It groups all the common properties the materials, post process, lights... might need
  25459. * in order to make a correct use of the texture.
  25460. */
  25461. export class BaseTexture implements IAnimatable {
  25462. /**
  25463. * Default anisotropic filtering level for the application.
  25464. * It is set to 4 as a good tradeoff between perf and quality.
  25465. */
  25466. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25467. /**
  25468. * Gets or sets the unique id of the texture
  25469. */
  25470. uniqueId: number;
  25471. /**
  25472. * Define the name of the texture.
  25473. */
  25474. name: string;
  25475. /**
  25476. * Gets or sets an object used to store user defined information.
  25477. */
  25478. metadata: any;
  25479. /**
  25480. * For internal use only. Please do not use.
  25481. */
  25482. reservedDataStore: any;
  25483. private _hasAlpha;
  25484. /**
  25485. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25486. */
  25487. hasAlpha: boolean;
  25488. /**
  25489. * Defines if the alpha value should be determined via the rgb values.
  25490. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25491. */
  25492. getAlphaFromRGB: boolean;
  25493. /**
  25494. * Intensity or strength of the texture.
  25495. * It is commonly used by materials to fine tune the intensity of the texture
  25496. */
  25497. level: number;
  25498. /**
  25499. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25500. * This is part of the texture as textures usually maps to one uv set.
  25501. */
  25502. coordinatesIndex: number;
  25503. private _coordinatesMode;
  25504. /**
  25505. * How a texture is mapped.
  25506. *
  25507. * | Value | Type | Description |
  25508. * | ----- | ----------------------------------- | ----------- |
  25509. * | 0 | EXPLICIT_MODE | |
  25510. * | 1 | SPHERICAL_MODE | |
  25511. * | 2 | PLANAR_MODE | |
  25512. * | 3 | CUBIC_MODE | |
  25513. * | 4 | PROJECTION_MODE | |
  25514. * | 5 | SKYBOX_MODE | |
  25515. * | 6 | INVCUBIC_MODE | |
  25516. * | 7 | EQUIRECTANGULAR_MODE | |
  25517. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25518. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25519. */
  25520. coordinatesMode: number;
  25521. /**
  25522. * | Value | Type | Description |
  25523. * | ----- | ------------------ | ----------- |
  25524. * | 0 | CLAMP_ADDRESSMODE | |
  25525. * | 1 | WRAP_ADDRESSMODE | |
  25526. * | 2 | MIRROR_ADDRESSMODE | |
  25527. */
  25528. wrapU: number;
  25529. /**
  25530. * | Value | Type | Description |
  25531. * | ----- | ------------------ | ----------- |
  25532. * | 0 | CLAMP_ADDRESSMODE | |
  25533. * | 1 | WRAP_ADDRESSMODE | |
  25534. * | 2 | MIRROR_ADDRESSMODE | |
  25535. */
  25536. wrapV: number;
  25537. /**
  25538. * | Value | Type | Description |
  25539. * | ----- | ------------------ | ----------- |
  25540. * | 0 | CLAMP_ADDRESSMODE | |
  25541. * | 1 | WRAP_ADDRESSMODE | |
  25542. * | 2 | MIRROR_ADDRESSMODE | |
  25543. */
  25544. wrapR: number;
  25545. /**
  25546. * With compliant hardware and browser (supporting anisotropic filtering)
  25547. * this defines the level of anisotropic filtering in the texture.
  25548. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25549. */
  25550. anisotropicFilteringLevel: number;
  25551. /**
  25552. * Define if the texture is a cube texture or if false a 2d texture.
  25553. */
  25554. isCube: boolean;
  25555. /**
  25556. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25557. */
  25558. is3D: boolean;
  25559. /**
  25560. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25561. * HDR texture are usually stored in linear space.
  25562. * This only impacts the PBR and Background materials
  25563. */
  25564. gammaSpace: boolean;
  25565. /**
  25566. * Gets whether or not the texture contains RGBD data.
  25567. */
  25568. readonly isRGBD: boolean;
  25569. /**
  25570. * Is Z inverted in the texture (useful in a cube texture).
  25571. */
  25572. invertZ: boolean;
  25573. /**
  25574. * Are mip maps generated for this texture or not.
  25575. */
  25576. readonly noMipmap: boolean;
  25577. /**
  25578. * @hidden
  25579. */
  25580. lodLevelInAlpha: boolean;
  25581. /**
  25582. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25583. */
  25584. lodGenerationOffset: number;
  25585. /**
  25586. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25587. */
  25588. lodGenerationScale: number;
  25589. /**
  25590. * Define if the texture is a render target.
  25591. */
  25592. isRenderTarget: boolean;
  25593. /**
  25594. * Define the unique id of the texture in the scene.
  25595. */
  25596. readonly uid: string;
  25597. /**
  25598. * Return a string representation of the texture.
  25599. * @returns the texture as a string
  25600. */
  25601. toString(): string;
  25602. /**
  25603. * Get the class name of the texture.
  25604. * @returns "BaseTexture"
  25605. */
  25606. getClassName(): string;
  25607. /**
  25608. * Define the list of animation attached to the texture.
  25609. */
  25610. animations: import("babylonjs/Animations/animation").Animation[];
  25611. /**
  25612. * An event triggered when the texture is disposed.
  25613. */
  25614. onDisposeObservable: Observable<BaseTexture>;
  25615. private _onDisposeObserver;
  25616. /**
  25617. * Callback triggered when the texture has been disposed.
  25618. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25619. */
  25620. onDispose: () => void;
  25621. /**
  25622. * Define the current state of the loading sequence when in delayed load mode.
  25623. */
  25624. delayLoadState: number;
  25625. private _scene;
  25626. /** @hidden */
  25627. _texture: Nullable<InternalTexture>;
  25628. private _uid;
  25629. /**
  25630. * Define if the texture is preventinga material to render or not.
  25631. * If not and the texture is not ready, the engine will use a default black texture instead.
  25632. */
  25633. readonly isBlocking: boolean;
  25634. /**
  25635. * Instantiates a new BaseTexture.
  25636. * Base class of all the textures in babylon.
  25637. * It groups all the common properties the materials, post process, lights... might need
  25638. * in order to make a correct use of the texture.
  25639. * @param scene Define the scene the texture blongs to
  25640. */
  25641. constructor(scene: Nullable<Scene>);
  25642. /**
  25643. * Get the scene the texture belongs to.
  25644. * @returns the scene or null if undefined
  25645. */
  25646. getScene(): Nullable<Scene>;
  25647. /**
  25648. * Get the texture transform matrix used to offset tile the texture for istance.
  25649. * @returns the transformation matrix
  25650. */
  25651. getTextureMatrix(): Matrix;
  25652. /**
  25653. * Get the texture reflection matrix used to rotate/transform the reflection.
  25654. * @returns the reflection matrix
  25655. */
  25656. getReflectionTextureMatrix(): Matrix;
  25657. /**
  25658. * Get the underlying lower level texture from Babylon.
  25659. * @returns the insternal texture
  25660. */
  25661. getInternalTexture(): Nullable<InternalTexture>;
  25662. /**
  25663. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25664. * @returns true if ready or not blocking
  25665. */
  25666. isReadyOrNotBlocking(): boolean;
  25667. /**
  25668. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25669. * @returns true if fully ready
  25670. */
  25671. isReady(): boolean;
  25672. private _cachedSize;
  25673. /**
  25674. * Get the size of the texture.
  25675. * @returns the texture size.
  25676. */
  25677. getSize(): ISize;
  25678. /**
  25679. * Get the base size of the texture.
  25680. * It can be different from the size if the texture has been resized for POT for instance
  25681. * @returns the base size
  25682. */
  25683. getBaseSize(): ISize;
  25684. /**
  25685. * Update the sampling mode of the texture.
  25686. * Default is Trilinear mode.
  25687. *
  25688. * | Value | Type | Description |
  25689. * | ----- | ------------------ | ----------- |
  25690. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25691. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25692. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25693. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25694. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25695. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25696. * | 7 | NEAREST_LINEAR | |
  25697. * | 8 | NEAREST_NEAREST | |
  25698. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25699. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25700. * | 11 | LINEAR_LINEAR | |
  25701. * | 12 | LINEAR_NEAREST | |
  25702. *
  25703. * > _mag_: magnification filter (close to the viewer)
  25704. * > _min_: minification filter (far from the viewer)
  25705. * > _mip_: filter used between mip map levels
  25706. *@param samplingMode Define the new sampling mode of the texture
  25707. */
  25708. updateSamplingMode(samplingMode: number): void;
  25709. /**
  25710. * Scales the texture if is `canRescale()`
  25711. * @param ratio the resize factor we want to use to rescale
  25712. */
  25713. scale(ratio: number): void;
  25714. /**
  25715. * Get if the texture can rescale.
  25716. */
  25717. readonly canRescale: boolean;
  25718. /** @hidden */
  25719. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25720. /** @hidden */
  25721. _rebuild(): void;
  25722. /**
  25723. * Triggers the load sequence in delayed load mode.
  25724. */
  25725. delayLoad(): void;
  25726. /**
  25727. * Clones the texture.
  25728. * @returns the cloned texture
  25729. */
  25730. clone(): Nullable<BaseTexture>;
  25731. /**
  25732. * Get the texture underlying type (INT, FLOAT...)
  25733. */
  25734. readonly textureType: number;
  25735. /**
  25736. * Get the texture underlying format (RGB, RGBA...)
  25737. */
  25738. readonly textureFormat: number;
  25739. /**
  25740. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25741. * This will returns an RGBA array buffer containing either in values (0-255) or
  25742. * float values (0-1) depending of the underlying buffer type.
  25743. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25744. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25745. * @param buffer defines a user defined buffer to fill with data (can be null)
  25746. * @returns The Array buffer containing the pixels data.
  25747. */
  25748. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25749. /**
  25750. * Release and destroy the underlying lower level texture aka internalTexture.
  25751. */
  25752. releaseInternalTexture(): void;
  25753. /**
  25754. * Get the polynomial representation of the texture data.
  25755. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25756. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25757. */
  25758. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25759. /** @hidden */
  25760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25761. /** @hidden */
  25762. readonly _lodTextureMid: Nullable<BaseTexture>;
  25763. /** @hidden */
  25764. readonly _lodTextureLow: Nullable<BaseTexture>;
  25765. /**
  25766. * Dispose the texture and release its associated resources.
  25767. */
  25768. dispose(): void;
  25769. /**
  25770. * Serialize the texture into a JSON representation that can be parsed later on.
  25771. * @returns the JSON representation of the texture
  25772. */
  25773. serialize(): any;
  25774. /**
  25775. * Helper function to be called back once a list of texture contains only ready textures.
  25776. * @param textures Define the list of textures to wait for
  25777. * @param callback Define the callback triggered once the entire list will be ready
  25778. */
  25779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25780. }
  25781. }
  25782. declare module "babylonjs/Materials/uniformBuffer" {
  25783. import { Nullable, FloatArray } from "babylonjs/types";
  25784. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25785. import { Engine } from "babylonjs/Engines/engine";
  25786. import { Effect } from "babylonjs/Materials/effect";
  25787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25788. /**
  25789. * Uniform buffer objects.
  25790. *
  25791. * Handles blocks of uniform on the GPU.
  25792. *
  25793. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25794. *
  25795. * For more information, please refer to :
  25796. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25797. */
  25798. export class UniformBuffer {
  25799. private _engine;
  25800. private _buffer;
  25801. private _data;
  25802. private _bufferData;
  25803. private _dynamic?;
  25804. private _uniformLocations;
  25805. private _uniformSizes;
  25806. private _uniformLocationPointer;
  25807. private _needSync;
  25808. private _noUBO;
  25809. private _currentEffect;
  25810. private static _MAX_UNIFORM_SIZE;
  25811. private static _tempBuffer;
  25812. /**
  25813. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25814. * This is dynamic to allow compat with webgl 1 and 2.
  25815. * You will need to pass the name of the uniform as well as the value.
  25816. */
  25817. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25818. /**
  25819. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25820. * This is dynamic to allow compat with webgl 1 and 2.
  25821. * You will need to pass the name of the uniform as well as the value.
  25822. */
  25823. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25824. /**
  25825. * Lambda to Update a single float in a uniform buffer.
  25826. * This is dynamic to allow compat with webgl 1 and 2.
  25827. * You will need to pass the name of the uniform as well as the value.
  25828. */
  25829. updateFloat: (name: string, x: number) => void;
  25830. /**
  25831. * Lambda to Update a vec2 of float in a uniform buffer.
  25832. * This is dynamic to allow compat with webgl 1 and 2.
  25833. * You will need to pass the name of the uniform as well as the value.
  25834. */
  25835. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25836. /**
  25837. * Lambda to Update a vec3 of float in a uniform buffer.
  25838. * This is dynamic to allow compat with webgl 1 and 2.
  25839. * You will need to pass the name of the uniform as well as the value.
  25840. */
  25841. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25842. /**
  25843. * Lambda to Update a vec4 of float in a uniform buffer.
  25844. * This is dynamic to allow compat with webgl 1 and 2.
  25845. * You will need to pass the name of the uniform as well as the value.
  25846. */
  25847. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25848. /**
  25849. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25850. * This is dynamic to allow compat with webgl 1 and 2.
  25851. * You will need to pass the name of the uniform as well as the value.
  25852. */
  25853. updateMatrix: (name: string, mat: Matrix) => void;
  25854. /**
  25855. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25856. * This is dynamic to allow compat with webgl 1 and 2.
  25857. * You will need to pass the name of the uniform as well as the value.
  25858. */
  25859. updateVector3: (name: string, vector: Vector3) => void;
  25860. /**
  25861. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25862. * This is dynamic to allow compat with webgl 1 and 2.
  25863. * You will need to pass the name of the uniform as well as the value.
  25864. */
  25865. updateVector4: (name: string, vector: Vector4) => void;
  25866. /**
  25867. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25868. * This is dynamic to allow compat with webgl 1 and 2.
  25869. * You will need to pass the name of the uniform as well as the value.
  25870. */
  25871. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25872. /**
  25873. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25874. * This is dynamic to allow compat with webgl 1 and 2.
  25875. * You will need to pass the name of the uniform as well as the value.
  25876. */
  25877. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25878. /**
  25879. * Instantiates a new Uniform buffer objects.
  25880. *
  25881. * Handles blocks of uniform on the GPU.
  25882. *
  25883. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25884. *
  25885. * For more information, please refer to :
  25886. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25887. * @param engine Define the engine the buffer is associated with
  25888. * @param data Define the data contained in the buffer
  25889. * @param dynamic Define if the buffer is updatable
  25890. */
  25891. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25892. /**
  25893. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25894. * or just falling back on setUniformXXX calls.
  25895. */
  25896. readonly useUbo: boolean;
  25897. /**
  25898. * Indicates if the WebGL underlying uniform buffer is in sync
  25899. * with the javascript cache data.
  25900. */
  25901. readonly isSync: boolean;
  25902. /**
  25903. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25904. * Also, a dynamic UniformBuffer will disable cache verification and always
  25905. * update the underlying WebGL uniform buffer to the GPU.
  25906. * @returns if Dynamic, otherwise false
  25907. */
  25908. isDynamic(): boolean;
  25909. /**
  25910. * The data cache on JS side.
  25911. * @returns the underlying data as a float array
  25912. */
  25913. getData(): Float32Array;
  25914. /**
  25915. * The underlying WebGL Uniform buffer.
  25916. * @returns the webgl buffer
  25917. */
  25918. getBuffer(): Nullable<WebGLBuffer>;
  25919. /**
  25920. * std140 layout specifies how to align data within an UBO structure.
  25921. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25922. * for specs.
  25923. */
  25924. private _fillAlignment;
  25925. /**
  25926. * Adds an uniform in the buffer.
  25927. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25928. * for the layout to be correct !
  25929. * @param name Name of the uniform, as used in the uniform block in the shader.
  25930. * @param size Data size, or data directly.
  25931. */
  25932. addUniform(name: string, size: number | number[]): void;
  25933. /**
  25934. * Adds a Matrix 4x4 to the uniform buffer.
  25935. * @param name Name of the uniform, as used in the uniform block in the shader.
  25936. * @param mat A 4x4 matrix.
  25937. */
  25938. addMatrix(name: string, mat: Matrix): void;
  25939. /**
  25940. * Adds a vec2 to the uniform buffer.
  25941. * @param name Name of the uniform, as used in the uniform block in the shader.
  25942. * @param x Define the x component value of the vec2
  25943. * @param y Define the y component value of the vec2
  25944. */
  25945. addFloat2(name: string, x: number, y: number): void;
  25946. /**
  25947. * Adds a vec3 to the uniform buffer.
  25948. * @param name Name of the uniform, as used in the uniform block in the shader.
  25949. * @param x Define the x component value of the vec3
  25950. * @param y Define the y component value of the vec3
  25951. * @param z Define the z component value of the vec3
  25952. */
  25953. addFloat3(name: string, x: number, y: number, z: number): void;
  25954. /**
  25955. * Adds a vec3 to the uniform buffer.
  25956. * @param name Name of the uniform, as used in the uniform block in the shader.
  25957. * @param color Define the vec3 from a Color
  25958. */
  25959. addColor3(name: string, color: Color3): void;
  25960. /**
  25961. * Adds a vec4 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. * @param color Define the rgb components from a Color
  25964. * @param alpha Define the a component of the vec4
  25965. */
  25966. addColor4(name: string, color: Color3, alpha: number): void;
  25967. /**
  25968. * Adds a vec3 to the uniform buffer.
  25969. * @param name Name of the uniform, as used in the uniform block in the shader.
  25970. * @param vector Define the vec3 components from a Vector
  25971. */
  25972. addVector3(name: string, vector: Vector3): void;
  25973. /**
  25974. * Adds a Matrix 3x3 to the uniform buffer.
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. */
  25977. addMatrix3x3(name: string): void;
  25978. /**
  25979. * Adds a Matrix 2x2 to the uniform buffer.
  25980. * @param name Name of the uniform, as used in the uniform block in the shader.
  25981. */
  25982. addMatrix2x2(name: string): void;
  25983. /**
  25984. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25985. */
  25986. create(): void;
  25987. /** @hidden */
  25988. _rebuild(): void;
  25989. /**
  25990. * Updates the WebGL Uniform Buffer on the GPU.
  25991. * If the `dynamic` flag is set to true, no cache comparison is done.
  25992. * Otherwise, the buffer will be updated only if the cache differs.
  25993. */
  25994. update(): void;
  25995. /**
  25996. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25997. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25998. * @param data Define the flattened data
  25999. * @param size Define the size of the data.
  26000. */
  26001. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26002. private _updateMatrix3x3ForUniform;
  26003. private _updateMatrix3x3ForEffect;
  26004. private _updateMatrix2x2ForEffect;
  26005. private _updateMatrix2x2ForUniform;
  26006. private _updateFloatForEffect;
  26007. private _updateFloatForUniform;
  26008. private _updateFloat2ForEffect;
  26009. private _updateFloat2ForUniform;
  26010. private _updateFloat3ForEffect;
  26011. private _updateFloat3ForUniform;
  26012. private _updateFloat4ForEffect;
  26013. private _updateFloat4ForUniform;
  26014. private _updateMatrixForEffect;
  26015. private _updateMatrixForUniform;
  26016. private _updateVector3ForEffect;
  26017. private _updateVector3ForUniform;
  26018. private _updateVector4ForEffect;
  26019. private _updateVector4ForUniform;
  26020. private _updateColor3ForEffect;
  26021. private _updateColor3ForUniform;
  26022. private _updateColor4ForEffect;
  26023. private _updateColor4ForUniform;
  26024. /**
  26025. * Sets a sampler uniform on the effect.
  26026. * @param name Define the name of the sampler.
  26027. * @param texture Define the texture to set in the sampler
  26028. */
  26029. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26030. /**
  26031. * Directly updates the value of the uniform in the cache AND on the GPU.
  26032. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26033. * @param data Define the flattened data
  26034. */
  26035. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26036. /**
  26037. * Binds this uniform buffer to an effect.
  26038. * @param effect Define the effect to bind the buffer to
  26039. * @param name Name of the uniform block in the shader.
  26040. */
  26041. bindToEffect(effect: Effect, name: string): void;
  26042. /**
  26043. * Disposes the uniform buffer.
  26044. */
  26045. dispose(): void;
  26046. }
  26047. }
  26048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26049. import { Nullable } from "babylonjs/types";
  26050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26051. /**
  26052. * This represents the required contract to create a new type of texture loader.
  26053. */
  26054. export interface IInternalTextureLoader {
  26055. /**
  26056. * Defines wether the loader supports cascade loading the different faces.
  26057. */
  26058. supportCascades: boolean;
  26059. /**
  26060. * This returns if the loader support the current file information.
  26061. * @param extension defines the file extension of the file being loaded
  26062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26063. * @param fallback defines the fallback internal texture if any
  26064. * @param isBase64 defines whether the texture is encoded as a base64
  26065. * @param isBuffer defines whether the texture data are stored as a buffer
  26066. * @returns true if the loader can load the specified file
  26067. */
  26068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26069. /**
  26070. * Transform the url before loading if required.
  26071. * @param rootUrl the url of the texture
  26072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26073. * @returns the transformed texture
  26074. */
  26075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26076. /**
  26077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26078. * @param rootUrl the url of the texture
  26079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26080. * @returns the fallback texture
  26081. */
  26082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26083. /**
  26084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26085. * @param data contains the texture data
  26086. * @param texture defines the BabylonJS internal texture
  26087. * @param createPolynomials will be true if polynomials have been requested
  26088. * @param onLoad defines the callback to trigger once the texture is ready
  26089. * @param onError defines the callback to trigger in case of error
  26090. */
  26091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26092. /**
  26093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26094. * @param data contains the texture data
  26095. * @param texture defines the BabylonJS internal texture
  26096. * @param callback defines the method to call once ready to upload
  26097. */
  26098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26099. }
  26100. }
  26101. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26102. import { Scene } from "babylonjs/scene";
  26103. import { Engine } from "babylonjs/Engines/engine";
  26104. import { Texture } from "babylonjs/Materials/Textures/texture";
  26105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26106. /**
  26107. * Creation options of the multi render target texture.
  26108. */
  26109. export interface IMultiRenderTargetOptions {
  26110. /**
  26111. * Define if the texture needs to create mip maps after render.
  26112. */
  26113. generateMipMaps?: boolean;
  26114. /**
  26115. * Define the types of all the draw buffers we want to create
  26116. */
  26117. types?: number[];
  26118. /**
  26119. * Define the sampling modes of all the draw buffers we want to create
  26120. */
  26121. samplingModes?: number[];
  26122. /**
  26123. * Define if a depth buffer is required
  26124. */
  26125. generateDepthBuffer?: boolean;
  26126. /**
  26127. * Define if a stencil buffer is required
  26128. */
  26129. generateStencilBuffer?: boolean;
  26130. /**
  26131. * Define if a depth texture is required instead of a depth buffer
  26132. */
  26133. generateDepthTexture?: boolean;
  26134. /**
  26135. * Define the number of desired draw buffers
  26136. */
  26137. textureCount?: number;
  26138. /**
  26139. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26140. */
  26141. doNotChangeAspectRatio?: boolean;
  26142. /**
  26143. * Define the default type of the buffers we are creating
  26144. */
  26145. defaultType?: number;
  26146. }
  26147. /**
  26148. * A multi render target, like a render target provides the ability to render to a texture.
  26149. * Unlike the render target, it can render to several draw buffers in one draw.
  26150. * This is specially interesting in deferred rendering or for any effects requiring more than
  26151. * just one color from a single pass.
  26152. */
  26153. export class MultiRenderTarget extends RenderTargetTexture {
  26154. private _internalTextures;
  26155. private _textures;
  26156. private _multiRenderTargetOptions;
  26157. /**
  26158. * Get if draw buffers are currently supported by the used hardware and browser.
  26159. */
  26160. readonly isSupported: boolean;
  26161. /**
  26162. * Get the list of textures generated by the multi render target.
  26163. */
  26164. readonly textures: Texture[];
  26165. /**
  26166. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26167. */
  26168. readonly depthTexture: Texture;
  26169. /**
  26170. * Set the wrapping mode on U of all the textures we are rendering to.
  26171. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26172. */
  26173. wrapU: number;
  26174. /**
  26175. * Set the wrapping mode on V of all the textures we are rendering to.
  26176. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26177. */
  26178. wrapV: number;
  26179. /**
  26180. * Instantiate a new multi render target texture.
  26181. * A multi render target, like a render target provides the ability to render to a texture.
  26182. * Unlike the render target, it can render to several draw buffers in one draw.
  26183. * This is specially interesting in deferred rendering or for any effects requiring more than
  26184. * just one color from a single pass.
  26185. * @param name Define the name of the texture
  26186. * @param size Define the size of the buffers to render to
  26187. * @param count Define the number of target we are rendering into
  26188. * @param scene Define the scene the texture belongs to
  26189. * @param options Define the options used to create the multi render target
  26190. */
  26191. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26192. /** @hidden */
  26193. _rebuild(): void;
  26194. private _createInternalTextures;
  26195. private _createTextures;
  26196. /**
  26197. * Define the number of samples used if MSAA is enabled.
  26198. */
  26199. samples: number;
  26200. /**
  26201. * Resize all the textures in the multi render target.
  26202. * Be carrefull as it will recreate all the data in the new texture.
  26203. * @param size Define the new size
  26204. */
  26205. resize(size: any): void;
  26206. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26207. /**
  26208. * Dispose the render targets and their associated resources
  26209. */
  26210. dispose(): void;
  26211. /**
  26212. * Release all the underlying texture used as draw buffers.
  26213. */
  26214. releaseInternalTextures(): void;
  26215. }
  26216. }
  26217. declare module "babylonjs/Audio/analyser" {
  26218. import { Scene } from "babylonjs/scene";
  26219. /**
  26220. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26222. */
  26223. export class Analyser {
  26224. /**
  26225. * Gets or sets the smoothing
  26226. * @ignorenaming
  26227. */
  26228. SMOOTHING: number;
  26229. /**
  26230. * Gets or sets the FFT table size
  26231. * @ignorenaming
  26232. */
  26233. FFT_SIZE: number;
  26234. /**
  26235. * Gets or sets the bar graph amplitude
  26236. * @ignorenaming
  26237. */
  26238. BARGRAPHAMPLITUDE: number;
  26239. /**
  26240. * Gets or sets the position of the debug canvas
  26241. * @ignorenaming
  26242. */
  26243. DEBUGCANVASPOS: {
  26244. x: number;
  26245. y: number;
  26246. };
  26247. /**
  26248. * Gets or sets the debug canvas size
  26249. * @ignorenaming
  26250. */
  26251. DEBUGCANVASSIZE: {
  26252. width: number;
  26253. height: number;
  26254. };
  26255. private _byteFreqs;
  26256. private _byteTime;
  26257. private _floatFreqs;
  26258. private _webAudioAnalyser;
  26259. private _debugCanvas;
  26260. private _debugCanvasContext;
  26261. private _scene;
  26262. private _registerFunc;
  26263. private _audioEngine;
  26264. /**
  26265. * Creates a new analyser
  26266. * @param scene defines hosting scene
  26267. */
  26268. constructor(scene: Scene);
  26269. /**
  26270. * Get the number of data values you will have to play with for the visualization
  26271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26272. * @returns a number
  26273. */
  26274. getFrequencyBinCount(): number;
  26275. /**
  26276. * Gets the current frequency data as a byte array
  26277. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26278. * @returns a Uint8Array
  26279. */
  26280. getByteFrequencyData(): Uint8Array;
  26281. /**
  26282. * Gets the current waveform as a byte array
  26283. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26284. * @returns a Uint8Array
  26285. */
  26286. getByteTimeDomainData(): Uint8Array;
  26287. /**
  26288. * Gets the current frequency data as a float array
  26289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26290. * @returns a Float32Array
  26291. */
  26292. getFloatFrequencyData(): Float32Array;
  26293. /**
  26294. * Renders the debug canvas
  26295. */
  26296. drawDebugCanvas(): void;
  26297. /**
  26298. * Stops rendering the debug canvas and removes it
  26299. */
  26300. stopDebugCanvas(): void;
  26301. /**
  26302. * Connects two audio nodes
  26303. * @param inputAudioNode defines first node to connect
  26304. * @param outputAudioNode defines second node to connect
  26305. */
  26306. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26307. /**
  26308. * Releases all associated resources
  26309. */
  26310. dispose(): void;
  26311. }
  26312. }
  26313. declare module "babylonjs/Audio/audioEngine" {
  26314. import { IDisposable } from "babylonjs/scene";
  26315. import { Analyser } from "babylonjs/Audio/analyser";
  26316. import { Nullable } from "babylonjs/types";
  26317. import { Observable } from "babylonjs/Misc/observable";
  26318. /**
  26319. * This represents an audio engine and it is responsible
  26320. * to play, synchronize and analyse sounds throughout the application.
  26321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26322. */
  26323. export interface IAudioEngine extends IDisposable {
  26324. /**
  26325. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26326. */
  26327. readonly canUseWebAudio: boolean;
  26328. /**
  26329. * Gets the current AudioContext if available.
  26330. */
  26331. readonly audioContext: Nullable<AudioContext>;
  26332. /**
  26333. * The master gain node defines the global audio volume of your audio engine.
  26334. */
  26335. readonly masterGain: GainNode;
  26336. /**
  26337. * Gets whether or not mp3 are supported by your browser.
  26338. */
  26339. readonly isMP3supported: boolean;
  26340. /**
  26341. * Gets whether or not ogg are supported by your browser.
  26342. */
  26343. readonly isOGGsupported: boolean;
  26344. /**
  26345. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26346. * @ignoreNaming
  26347. */
  26348. WarnedWebAudioUnsupported: boolean;
  26349. /**
  26350. * Defines if the audio engine relies on a custom unlocked button.
  26351. * In this case, the embedded button will not be displayed.
  26352. */
  26353. useCustomUnlockedButton: boolean;
  26354. /**
  26355. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26356. */
  26357. readonly unlocked: boolean;
  26358. /**
  26359. * Event raised when audio has been unlocked on the browser.
  26360. */
  26361. onAudioUnlockedObservable: Observable<AudioEngine>;
  26362. /**
  26363. * Event raised when audio has been locked on the browser.
  26364. */
  26365. onAudioLockedObservable: Observable<AudioEngine>;
  26366. /**
  26367. * Flags the audio engine in Locked state.
  26368. * This happens due to new browser policies preventing audio to autoplay.
  26369. */
  26370. lock(): void;
  26371. /**
  26372. * Unlocks the audio engine once a user action has been done on the dom.
  26373. * This is helpful to resume play once browser policies have been satisfied.
  26374. */
  26375. unlock(): void;
  26376. }
  26377. /**
  26378. * This represents the default audio engine used in babylon.
  26379. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26381. */
  26382. export class AudioEngine implements IAudioEngine {
  26383. private _audioContext;
  26384. private _audioContextInitialized;
  26385. private _muteButton;
  26386. private _hostElement;
  26387. /**
  26388. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26389. */
  26390. canUseWebAudio: boolean;
  26391. /**
  26392. * The master gain node defines the global audio volume of your audio engine.
  26393. */
  26394. masterGain: GainNode;
  26395. /**
  26396. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26397. * @ignoreNaming
  26398. */
  26399. WarnedWebAudioUnsupported: boolean;
  26400. /**
  26401. * Gets whether or not mp3 are supported by your browser.
  26402. */
  26403. isMP3supported: boolean;
  26404. /**
  26405. * Gets whether or not ogg are supported by your browser.
  26406. */
  26407. isOGGsupported: boolean;
  26408. /**
  26409. * Gets whether audio has been unlocked on the device.
  26410. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26411. * a user interaction has happened.
  26412. */
  26413. unlocked: boolean;
  26414. /**
  26415. * Defines if the audio engine relies on a custom unlocked button.
  26416. * In this case, the embedded button will not be displayed.
  26417. */
  26418. useCustomUnlockedButton: boolean;
  26419. /**
  26420. * Event raised when audio has been unlocked on the browser.
  26421. */
  26422. onAudioUnlockedObservable: Observable<AudioEngine>;
  26423. /**
  26424. * Event raised when audio has been locked on the browser.
  26425. */
  26426. onAudioLockedObservable: Observable<AudioEngine>;
  26427. /**
  26428. * Gets the current AudioContext if available.
  26429. */
  26430. readonly audioContext: Nullable<AudioContext>;
  26431. private _connectedAnalyser;
  26432. /**
  26433. * Instantiates a new audio engine.
  26434. *
  26435. * There should be only one per page as some browsers restrict the number
  26436. * of audio contexts you can create.
  26437. * @param hostElement defines the host element where to display the mute icon if necessary
  26438. */
  26439. constructor(hostElement?: Nullable<HTMLElement>);
  26440. /**
  26441. * Flags the audio engine in Locked state.
  26442. * This happens due to new browser policies preventing audio to autoplay.
  26443. */
  26444. lock(): void;
  26445. /**
  26446. * Unlocks the audio engine once a user action has been done on the dom.
  26447. * This is helpful to resume play once browser policies have been satisfied.
  26448. */
  26449. unlock(): void;
  26450. private _resumeAudioContext;
  26451. private _initializeAudioContext;
  26452. private _tryToRun;
  26453. private _triggerRunningState;
  26454. private _triggerSuspendedState;
  26455. private _displayMuteButton;
  26456. private _moveButtonToTopLeft;
  26457. private _onResize;
  26458. private _hideMuteButton;
  26459. /**
  26460. * Destroy and release the resources associated with the audio ccontext.
  26461. */
  26462. dispose(): void;
  26463. /**
  26464. * Gets the global volume sets on the master gain.
  26465. * @returns the global volume if set or -1 otherwise
  26466. */
  26467. getGlobalVolume(): number;
  26468. /**
  26469. * Sets the global volume of your experience (sets on the master gain).
  26470. * @param newVolume Defines the new global volume of the application
  26471. */
  26472. setGlobalVolume(newVolume: number): void;
  26473. /**
  26474. * Connect the audio engine to an audio analyser allowing some amazing
  26475. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26477. * @param analyser The analyser to connect to the engine
  26478. */
  26479. connectToAnalyser(analyser: Analyser): void;
  26480. }
  26481. }
  26482. declare module "babylonjs/Loading/loadingScreen" {
  26483. /**
  26484. * Interface used to present a loading screen while loading a scene
  26485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26486. */
  26487. export interface ILoadingScreen {
  26488. /**
  26489. * Function called to display the loading screen
  26490. */
  26491. displayLoadingUI: () => void;
  26492. /**
  26493. * Function called to hide the loading screen
  26494. */
  26495. hideLoadingUI: () => void;
  26496. /**
  26497. * Gets or sets the color to use for the background
  26498. */
  26499. loadingUIBackgroundColor: string;
  26500. /**
  26501. * Gets or sets the text to display while loading
  26502. */
  26503. loadingUIText: string;
  26504. }
  26505. /**
  26506. * Class used for the default loading screen
  26507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26508. */
  26509. export class DefaultLoadingScreen implements ILoadingScreen {
  26510. private _renderingCanvas;
  26511. private _loadingText;
  26512. private _loadingDivBackgroundColor;
  26513. private _loadingDiv;
  26514. private _loadingTextDiv;
  26515. /**
  26516. * Creates a new default loading screen
  26517. * @param _renderingCanvas defines the canvas used to render the scene
  26518. * @param _loadingText defines the default text to display
  26519. * @param _loadingDivBackgroundColor defines the default background color
  26520. */
  26521. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26522. /**
  26523. * Function called to display the loading screen
  26524. */
  26525. displayLoadingUI(): void;
  26526. /**
  26527. * Function called to hide the loading screen
  26528. */
  26529. hideLoadingUI(): void;
  26530. /**
  26531. * Gets or sets the text to display while loading
  26532. */
  26533. loadingUIText: string;
  26534. /**
  26535. * Gets or sets the color to use for the background
  26536. */
  26537. loadingUIBackgroundColor: string;
  26538. private _resizeLoadingUI;
  26539. }
  26540. }
  26541. declare module "babylonjs/Materials/Textures/videoTexture" {
  26542. import { Observable } from "babylonjs/Misc/observable";
  26543. import { Nullable } from "babylonjs/types";
  26544. import { Scene } from "babylonjs/scene";
  26545. import { Texture } from "babylonjs/Materials/Textures/texture";
  26546. /**
  26547. * Settings for finer control over video usage
  26548. */
  26549. export interface VideoTextureSettings {
  26550. /**
  26551. * Applies `autoplay` to video, if specified
  26552. */
  26553. autoPlay?: boolean;
  26554. /**
  26555. * Applies `loop` to video, if specified
  26556. */
  26557. loop?: boolean;
  26558. /**
  26559. * Automatically updates internal texture from video at every frame in the render loop
  26560. */
  26561. autoUpdateTexture: boolean;
  26562. /**
  26563. * Image src displayed during the video loading or until the user interacts with the video.
  26564. */
  26565. poster?: string;
  26566. }
  26567. /**
  26568. * If you want to display a video in your scene, this is the special texture for that.
  26569. * This special texture works similar to other textures, with the exception of a few parameters.
  26570. * @see https://doc.babylonjs.com/how_to/video_texture
  26571. */
  26572. export class VideoTexture extends Texture {
  26573. /**
  26574. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26575. */
  26576. readonly autoUpdateTexture: boolean;
  26577. /**
  26578. * The video instance used by the texture internally
  26579. */
  26580. readonly video: HTMLVideoElement;
  26581. private _onUserActionRequestedObservable;
  26582. /**
  26583. * Event triggerd when a dom action is required by the user to play the video.
  26584. * This happens due to recent changes in browser policies preventing video to auto start.
  26585. */
  26586. readonly onUserActionRequestedObservable: Observable<Texture>;
  26587. private _generateMipMaps;
  26588. private _engine;
  26589. private _stillImageCaptured;
  26590. private _displayingPosterTexture;
  26591. private _settings;
  26592. private _createInternalTextureOnEvent;
  26593. /**
  26594. * Creates a video texture.
  26595. * If you want to display a video in your scene, this is the special texture for that.
  26596. * This special texture works similar to other textures, with the exception of a few parameters.
  26597. * @see https://doc.babylonjs.com/how_to/video_texture
  26598. * @param name optional name, will detect from video source, if not defined
  26599. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26600. * @param scene is obviously the current scene.
  26601. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26602. * @param invertY is false by default but can be used to invert video on Y axis
  26603. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26604. * @param settings allows finer control over video usage
  26605. */
  26606. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26607. private _getName;
  26608. private _getVideo;
  26609. private _createInternalTexture;
  26610. private reset;
  26611. /**
  26612. * @hidden Internal method to initiate `update`.
  26613. */
  26614. _rebuild(): void;
  26615. /**
  26616. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26617. */
  26618. update(): void;
  26619. /**
  26620. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26621. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26622. */
  26623. updateTexture(isVisible: boolean): void;
  26624. protected _updateInternalTexture: () => void;
  26625. /**
  26626. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26627. * @param url New url.
  26628. */
  26629. updateURL(url: string): void;
  26630. /**
  26631. * Dispose the texture and release its associated resources.
  26632. */
  26633. dispose(): void;
  26634. /**
  26635. * Creates a video texture straight from your WebCam video feed.
  26636. * @param scene Define the scene the texture should be created in
  26637. * @param onReady Define a callback to triggered once the texture will be ready
  26638. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26639. */
  26640. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26641. minWidth: number;
  26642. maxWidth: number;
  26643. minHeight: number;
  26644. maxHeight: number;
  26645. deviceId: string;
  26646. }): void;
  26647. }
  26648. }
  26649. declare module "babylonjs/Engines/engine" {
  26650. import { Observable } from "babylonjs/Misc/observable";
  26651. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26652. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26653. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26654. import { Camera } from "babylonjs/Cameras/camera";
  26655. import { Scene } from "babylonjs/scene";
  26656. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26657. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26658. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26659. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26660. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26661. import { Material } from "babylonjs/Materials/material";
  26662. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26665. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26666. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26667. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26668. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26669. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26673. /**
  26674. * Interface for attribute information associated with buffer instanciation
  26675. */
  26676. export class InstancingAttributeInfo {
  26677. /**
  26678. * Index/offset of the attribute in the vertex shader
  26679. */
  26680. index: number;
  26681. /**
  26682. * size of the attribute, 1, 2, 3 or 4
  26683. */
  26684. attributeSize: number;
  26685. /**
  26686. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26687. * default is FLOAT
  26688. */
  26689. attribyteType: number;
  26690. /**
  26691. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26692. */
  26693. normalized: boolean;
  26694. /**
  26695. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26696. */
  26697. offset: number;
  26698. /**
  26699. * Name of the GLSL attribute, for debugging purpose only
  26700. */
  26701. attributeName: string;
  26702. }
  26703. /**
  26704. * Define options used to create a depth texture
  26705. */
  26706. export class DepthTextureCreationOptions {
  26707. /** Specifies whether or not a stencil should be allocated in the texture */
  26708. generateStencil?: boolean;
  26709. /** Specifies whether or not bilinear filtering is enable on the texture */
  26710. bilinearFiltering?: boolean;
  26711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26712. comparisonFunction?: number;
  26713. /** Specifies if the created texture is a cube texture */
  26714. isCube?: boolean;
  26715. }
  26716. /**
  26717. * Class used to describe the capabilities of the engine relatively to the current browser
  26718. */
  26719. export class EngineCapabilities {
  26720. /** Maximum textures units per fragment shader */
  26721. maxTexturesImageUnits: number;
  26722. /** Maximum texture units per vertex shader */
  26723. maxVertexTextureImageUnits: number;
  26724. /** Maximum textures units in the entire pipeline */
  26725. maxCombinedTexturesImageUnits: number;
  26726. /** Maximum texture size */
  26727. maxTextureSize: number;
  26728. /** Maximum cube texture size */
  26729. maxCubemapTextureSize: number;
  26730. /** Maximum render texture size */
  26731. maxRenderTextureSize: number;
  26732. /** Maximum number of vertex attributes */
  26733. maxVertexAttribs: number;
  26734. /** Maximum number of varyings */
  26735. maxVaryingVectors: number;
  26736. /** Maximum number of uniforms per vertex shader */
  26737. maxVertexUniformVectors: number;
  26738. /** Maximum number of uniforms per fragment shader */
  26739. maxFragmentUniformVectors: number;
  26740. /** Defines if standard derivates (dx/dy) are supported */
  26741. standardDerivatives: boolean;
  26742. /** Defines if s3tc texture compression is supported */
  26743. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26744. /** Defines if pvrtc texture compression is supported */
  26745. pvrtc: any;
  26746. /** Defines if etc1 texture compression is supported */
  26747. etc1: any;
  26748. /** Defines if etc2 texture compression is supported */
  26749. etc2: any;
  26750. /** Defines if astc texture compression is supported */
  26751. astc: any;
  26752. /** Defines if float textures are supported */
  26753. textureFloat: boolean;
  26754. /** Defines if vertex array objects are supported */
  26755. vertexArrayObject: boolean;
  26756. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26757. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26758. /** Gets the maximum level of anisotropy supported */
  26759. maxAnisotropy: number;
  26760. /** Defines if instancing is supported */
  26761. instancedArrays: boolean;
  26762. /** Defines if 32 bits indices are supported */
  26763. uintIndices: boolean;
  26764. /** Defines if high precision shaders are supported */
  26765. highPrecisionShaderSupported: boolean;
  26766. /** Defines if depth reading in the fragment shader is supported */
  26767. fragmentDepthSupported: boolean;
  26768. /** Defines if float texture linear filtering is supported*/
  26769. textureFloatLinearFiltering: boolean;
  26770. /** Defines if rendering to float textures is supported */
  26771. textureFloatRender: boolean;
  26772. /** Defines if half float textures are supported*/
  26773. textureHalfFloat: boolean;
  26774. /** Defines if half float texture linear filtering is supported*/
  26775. textureHalfFloatLinearFiltering: boolean;
  26776. /** Defines if rendering to half float textures is supported */
  26777. textureHalfFloatRender: boolean;
  26778. /** Defines if textureLOD shader command is supported */
  26779. textureLOD: boolean;
  26780. /** Defines if draw buffers extension is supported */
  26781. drawBuffersExtension: boolean;
  26782. /** Defines if depth textures are supported */
  26783. depthTextureExtension: boolean;
  26784. /** Defines if float color buffer are supported */
  26785. colorBufferFloat: boolean;
  26786. /** Gets disjoint timer query extension (null if not supported) */
  26787. timerQuery: EXT_disjoint_timer_query;
  26788. /** Defines if timestamp can be used with timer query */
  26789. canUseTimestampForTimerQuery: boolean;
  26790. /** Function used to let the system compiles shaders in background */
  26791. parallelShaderCompile: {
  26792. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26793. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26794. COMPLETION_STATUS_KHR: number;
  26795. };
  26796. }
  26797. /** Interface defining initialization parameters for Engine class */
  26798. export interface EngineOptions extends WebGLContextAttributes {
  26799. /**
  26800. * Defines if the engine should no exceed a specified device ratio
  26801. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26802. */
  26803. limitDeviceRatio?: number;
  26804. /**
  26805. * Defines if webvr should be enabled automatically
  26806. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26807. */
  26808. autoEnableWebVR?: boolean;
  26809. /**
  26810. * Defines if webgl2 should be turned off even if supported
  26811. * @see http://doc.babylonjs.com/features/webgl2
  26812. */
  26813. disableWebGL2Support?: boolean;
  26814. /**
  26815. * Defines if webaudio should be initialized as well
  26816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26817. */
  26818. audioEngine?: boolean;
  26819. /**
  26820. * Defines if animations should run using a deterministic lock step
  26821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26822. */
  26823. deterministicLockstep?: boolean;
  26824. /** Defines the maximum steps to use with deterministic lock step mode */
  26825. lockstepMaxSteps?: number;
  26826. /**
  26827. * Defines that engine should ignore context lost events
  26828. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26829. */
  26830. doNotHandleContextLost?: boolean;
  26831. /**
  26832. * Defines that engine should ignore modifying touch action attribute and style
  26833. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26834. */
  26835. doNotHandleTouchAction?: boolean;
  26836. }
  26837. /**
  26838. * Defines the interface used by display changed events
  26839. */
  26840. export interface IDisplayChangedEventArgs {
  26841. /** Gets the vrDisplay object (if any) */
  26842. vrDisplay: Nullable<any>;
  26843. /** Gets a boolean indicating if webVR is supported */
  26844. vrSupported: boolean;
  26845. }
  26846. /**
  26847. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26848. */
  26849. export class Engine {
  26850. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26851. static ExceptionList: ({
  26852. key: string;
  26853. capture: string;
  26854. captureConstraint: number;
  26855. targets: string[];
  26856. } | {
  26857. key: string;
  26858. capture: null;
  26859. captureConstraint: null;
  26860. targets: string[];
  26861. })[];
  26862. /** Gets the list of created engines */
  26863. static readonly Instances: Engine[];
  26864. /**
  26865. * Gets the latest created engine
  26866. */
  26867. static readonly LastCreatedEngine: Nullable<Engine>;
  26868. /**
  26869. * Gets the latest created scene
  26870. */
  26871. static readonly LastCreatedScene: Nullable<Scene>;
  26872. /**
  26873. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26874. * @param flag defines which part of the materials must be marked as dirty
  26875. * @param predicate defines a predicate used to filter which materials should be affected
  26876. */
  26877. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26878. /**
  26879. * Hidden
  26880. */
  26881. static _TextureLoaders: IInternalTextureLoader[];
  26882. /** Defines that alpha blending is disabled */
  26883. static readonly ALPHA_DISABLE: number;
  26884. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26885. static readonly ALPHA_ADD: number;
  26886. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26887. static readonly ALPHA_COMBINE: number;
  26888. /** Defines that alpha blending to DEST - SRC * DEST */
  26889. static readonly ALPHA_SUBTRACT: number;
  26890. /** Defines that alpha blending to SRC * DEST */
  26891. static readonly ALPHA_MULTIPLY: number;
  26892. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26893. static readonly ALPHA_MAXIMIZED: number;
  26894. /** Defines that alpha blending to SRC + DEST */
  26895. static readonly ALPHA_ONEONE: number;
  26896. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26897. static readonly ALPHA_PREMULTIPLIED: number;
  26898. /**
  26899. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26900. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26901. */
  26902. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26903. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26904. static readonly ALPHA_INTERPOLATE: number;
  26905. /**
  26906. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26907. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26908. */
  26909. static readonly ALPHA_SCREENMODE: number;
  26910. /** Defines that the ressource is not delayed*/
  26911. static readonly DELAYLOADSTATE_NONE: number;
  26912. /** Defines that the ressource was successfully delay loaded */
  26913. static readonly DELAYLOADSTATE_LOADED: number;
  26914. /** Defines that the ressource is currently delay loading */
  26915. static readonly DELAYLOADSTATE_LOADING: number;
  26916. /** Defines that the ressource is delayed and has not started loading */
  26917. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26918. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26919. static readonly NEVER: number;
  26920. /** 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 */
  26921. static readonly ALWAYS: number;
  26922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26923. static readonly LESS: number;
  26924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26925. static readonly EQUAL: number;
  26926. /** 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 */
  26927. static readonly LEQUAL: number;
  26928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26929. static readonly GREATER: number;
  26930. /** 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 */
  26931. static readonly GEQUAL: number;
  26932. /** 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 */
  26933. static readonly NOTEQUAL: number;
  26934. /** Passed to stencilOperation to specify that stencil value must be kept */
  26935. static readonly KEEP: number;
  26936. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26937. static readonly REPLACE: number;
  26938. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26939. static readonly INCR: number;
  26940. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26941. static readonly DECR: number;
  26942. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26943. static readonly INVERT: number;
  26944. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26945. static readonly INCR_WRAP: number;
  26946. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26947. static readonly DECR_WRAP: number;
  26948. /** Texture is not repeating outside of 0..1 UVs */
  26949. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26950. /** Texture is repeating outside of 0..1 UVs */
  26951. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26952. /** Texture is repeating and mirrored */
  26953. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26954. /** ALPHA */
  26955. static readonly TEXTUREFORMAT_ALPHA: number;
  26956. /** LUMINANCE */
  26957. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26958. /** LUMINANCE_ALPHA */
  26959. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26960. /** RGB */
  26961. static readonly TEXTUREFORMAT_RGB: number;
  26962. /** RGBA */
  26963. static readonly TEXTUREFORMAT_RGBA: number;
  26964. /** RED */
  26965. static readonly TEXTUREFORMAT_RED: number;
  26966. /** RED (2nd reference) */
  26967. static readonly TEXTUREFORMAT_R: number;
  26968. /** RG */
  26969. static readonly TEXTUREFORMAT_RG: number;
  26970. /** RED_INTEGER */
  26971. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26972. /** RED_INTEGER (2nd reference) */
  26973. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26974. /** RG_INTEGER */
  26975. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26976. /** RGB_INTEGER */
  26977. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26978. /** RGBA_INTEGER */
  26979. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26980. /** UNSIGNED_BYTE */
  26981. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26982. /** UNSIGNED_BYTE (2nd reference) */
  26983. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26984. /** FLOAT */
  26985. static readonly TEXTURETYPE_FLOAT: number;
  26986. /** HALF_FLOAT */
  26987. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26988. /** BYTE */
  26989. static readonly TEXTURETYPE_BYTE: number;
  26990. /** SHORT */
  26991. static readonly TEXTURETYPE_SHORT: number;
  26992. /** UNSIGNED_SHORT */
  26993. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26994. /** INT */
  26995. static readonly TEXTURETYPE_INT: number;
  26996. /** UNSIGNED_INT */
  26997. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26998. /** UNSIGNED_SHORT_4_4_4_4 */
  26999. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27000. /** UNSIGNED_SHORT_5_5_5_1 */
  27001. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27002. /** UNSIGNED_SHORT_5_6_5 */
  27003. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27004. /** UNSIGNED_INT_2_10_10_10_REV */
  27005. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27006. /** UNSIGNED_INT_24_8 */
  27007. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27008. /** UNSIGNED_INT_10F_11F_11F_REV */
  27009. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27010. /** UNSIGNED_INT_5_9_9_9_REV */
  27011. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27012. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27013. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27014. /** nearest is mag = nearest and min = nearest and mip = linear */
  27015. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27016. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27017. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27018. /** Trilinear is mag = linear and min = linear and mip = linear */
  27019. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27020. /** nearest is mag = nearest and min = nearest and mip = linear */
  27021. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27022. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27023. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27024. /** Trilinear is mag = linear and min = linear and mip = linear */
  27025. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27026. /** mag = nearest and min = nearest and mip = nearest */
  27027. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27028. /** mag = nearest and min = linear and mip = nearest */
  27029. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27030. /** mag = nearest and min = linear and mip = linear */
  27031. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27032. /** mag = nearest and min = linear and mip = none */
  27033. static readonly TEXTURE_NEAREST_LINEAR: number;
  27034. /** mag = nearest and min = nearest and mip = none */
  27035. static readonly TEXTURE_NEAREST_NEAREST: number;
  27036. /** mag = linear and min = nearest and mip = nearest */
  27037. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27038. /** mag = linear and min = nearest and mip = linear */
  27039. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27040. /** mag = linear and min = linear and mip = none */
  27041. static readonly TEXTURE_LINEAR_LINEAR: number;
  27042. /** mag = linear and min = nearest and mip = none */
  27043. static readonly TEXTURE_LINEAR_NEAREST: number;
  27044. /** Explicit coordinates mode */
  27045. static readonly TEXTURE_EXPLICIT_MODE: number;
  27046. /** Spherical coordinates mode */
  27047. static readonly TEXTURE_SPHERICAL_MODE: number;
  27048. /** Planar coordinates mode */
  27049. static readonly TEXTURE_PLANAR_MODE: number;
  27050. /** Cubic coordinates mode */
  27051. static readonly TEXTURE_CUBIC_MODE: number;
  27052. /** Projection coordinates mode */
  27053. static readonly TEXTURE_PROJECTION_MODE: number;
  27054. /** Skybox coordinates mode */
  27055. static readonly TEXTURE_SKYBOX_MODE: number;
  27056. /** Inverse Cubic coordinates mode */
  27057. static readonly TEXTURE_INVCUBIC_MODE: number;
  27058. /** Equirectangular coordinates mode */
  27059. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27060. /** Equirectangular Fixed coordinates mode */
  27061. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27062. /** Equirectangular Fixed Mirrored coordinates mode */
  27063. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27064. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27065. static readonly SCALEMODE_FLOOR: number;
  27066. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27067. static readonly SCALEMODE_NEAREST: number;
  27068. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27069. static readonly SCALEMODE_CEILING: number;
  27070. /**
  27071. * Returns the current version of the framework
  27072. */
  27073. static readonly Version: string;
  27074. /**
  27075. * Returns a string describing the current engine
  27076. */
  27077. readonly description: string;
  27078. /**
  27079. * Gets or sets the epsilon value used by collision engine
  27080. */
  27081. static CollisionsEpsilon: number;
  27082. /**
  27083. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27084. */
  27085. static ShadersRepository: string;
  27086. /**
  27087. * Method called to create the default loading screen.
  27088. * This can be overriden in your own app.
  27089. * @param canvas The rendering canvas element
  27090. * @returns The loading screen
  27091. */
  27092. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27093. /**
  27094. * Method called to create the default rescale post process on each engine.
  27095. */
  27096. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27097. /**
  27098. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27099. */
  27100. forcePOTTextures: boolean;
  27101. /**
  27102. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27103. */
  27104. isFullscreen: boolean;
  27105. /**
  27106. * Gets a boolean indicating if the pointer is currently locked
  27107. */
  27108. isPointerLock: boolean;
  27109. /**
  27110. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27111. */
  27112. cullBackFaces: boolean;
  27113. /**
  27114. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27115. */
  27116. renderEvenInBackground: boolean;
  27117. /**
  27118. * Gets or sets a boolean indicating that cache can be kept between frames
  27119. */
  27120. preventCacheWipeBetweenFrames: boolean;
  27121. /**
  27122. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27123. **/
  27124. enableOfflineSupport: boolean;
  27125. /**
  27126. * 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)
  27127. **/
  27128. disableManifestCheck: boolean;
  27129. /**
  27130. * Gets the list of created scenes
  27131. */
  27132. scenes: Scene[];
  27133. /**
  27134. * Event raised when a new scene is created
  27135. */
  27136. onNewSceneAddedObservable: Observable<Scene>;
  27137. /**
  27138. * Gets the list of created postprocesses
  27139. */
  27140. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27141. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27142. validateShaderPrograms: boolean;
  27143. /**
  27144. * Observable event triggered each time the rendering canvas is resized
  27145. */
  27146. onResizeObservable: Observable<Engine>;
  27147. /**
  27148. * Observable event triggered each time the canvas loses focus
  27149. */
  27150. onCanvasBlurObservable: Observable<Engine>;
  27151. /**
  27152. * Observable event triggered each time the canvas gains focus
  27153. */
  27154. onCanvasFocusObservable: Observable<Engine>;
  27155. /**
  27156. * Observable event triggered each time the canvas receives pointerout event
  27157. */
  27158. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27159. /**
  27160. * Observable event triggered before each texture is initialized
  27161. */
  27162. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27163. private _vrDisplay;
  27164. private _vrSupported;
  27165. private _oldSize;
  27166. private _oldHardwareScaleFactor;
  27167. private _vrExclusivePointerMode;
  27168. private _webVRInitPromise;
  27169. /**
  27170. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27171. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27172. */
  27173. readonly isInVRExclusivePointerMode: boolean;
  27174. /**
  27175. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27176. */
  27177. disableUniformBuffers: boolean;
  27178. /** @hidden */
  27179. _uniformBuffers: UniformBuffer[];
  27180. /**
  27181. * Gets a boolean indicating that the engine supports uniform buffers
  27182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27183. */
  27184. readonly supportsUniformBuffers: boolean;
  27185. /**
  27186. * Observable raised when the engine begins a new frame
  27187. */
  27188. onBeginFrameObservable: Observable<Engine>;
  27189. /**
  27190. * If set, will be used to request the next animation frame for the render loop
  27191. */
  27192. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27193. /**
  27194. * Observable raised when the engine ends the current frame
  27195. */
  27196. onEndFrameObservable: Observable<Engine>;
  27197. /**
  27198. * Observable raised when the engine is about to compile a shader
  27199. */
  27200. onBeforeShaderCompilationObservable: Observable<Engine>;
  27201. /**
  27202. * Observable raised when the engine has jsut compiled a shader
  27203. */
  27204. onAfterShaderCompilationObservable: Observable<Engine>;
  27205. /** @hidden */
  27206. _gl: WebGLRenderingContext;
  27207. private _renderingCanvas;
  27208. private _windowIsBackground;
  27209. private _webGLVersion;
  27210. /**
  27211. * Gets a boolean indicating that only power of 2 textures are supported
  27212. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27213. */
  27214. readonly needPOTTextures: boolean;
  27215. /** @hidden */
  27216. _badOS: boolean;
  27217. /** @hidden */
  27218. _badDesktopOS: boolean;
  27219. /**
  27220. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27221. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27222. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27223. */
  27224. disableTextureBindingOptimization: boolean;
  27225. /**
  27226. * Gets the audio engine
  27227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27228. * @ignorenaming
  27229. */
  27230. static audioEngine: IAudioEngine;
  27231. /**
  27232. * Default AudioEngine factory responsible of creating the Audio Engine.
  27233. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27234. */
  27235. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27236. /**
  27237. * Default offline support factory responsible of creating a tool used to store data locally.
  27238. * By default, this will create a Database object if the workload has been embedded.
  27239. */
  27240. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27241. private _onFocus;
  27242. private _onBlur;
  27243. private _onCanvasPointerOut;
  27244. private _onCanvasBlur;
  27245. private _onCanvasFocus;
  27246. private _onFullscreenChange;
  27247. private _onPointerLockChange;
  27248. private _onVRDisplayPointerRestricted;
  27249. private _onVRDisplayPointerUnrestricted;
  27250. private _onVrDisplayConnect;
  27251. private _onVrDisplayDisconnect;
  27252. private _onVrDisplayPresentChange;
  27253. /**
  27254. * Observable signaled when VR display mode changes
  27255. */
  27256. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27257. /**
  27258. * Observable signaled when VR request present is complete
  27259. */
  27260. onVRRequestPresentComplete: Observable<boolean>;
  27261. /**
  27262. * Observable signaled when VR request present starts
  27263. */
  27264. onVRRequestPresentStart: Observable<Engine>;
  27265. private _hardwareScalingLevel;
  27266. /** @hidden */
  27267. protected _caps: EngineCapabilities;
  27268. private _pointerLockRequested;
  27269. private _isStencilEnable;
  27270. private _colorWrite;
  27271. private _loadingScreen;
  27272. /** @hidden */
  27273. _drawCalls: PerfCounter;
  27274. /** @hidden */
  27275. _textureCollisions: PerfCounter;
  27276. private _glVersion;
  27277. private _glRenderer;
  27278. private _glVendor;
  27279. private _videoTextureSupported;
  27280. private _renderingQueueLaunched;
  27281. private _activeRenderLoops;
  27282. private _deterministicLockstep;
  27283. private _lockstepMaxSteps;
  27284. /**
  27285. * Observable signaled when a context lost event is raised
  27286. */
  27287. onContextLostObservable: Observable<Engine>;
  27288. /**
  27289. * Observable signaled when a context restored event is raised
  27290. */
  27291. onContextRestoredObservable: Observable<Engine>;
  27292. private _onContextLost;
  27293. private _onContextRestored;
  27294. private _contextWasLost;
  27295. private _doNotHandleContextLost;
  27296. /**
  27297. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27299. */
  27300. doNotHandleContextLost: boolean;
  27301. private _performanceMonitor;
  27302. private _fps;
  27303. private _deltaTime;
  27304. /**
  27305. * Turn this value on if you want to pause FPS computation when in background
  27306. */
  27307. disablePerformanceMonitorInBackground: boolean;
  27308. /**
  27309. * Gets the performance monitor attached to this engine
  27310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27311. */
  27312. readonly performanceMonitor: PerformanceMonitor;
  27313. /** @hidden */
  27314. protected _depthCullingState: _DepthCullingState;
  27315. /** @hidden */
  27316. protected _stencilState: _StencilState;
  27317. /** @hidden */
  27318. protected _alphaState: _AlphaState;
  27319. /** @hidden */
  27320. protected _alphaMode: number;
  27321. protected _internalTexturesCache: InternalTexture[];
  27322. /** @hidden */
  27323. protected _activeChannel: number;
  27324. private _currentTextureChannel;
  27325. /** @hidden */
  27326. protected _boundTexturesCache: {
  27327. [key: string]: Nullable<InternalTexture>;
  27328. };
  27329. /** @hidden */
  27330. protected _currentEffect: Nullable<Effect>;
  27331. /** @hidden */
  27332. protected _currentProgram: Nullable<WebGLProgram>;
  27333. private _compiledEffects;
  27334. private _vertexAttribArraysEnabled;
  27335. /** @hidden */
  27336. protected _cachedViewport: Nullable<Viewport>;
  27337. private _cachedVertexArrayObject;
  27338. /** @hidden */
  27339. protected _cachedVertexBuffers: any;
  27340. /** @hidden */
  27341. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27342. /** @hidden */
  27343. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27344. /** @hidden */
  27345. protected _currentRenderTarget: Nullable<InternalTexture>;
  27346. private _uintIndicesCurrentlySet;
  27347. private _currentBoundBuffer;
  27348. /** @hidden */
  27349. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27350. private _currentBufferPointers;
  27351. private _currentInstanceLocations;
  27352. private _currentInstanceBuffers;
  27353. private _textureUnits;
  27354. private _firstBoundInternalTextureTracker;
  27355. private _lastBoundInternalTextureTracker;
  27356. private _workingCanvas;
  27357. private _workingContext;
  27358. private _rescalePostProcess;
  27359. private _dummyFramebuffer;
  27360. private _externalData;
  27361. private _bindedRenderFunction;
  27362. private _vaoRecordInProgress;
  27363. private _mustWipeVertexAttributes;
  27364. private _emptyTexture;
  27365. private _emptyCubeTexture;
  27366. private _emptyTexture3D;
  27367. /** @hidden */
  27368. _frameHandler: number;
  27369. private _nextFreeTextureSlots;
  27370. private _maxSimultaneousTextures;
  27371. private _activeRequests;
  27372. private _texturesSupported;
  27373. private _textureFormatInUse;
  27374. /**
  27375. * Gets the list of texture formats supported
  27376. */
  27377. readonly texturesSupported: Array<string>;
  27378. /**
  27379. * Gets the list of texture formats in use
  27380. */
  27381. readonly textureFormatInUse: Nullable<string>;
  27382. /**
  27383. * Gets the current viewport
  27384. */
  27385. readonly currentViewport: Nullable<Viewport>;
  27386. /**
  27387. * Gets the default empty texture
  27388. */
  27389. readonly emptyTexture: InternalTexture;
  27390. /**
  27391. * Gets the default empty 3D texture
  27392. */
  27393. readonly emptyTexture3D: InternalTexture;
  27394. /**
  27395. * Gets the default empty cube texture
  27396. */
  27397. readonly emptyCubeTexture: InternalTexture;
  27398. /**
  27399. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27400. */
  27401. readonly premultipliedAlpha: boolean;
  27402. /**
  27403. * Creates a new engine
  27404. * @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
  27405. * @param antialias defines enable antialiasing (default: false)
  27406. * @param options defines further options to be sent to the getContext() function
  27407. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27408. */
  27409. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27410. private _disableTouchAction;
  27411. private _rebuildInternalTextures;
  27412. private _rebuildEffects;
  27413. /**
  27414. * Gets a boolean indicating if all created effects are ready
  27415. * @returns true if all effects are ready
  27416. */
  27417. areAllEffectsReady(): boolean;
  27418. private _rebuildBuffers;
  27419. private _initGLContext;
  27420. /**
  27421. * Gets version of the current webGL context
  27422. */
  27423. readonly webGLVersion: number;
  27424. /**
  27425. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27426. */
  27427. readonly isStencilEnable: boolean;
  27428. private _prepareWorkingCanvas;
  27429. /**
  27430. * Reset the texture cache to empty state
  27431. */
  27432. resetTextureCache(): void;
  27433. /**
  27434. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27436. * @returns true if engine is in deterministic lock step mode
  27437. */
  27438. isDeterministicLockStep(): boolean;
  27439. /**
  27440. * Gets the max steps when engine is running in deterministic lock step
  27441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27442. * @returns the max steps
  27443. */
  27444. getLockstepMaxSteps(): number;
  27445. /**
  27446. * Gets an object containing information about the current webGL context
  27447. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27448. */
  27449. getGlInfo(): {
  27450. vendor: string;
  27451. renderer: string;
  27452. version: string;
  27453. };
  27454. /**
  27455. * Gets current aspect ratio
  27456. * @param camera defines the camera to use to get the aspect ratio
  27457. * @param useScreen defines if screen size must be used (or the current render target if any)
  27458. * @returns a number defining the aspect ratio
  27459. */
  27460. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27461. /**
  27462. * Gets current screen aspect ratio
  27463. * @returns a number defining the aspect ratio
  27464. */
  27465. getScreenAspectRatio(): number;
  27466. /**
  27467. * Gets the current render width
  27468. * @param useScreen defines if screen size must be used (or the current render target if any)
  27469. * @returns a number defining the current render width
  27470. */
  27471. getRenderWidth(useScreen?: boolean): number;
  27472. /**
  27473. * Gets the current render height
  27474. * @param useScreen defines if screen size must be used (or the current render target if any)
  27475. * @returns a number defining the current render height
  27476. */
  27477. getRenderHeight(useScreen?: boolean): number;
  27478. /**
  27479. * Gets the HTML canvas attached with the current webGL context
  27480. * @returns a HTML canvas
  27481. */
  27482. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27483. /**
  27484. * Gets the client rect of the HTML canvas attached with the current webGL context
  27485. * @returns a client rectanglee
  27486. */
  27487. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27488. /**
  27489. * Defines the hardware scaling level.
  27490. * By default the hardware scaling level is computed from the window device ratio.
  27491. * 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.
  27492. * @param level defines the level to use
  27493. */
  27494. setHardwareScalingLevel(level: number): void;
  27495. /**
  27496. * Gets the current hardware scaling level.
  27497. * By default the hardware scaling level is computed from the window device ratio.
  27498. * 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.
  27499. * @returns a number indicating the current hardware scaling level
  27500. */
  27501. getHardwareScalingLevel(): number;
  27502. /**
  27503. * Gets the list of loaded textures
  27504. * @returns an array containing all loaded textures
  27505. */
  27506. getLoadedTexturesCache(): InternalTexture[];
  27507. /**
  27508. * Gets the object containing all engine capabilities
  27509. * @returns the EngineCapabilities object
  27510. */
  27511. getCaps(): EngineCapabilities;
  27512. /**
  27513. * Gets the current depth function
  27514. * @returns a number defining the depth function
  27515. */
  27516. getDepthFunction(): Nullable<number>;
  27517. /**
  27518. * Sets the current depth function
  27519. * @param depthFunc defines the function to use
  27520. */
  27521. setDepthFunction(depthFunc: number): void;
  27522. /**
  27523. * Sets the current depth function to GREATER
  27524. */
  27525. setDepthFunctionToGreater(): void;
  27526. /**
  27527. * Sets the current depth function to GEQUAL
  27528. */
  27529. setDepthFunctionToGreaterOrEqual(): void;
  27530. /**
  27531. * Sets the current depth function to LESS
  27532. */
  27533. setDepthFunctionToLess(): void;
  27534. /**
  27535. * Sets the current depth function to LEQUAL
  27536. */
  27537. setDepthFunctionToLessOrEqual(): void;
  27538. /**
  27539. * Gets a boolean indicating if stencil buffer is enabled
  27540. * @returns the current stencil buffer state
  27541. */
  27542. getStencilBuffer(): boolean;
  27543. /**
  27544. * Enable or disable the stencil buffer
  27545. * @param enable defines if the stencil buffer must be enabled or disabled
  27546. */
  27547. setStencilBuffer(enable: boolean): void;
  27548. /**
  27549. * Gets the current stencil mask
  27550. * @returns a number defining the new stencil mask to use
  27551. */
  27552. getStencilMask(): number;
  27553. /**
  27554. * Sets the current stencil mask
  27555. * @param mask defines the new stencil mask to use
  27556. */
  27557. setStencilMask(mask: number): void;
  27558. /**
  27559. * Gets the current stencil function
  27560. * @returns a number defining the stencil function to use
  27561. */
  27562. getStencilFunction(): number;
  27563. /**
  27564. * Gets the current stencil reference value
  27565. * @returns a number defining the stencil reference value to use
  27566. */
  27567. getStencilFunctionReference(): number;
  27568. /**
  27569. * Gets the current stencil mask
  27570. * @returns a number defining the stencil mask to use
  27571. */
  27572. getStencilFunctionMask(): number;
  27573. /**
  27574. * Sets the current stencil function
  27575. * @param stencilFunc defines the new stencil function to use
  27576. */
  27577. setStencilFunction(stencilFunc: number): void;
  27578. /**
  27579. * Sets the current stencil reference
  27580. * @param reference defines the new stencil reference to use
  27581. */
  27582. setStencilFunctionReference(reference: number): void;
  27583. /**
  27584. * Sets the current stencil mask
  27585. * @param mask defines the new stencil mask to use
  27586. */
  27587. setStencilFunctionMask(mask: number): void;
  27588. /**
  27589. * Gets the current stencil operation when stencil fails
  27590. * @returns a number defining stencil operation to use when stencil fails
  27591. */
  27592. getStencilOperationFail(): number;
  27593. /**
  27594. * Gets the current stencil operation when depth fails
  27595. * @returns a number defining stencil operation to use when depth fails
  27596. */
  27597. getStencilOperationDepthFail(): number;
  27598. /**
  27599. * Gets the current stencil operation when stencil passes
  27600. * @returns a number defining stencil operation to use when stencil passes
  27601. */
  27602. getStencilOperationPass(): number;
  27603. /**
  27604. * Sets the stencil operation to use when stencil fails
  27605. * @param operation defines the stencil operation to use when stencil fails
  27606. */
  27607. setStencilOperationFail(operation: number): void;
  27608. /**
  27609. * Sets the stencil operation to use when depth fails
  27610. * @param operation defines the stencil operation to use when depth fails
  27611. */
  27612. setStencilOperationDepthFail(operation: number): void;
  27613. /**
  27614. * Sets the stencil operation to use when stencil passes
  27615. * @param operation defines the stencil operation to use when stencil passes
  27616. */
  27617. setStencilOperationPass(operation: number): void;
  27618. /**
  27619. * Sets a boolean indicating if the dithering state is enabled or disabled
  27620. * @param value defines the dithering state
  27621. */
  27622. setDitheringState(value: boolean): void;
  27623. /**
  27624. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27625. * @param value defines the rasterizer state
  27626. */
  27627. setRasterizerState(value: boolean): void;
  27628. /**
  27629. * stop executing a render loop function and remove it from the execution array
  27630. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27631. */
  27632. stopRenderLoop(renderFunction?: () => void): void;
  27633. /** @hidden */
  27634. _renderLoop(): void;
  27635. /**
  27636. * Register and execute a render loop. The engine can have more than one render function
  27637. * @param renderFunction defines the function to continuously execute
  27638. */
  27639. runRenderLoop(renderFunction: () => void): void;
  27640. /**
  27641. * Toggle full screen mode
  27642. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27643. */
  27644. switchFullscreen(requestPointerLock: boolean): void;
  27645. /**
  27646. * Enters full screen mode
  27647. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27648. */
  27649. enterFullscreen(requestPointerLock: boolean): void;
  27650. /**
  27651. * Exits full screen mode
  27652. */
  27653. exitFullscreen(): void;
  27654. /**
  27655. * Clear the current render buffer or the current render target (if any is set up)
  27656. * @param color defines the color to use
  27657. * @param backBuffer defines if the back buffer must be cleared
  27658. * @param depth defines if the depth buffer must be cleared
  27659. * @param stencil defines if the stencil buffer must be cleared
  27660. */
  27661. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27662. /**
  27663. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27664. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27665. * @param y defines the y-coordinate of the corner of the clear rectangle
  27666. * @param width defines the width of the clear rectangle
  27667. * @param height defines the height of the clear rectangle
  27668. * @param clearColor defines the clear color
  27669. */
  27670. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27671. /**
  27672. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27673. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27674. * @param y defines the y-coordinate of the corner of the clear rectangle
  27675. * @param width defines the width of the clear rectangle
  27676. * @param height defines the height of the clear rectangle
  27677. */
  27678. enableScissor(x: number, y: number, width: number, height: number): void;
  27679. /**
  27680. * Disable previously set scissor test rectangle
  27681. */
  27682. disableScissor(): void;
  27683. private _viewportCached;
  27684. /** @hidden */
  27685. _viewport(x: number, y: number, width: number, height: number): void;
  27686. /**
  27687. * Set the WebGL's viewport
  27688. * @param viewport defines the viewport element to be used
  27689. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27690. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27691. */
  27692. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27693. /**
  27694. * Directly set the WebGL Viewport
  27695. * @param x defines the x coordinate of the viewport (in screen space)
  27696. * @param y defines the y coordinate of the viewport (in screen space)
  27697. * @param width defines the width of the viewport (in screen space)
  27698. * @param height defines the height of the viewport (in screen space)
  27699. * @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
  27700. */
  27701. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27702. /**
  27703. * Begin a new frame
  27704. */
  27705. beginFrame(): void;
  27706. /**
  27707. * Enf the current frame
  27708. */
  27709. endFrame(): void;
  27710. /**
  27711. * Resize the view according to the canvas' size
  27712. */
  27713. resize(): void;
  27714. /**
  27715. * Force a specific size of the canvas
  27716. * @param width defines the new canvas' width
  27717. * @param height defines the new canvas' height
  27718. */
  27719. setSize(width: number, height: number): void;
  27720. /**
  27721. * Gets a boolean indicating if a webVR device was detected
  27722. * @returns true if a webVR device was detected
  27723. */
  27724. isVRDevicePresent(): boolean;
  27725. /**
  27726. * Gets the current webVR device
  27727. * @returns the current webVR device (or null)
  27728. */
  27729. getVRDevice(): any;
  27730. /**
  27731. * Initializes a webVR display and starts listening to display change events
  27732. * The onVRDisplayChangedObservable will be notified upon these changes
  27733. * @returns The onVRDisplayChangedObservable
  27734. */
  27735. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27736. /**
  27737. * Initializes a webVR display and starts listening to display change events
  27738. * The onVRDisplayChangedObservable will be notified upon these changes
  27739. * @returns A promise containing a VRDisplay and if vr is supported
  27740. */
  27741. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27742. /**
  27743. * Call this function to switch to webVR mode
  27744. * Will do nothing if webVR is not supported or if there is no webVR device
  27745. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27746. */
  27747. enableVR(): void;
  27748. /**
  27749. * Call this function to leave webVR mode
  27750. * Will do nothing if webVR is not supported or if there is no webVR device
  27751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27752. */
  27753. disableVR(): void;
  27754. private _onVRFullScreenTriggered;
  27755. private _getVRDisplaysAsync;
  27756. /**
  27757. * Binds the frame buffer to the specified texture.
  27758. * @param texture The texture to render to or null for the default canvas
  27759. * @param faceIndex The face of the texture to render to in case of cube texture
  27760. * @param requiredWidth The width of the target to render to
  27761. * @param requiredHeight The height of the target to render to
  27762. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27763. * @param depthStencilTexture The depth stencil texture to use to render
  27764. * @param lodLevel defines le lod level to bind to the frame buffer
  27765. */
  27766. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27767. private bindUnboundFramebuffer;
  27768. /**
  27769. * Unbind the current render target texture from the webGL context
  27770. * @param texture defines the render target texture to unbind
  27771. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27772. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27773. */
  27774. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27775. /**
  27776. * Unbind a list of render target textures from the webGL context
  27777. * This is used only when drawBuffer extension or webGL2 are active
  27778. * @param textures defines the render target textures to unbind
  27779. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27780. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27781. */
  27782. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27783. /**
  27784. * Force the mipmap generation for the given render target texture
  27785. * @param texture defines the render target texture to use
  27786. */
  27787. generateMipMapsForCubemap(texture: InternalTexture): void;
  27788. /**
  27789. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27790. */
  27791. flushFramebuffer(): void;
  27792. /**
  27793. * Unbind the current render target and bind the default framebuffer
  27794. */
  27795. restoreDefaultFramebuffer(): void;
  27796. /**
  27797. * Create an uniform buffer
  27798. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27799. * @param elements defines the content of the uniform buffer
  27800. * @returns the webGL uniform buffer
  27801. */
  27802. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27803. /**
  27804. * Create a dynamic uniform buffer
  27805. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27806. * @param elements defines the content of the uniform buffer
  27807. * @returns the webGL uniform buffer
  27808. */
  27809. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27810. /**
  27811. * Update an existing uniform buffer
  27812. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27813. * @param uniformBuffer defines the target uniform buffer
  27814. * @param elements defines the content to update
  27815. * @param offset defines the offset in the uniform buffer where update should start
  27816. * @param count defines the size of the data to update
  27817. */
  27818. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27819. private _resetVertexBufferBinding;
  27820. /**
  27821. * Creates a vertex buffer
  27822. * @param data the data for the vertex buffer
  27823. * @returns the new WebGL static buffer
  27824. */
  27825. createVertexBuffer(data: DataArray): WebGLBuffer;
  27826. /**
  27827. * Creates a dynamic vertex buffer
  27828. * @param data the data for the dynamic vertex buffer
  27829. * @returns the new WebGL dynamic buffer
  27830. */
  27831. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27832. /**
  27833. * Update a dynamic index buffer
  27834. * @param indexBuffer defines the target index buffer
  27835. * @param indices defines the data to update
  27836. * @param offset defines the offset in the target index buffer where update should start
  27837. */
  27838. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27839. /**
  27840. * Updates a dynamic vertex buffer.
  27841. * @param vertexBuffer the vertex buffer to update
  27842. * @param data the data used to update the vertex buffer
  27843. * @param byteOffset the byte offset of the data
  27844. * @param byteLength the byte length of the data
  27845. */
  27846. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27847. private _resetIndexBufferBinding;
  27848. /**
  27849. * Creates a new index buffer
  27850. * @param indices defines the content of the index buffer
  27851. * @param updatable defines if the index buffer must be updatable
  27852. * @returns a new webGL buffer
  27853. */
  27854. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27855. /**
  27856. * Bind a webGL buffer to the webGL context
  27857. * @param buffer defines the buffer to bind
  27858. */
  27859. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27860. /**
  27861. * Bind an uniform buffer to the current webGL context
  27862. * @param buffer defines the buffer to bind
  27863. */
  27864. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27865. /**
  27866. * Bind a buffer to the current webGL context at a given location
  27867. * @param buffer defines the buffer to bind
  27868. * @param location defines the index where to bind the buffer
  27869. */
  27870. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27871. /**
  27872. * Bind a specific block at a given index in a specific shader program
  27873. * @param shaderProgram defines the shader program
  27874. * @param blockName defines the block name
  27875. * @param index defines the index where to bind the block
  27876. */
  27877. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27878. private bindIndexBuffer;
  27879. private bindBuffer;
  27880. /**
  27881. * update the bound buffer with the given data
  27882. * @param data defines the data to update
  27883. */
  27884. updateArrayBuffer(data: Float32Array): void;
  27885. private _vertexAttribPointer;
  27886. private _bindIndexBufferWithCache;
  27887. private _bindVertexBuffersAttributes;
  27888. /**
  27889. * Records a vertex array object
  27890. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27891. * @param vertexBuffers defines the list of vertex buffers to store
  27892. * @param indexBuffer defines the index buffer to store
  27893. * @param effect defines the effect to store
  27894. * @returns the new vertex array object
  27895. */
  27896. recordVertexArrayObject(vertexBuffers: {
  27897. [key: string]: VertexBuffer;
  27898. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27899. /**
  27900. * Bind a specific vertex array object
  27901. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27902. * @param vertexArrayObject defines the vertex array object to bind
  27903. * @param indexBuffer defines the index buffer to bind
  27904. */
  27905. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27906. /**
  27907. * Bind webGl buffers directly to the webGL context
  27908. * @param vertexBuffer defines the vertex buffer to bind
  27909. * @param indexBuffer defines the index buffer to bind
  27910. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27911. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27912. * @param effect defines the effect associated with the vertex buffer
  27913. */
  27914. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27915. private _unbindVertexArrayObject;
  27916. /**
  27917. * Bind a list of vertex buffers to the webGL context
  27918. * @param vertexBuffers defines the list of vertex buffers to bind
  27919. * @param indexBuffer defines the index buffer to bind
  27920. * @param effect defines the effect associated with the vertex buffers
  27921. */
  27922. bindBuffers(vertexBuffers: {
  27923. [key: string]: Nullable<VertexBuffer>;
  27924. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27925. /**
  27926. * Unbind all instance attributes
  27927. */
  27928. unbindInstanceAttributes(): void;
  27929. /**
  27930. * Release and free the memory of a vertex array object
  27931. * @param vao defines the vertex array object to delete
  27932. */
  27933. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27934. /** @hidden */
  27935. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27936. /**
  27937. * Creates a webGL buffer to use with instanciation
  27938. * @param capacity defines the size of the buffer
  27939. * @returns the webGL buffer
  27940. */
  27941. createInstancesBuffer(capacity: number): WebGLBuffer;
  27942. /**
  27943. * Delete a webGL buffer used with instanciation
  27944. * @param buffer defines the webGL buffer to delete
  27945. */
  27946. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27947. /**
  27948. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27949. * @param instancesBuffer defines the webGL buffer to update and bind
  27950. * @param data defines the data to store in the buffer
  27951. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27952. */
  27953. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27954. /**
  27955. * Apply all cached states (depth, culling, stencil and alpha)
  27956. */
  27957. applyStates(): void;
  27958. /**
  27959. * Send a draw order
  27960. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27961. * @param indexStart defines the starting index
  27962. * @param indexCount defines the number of index to draw
  27963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27964. */
  27965. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27966. /**
  27967. * Draw a list of points
  27968. * @param verticesStart defines the index of first vertex to draw
  27969. * @param verticesCount defines the count of vertices to draw
  27970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27971. */
  27972. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27973. /**
  27974. * Draw a list of unindexed primitives
  27975. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27976. * @param verticesStart defines the index of first vertex to draw
  27977. * @param verticesCount defines the count of vertices to draw
  27978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27979. */
  27980. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27981. /**
  27982. * Draw a list of indexed primitives
  27983. * @param fillMode defines the primitive to use
  27984. * @param indexStart defines the starting index
  27985. * @param indexCount defines the number of index to draw
  27986. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27987. */
  27988. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27989. /**
  27990. * Draw a list of unindexed primitives
  27991. * @param fillMode defines the primitive to use
  27992. * @param verticesStart defines the index of first vertex to draw
  27993. * @param verticesCount defines the count of vertices to draw
  27994. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27995. */
  27996. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27997. private _drawMode;
  27998. /** @hidden */
  27999. _releaseEffect(effect: Effect): void;
  28000. /** @hidden */
  28001. _deleteProgram(program: WebGLProgram): void;
  28002. /**
  28003. * Create a new effect (used to store vertex/fragment shaders)
  28004. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28005. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28006. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28007. * @param samplers defines an array of string used to represent textures
  28008. * @param defines defines the string containing the defines to use to compile the shaders
  28009. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28010. * @param onCompiled defines a function to call when the effect creation is successful
  28011. * @param onError defines a function to call when the effect creation has failed
  28012. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28013. * @returns the new Effect
  28014. */
  28015. 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;
  28016. private _compileShader;
  28017. private _compileRawShader;
  28018. /**
  28019. * Directly creates a webGL program
  28020. * @param vertexCode defines the vertex shader code to use
  28021. * @param fragmentCode defines the fragment shader code to use
  28022. * @param context defines the webGL context to use (if not set, the current one will be used)
  28023. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28024. * @returns the new webGL program
  28025. */
  28026. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28027. /**
  28028. * Creates a webGL program
  28029. * @param vertexCode defines the vertex shader code to use
  28030. * @param fragmentCode defines the fragment shader code to use
  28031. * @param defines defines the string containing the defines to use to compile the shaders
  28032. * @param context defines the webGL context to use (if not set, the current one will be used)
  28033. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28034. * @returns the new webGL program
  28035. */
  28036. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28037. private _createShaderProgram;
  28038. private _finalizeProgram;
  28039. /** @hidden */
  28040. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28041. /** @hidden */
  28042. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28043. /**
  28044. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28045. * @param shaderProgram defines the webGL program to use
  28046. * @param uniformsNames defines the list of uniform names
  28047. * @returns an array of webGL uniform locations
  28048. */
  28049. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28050. /**
  28051. * Gets the lsit of active attributes for a given webGL program
  28052. * @param shaderProgram defines the webGL program to use
  28053. * @param attributesNames defines the list of attribute names to get
  28054. * @returns an array of indices indicating the offset of each attribute
  28055. */
  28056. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28057. /**
  28058. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28059. * @param effect defines the effect to activate
  28060. */
  28061. enableEffect(effect: Nullable<Effect>): void;
  28062. /**
  28063. * Set the value of an uniform to an array of int32
  28064. * @param uniform defines the webGL uniform location where to store the value
  28065. * @param array defines the array of int32 to store
  28066. */
  28067. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28068. /**
  28069. * Set the value of an uniform to an array of int32 (stored as vec2)
  28070. * @param uniform defines the webGL uniform location where to store the value
  28071. * @param array defines the array of int32 to store
  28072. */
  28073. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28074. /**
  28075. * Set the value of an uniform to an array of int32 (stored as vec3)
  28076. * @param uniform defines the webGL uniform location where to store the value
  28077. * @param array defines the array of int32 to store
  28078. */
  28079. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28080. /**
  28081. * Set the value of an uniform to an array of int32 (stored as vec4)
  28082. * @param uniform defines the webGL uniform location where to store the value
  28083. * @param array defines the array of int32 to store
  28084. */
  28085. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28086. /**
  28087. * Set the value of an uniform to an array of float32
  28088. * @param uniform defines the webGL uniform location where to store the value
  28089. * @param array defines the array of float32 to store
  28090. */
  28091. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28092. /**
  28093. * Set the value of an uniform to an array of float32 (stored as vec2)
  28094. * @param uniform defines the webGL uniform location where to store the value
  28095. * @param array defines the array of float32 to store
  28096. */
  28097. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28098. /**
  28099. * Set the value of an uniform to an array of float32 (stored as vec3)
  28100. * @param uniform defines the webGL uniform location where to store the value
  28101. * @param array defines the array of float32 to store
  28102. */
  28103. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28104. /**
  28105. * Set the value of an uniform to an array of float32 (stored as vec4)
  28106. * @param uniform defines the webGL uniform location where to store the value
  28107. * @param array defines the array of float32 to store
  28108. */
  28109. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28110. /**
  28111. * Set the value of an uniform to an array of number
  28112. * @param uniform defines the webGL uniform location where to store the value
  28113. * @param array defines the array of number to store
  28114. */
  28115. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28116. /**
  28117. * Set the value of an uniform to an array of number (stored as vec2)
  28118. * @param uniform defines the webGL uniform location where to store the value
  28119. * @param array defines the array of number to store
  28120. */
  28121. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28122. /**
  28123. * Set the value of an uniform to an array of number (stored as vec3)
  28124. * @param uniform defines the webGL uniform location where to store the value
  28125. * @param array defines the array of number to store
  28126. */
  28127. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28128. /**
  28129. * Set the value of an uniform to an array of number (stored as vec4)
  28130. * @param uniform defines the webGL uniform location where to store the value
  28131. * @param array defines the array of number to store
  28132. */
  28133. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28134. /**
  28135. * Set the value of an uniform to an array of float32 (stored as matrices)
  28136. * @param uniform defines the webGL uniform location where to store the value
  28137. * @param matrices defines the array of float32 to store
  28138. */
  28139. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28140. /**
  28141. * Set the value of an uniform to a matrix
  28142. * @param uniform defines the webGL uniform location where to store the value
  28143. * @param matrix defines the matrix to store
  28144. */
  28145. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28146. /**
  28147. * Set the value of an uniform to a matrix (3x3)
  28148. * @param uniform defines the webGL uniform location where to store the value
  28149. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28150. */
  28151. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28152. /**
  28153. * Set the value of an uniform to a matrix (2x2)
  28154. * @param uniform defines the webGL uniform location where to store the value
  28155. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28156. */
  28157. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28158. /**
  28159. * Set the value of an uniform to a number (int)
  28160. * @param uniform defines the webGL uniform location where to store the value
  28161. * @param value defines the int number to store
  28162. */
  28163. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28164. /**
  28165. * Set the value of an uniform to a number (float)
  28166. * @param uniform defines the webGL uniform location where to store the value
  28167. * @param value defines the float number to store
  28168. */
  28169. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28170. /**
  28171. * Set the value of an uniform to a vec2
  28172. * @param uniform defines the webGL uniform location where to store the value
  28173. * @param x defines the 1st component of the value
  28174. * @param y defines the 2nd component of the value
  28175. */
  28176. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28177. /**
  28178. * Set the value of an uniform to a vec3
  28179. * @param uniform defines the webGL uniform location where to store the value
  28180. * @param x defines the 1st component of the value
  28181. * @param y defines the 2nd component of the value
  28182. * @param z defines the 3rd component of the value
  28183. */
  28184. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28185. /**
  28186. * Set the value of an uniform to a boolean
  28187. * @param uniform defines the webGL uniform location where to store the value
  28188. * @param bool defines the boolean to store
  28189. */
  28190. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28191. /**
  28192. * Set the value of an uniform to a vec4
  28193. * @param uniform defines the webGL uniform location where to store the value
  28194. * @param x defines the 1st component of the value
  28195. * @param y defines the 2nd component of the value
  28196. * @param z defines the 3rd component of the value
  28197. * @param w defines the 4th component of the value
  28198. */
  28199. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28200. /**
  28201. * Set the value of an uniform to a Color3
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param color3 defines the color to store
  28204. */
  28205. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28206. /**
  28207. * Set the value of an uniform to a Color3 and an alpha value
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param color3 defines the color to store
  28210. * @param alpha defines the alpha component to store
  28211. */
  28212. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28213. /**
  28214. * Sets a Color4 on a uniform variable
  28215. * @param uniform defines the uniform location
  28216. * @param color4 defines the value to be set
  28217. */
  28218. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28219. /**
  28220. * Set various states to the webGL context
  28221. * @param culling defines backface culling state
  28222. * @param zOffset defines the value to apply to zOffset (0 by default)
  28223. * @param force defines if states must be applied even if cache is up to date
  28224. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28225. */
  28226. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28227. /**
  28228. * Set the z offset to apply to current rendering
  28229. * @param value defines the offset to apply
  28230. */
  28231. setZOffset(value: number): void;
  28232. /**
  28233. * Gets the current value of the zOffset
  28234. * @returns the current zOffset state
  28235. */
  28236. getZOffset(): number;
  28237. /**
  28238. * Enable or disable depth buffering
  28239. * @param enable defines the state to set
  28240. */
  28241. setDepthBuffer(enable: boolean): void;
  28242. /**
  28243. * Gets a boolean indicating if depth writing is enabled
  28244. * @returns the current depth writing state
  28245. */
  28246. getDepthWrite(): boolean;
  28247. /**
  28248. * Enable or disable depth writing
  28249. * @param enable defines the state to set
  28250. */
  28251. setDepthWrite(enable: boolean): void;
  28252. /**
  28253. * Enable or disable color writing
  28254. * @param enable defines the state to set
  28255. */
  28256. setColorWrite(enable: boolean): void;
  28257. /**
  28258. * Gets a boolean indicating if color writing is enabled
  28259. * @returns the current color writing state
  28260. */
  28261. getColorWrite(): boolean;
  28262. /**
  28263. * Sets alpha constants used by some alpha blending modes
  28264. * @param r defines the red component
  28265. * @param g defines the green component
  28266. * @param b defines the blue component
  28267. * @param a defines the alpha component
  28268. */
  28269. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28270. /**
  28271. * Sets the current alpha mode
  28272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28275. */
  28276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28277. /**
  28278. * Gets the current alpha mode
  28279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28280. * @returns the current alpha mode
  28281. */
  28282. getAlphaMode(): number;
  28283. /**
  28284. * Clears the list of texture accessible through engine.
  28285. * This can help preventing texture load conflict due to name collision.
  28286. */
  28287. clearInternalTexturesCache(): void;
  28288. /**
  28289. * Force the entire cache to be cleared
  28290. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28291. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28292. */
  28293. wipeCaches(bruteForce?: boolean): void;
  28294. /**
  28295. * Set the compressed texture format to use, based on the formats you have, and the formats
  28296. * supported by the hardware / browser.
  28297. *
  28298. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28299. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28300. * to API arguments needed to compressed textures. This puts the burden on the container
  28301. * generator to house the arcane code for determining these for current & future formats.
  28302. *
  28303. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28304. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28305. *
  28306. * Note: The result of this call is not taken into account when a texture is base64.
  28307. *
  28308. * @param formatsAvailable defines the list of those format families you have created
  28309. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28310. *
  28311. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28312. * @returns The extension selected.
  28313. */
  28314. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28315. private _getSamplingParameters;
  28316. private _partialLoadImg;
  28317. private _cascadeLoadImgs;
  28318. /** @hidden */
  28319. _createTexture(): WebGLTexture;
  28320. /**
  28321. * Usually called from Texture.ts.
  28322. * Passed information to create a WebGLTexture
  28323. * @param urlArg defines a value which contains one of the following:
  28324. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28325. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28326. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28328. * @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)
  28329. * @param scene needed for loading to the correct scene
  28330. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28331. * @param onLoad optional callback to be called upon successful completion
  28332. * @param onError optional callback to be called upon failure
  28333. * @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
  28334. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28335. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28336. * @param forcedExtension defines the extension to use to pick the right loader
  28337. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28338. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28339. */
  28340. 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;
  28341. private _rescaleTexture;
  28342. /**
  28343. * Update a raw texture
  28344. * @param texture defines the texture to update
  28345. * @param data defines the data to store in the texture
  28346. * @param format defines the format of the data
  28347. * @param invertY defines if data must be stored with Y axis inverted
  28348. * @param compression defines the compression used (null by default)
  28349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28350. */
  28351. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28352. /**
  28353. * Creates a raw texture
  28354. * @param data defines the data to store in the texture
  28355. * @param width defines the width of the texture
  28356. * @param height defines the height of the texture
  28357. * @param format defines the format of the data
  28358. * @param generateMipMaps defines if the engine should generate the mip levels
  28359. * @param invertY defines if data must be stored with Y axis inverted
  28360. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28361. * @param compression defines the compression used (null by default)
  28362. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28363. * @returns the raw texture inside an InternalTexture
  28364. */
  28365. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28366. private _unpackFlipYCached;
  28367. /**
  28368. * In case you are sharing the context with other applications, it might
  28369. * be interested to not cache the unpack flip y state to ensure a consistent
  28370. * value would be set.
  28371. */
  28372. enableUnpackFlipYCached: boolean;
  28373. /** @hidden */
  28374. _unpackFlipY(value: boolean): void;
  28375. /** @hidden */
  28376. _getUnpackAlignement(): number;
  28377. /**
  28378. * Creates a dynamic texture
  28379. * @param width defines the width of the texture
  28380. * @param height defines the height of the texture
  28381. * @param generateMipMaps defines if the engine should generate the mip levels
  28382. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28383. * @returns the dynamic texture inside an InternalTexture
  28384. */
  28385. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28386. /**
  28387. * Update the sampling mode of a given texture
  28388. * @param samplingMode defines the required sampling mode
  28389. * @param texture defines the texture to update
  28390. */
  28391. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28392. /**
  28393. * Update the content of a dynamic texture
  28394. * @param texture defines the texture to update
  28395. * @param canvas defines the canvas containing the source
  28396. * @param invertY defines if data must be stored with Y axis inverted
  28397. * @param premulAlpha defines if alpha is stored as premultiplied
  28398. * @param format defines the format of the data
  28399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28400. */
  28401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28402. /**
  28403. * Update a video texture
  28404. * @param texture defines the texture to update
  28405. * @param video defines the video element to use
  28406. * @param invertY defines if data must be stored with Y axis inverted
  28407. */
  28408. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28409. /**
  28410. * Updates a depth texture Comparison Mode and Function.
  28411. * If the comparison Function is equal to 0, the mode will be set to none.
  28412. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28413. * @param texture The texture to set the comparison function for
  28414. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28415. */
  28416. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28417. private _setupDepthStencilTexture;
  28418. /**
  28419. * Creates a depth stencil texture.
  28420. * This is only available in WebGL 2 or with the depth texture extension available.
  28421. * @param size The size of face edge in the texture.
  28422. * @param options The options defining the texture.
  28423. * @returns The texture
  28424. */
  28425. createDepthStencilTexture(size: number | {
  28426. width: number;
  28427. height: number;
  28428. }, options: DepthTextureCreationOptions): InternalTexture;
  28429. /**
  28430. * Creates a depth stencil texture.
  28431. * This is only available in WebGL 2 or with the depth texture extension available.
  28432. * @param size The size of face edge in the texture.
  28433. * @param options The options defining the texture.
  28434. * @returns The texture
  28435. */
  28436. private _createDepthStencilTexture;
  28437. /**
  28438. * Creates a depth stencil cube texture.
  28439. * This is only available in WebGL 2.
  28440. * @param size The size of face edge in the cube texture.
  28441. * @param options The options defining the cube texture.
  28442. * @returns The cube texture
  28443. */
  28444. private _createDepthStencilCubeTexture;
  28445. /**
  28446. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28447. * @param renderTarget The render target to set the frame buffer for
  28448. */
  28449. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28450. /**
  28451. * Creates a new render target texture
  28452. * @param size defines the size of the texture
  28453. * @param options defines the options used to create the texture
  28454. * @returns a new render target texture stored in an InternalTexture
  28455. */
  28456. createRenderTargetTexture(size: number | {
  28457. width: number;
  28458. height: number;
  28459. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28460. /**
  28461. * Create a multi render target texture
  28462. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28463. * @param size defines the size of the texture
  28464. * @param options defines the creation options
  28465. * @returns the cube texture as an InternalTexture
  28466. */
  28467. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28468. private _setupFramebufferDepthAttachments;
  28469. /**
  28470. * Updates the sample count of a render target texture
  28471. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28472. * @param texture defines the texture to update
  28473. * @param samples defines the sample count to set
  28474. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28475. */
  28476. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28477. /**
  28478. * Update the sample count for a given multiple render target texture
  28479. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28480. * @param textures defines the textures to update
  28481. * @param samples defines the sample count to set
  28482. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28483. */
  28484. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28485. /** @hidden */
  28486. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28487. /** @hidden */
  28488. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28489. /** @hidden */
  28490. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28491. /** @hidden */
  28492. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28493. /**
  28494. * Creates a new render target cube texture
  28495. * @param size defines the size of the texture
  28496. * @param options defines the options used to create the texture
  28497. * @returns a new render target cube texture stored in an InternalTexture
  28498. */
  28499. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28500. /**
  28501. * Creates a cube texture
  28502. * @param rootUrl defines the url where the files to load is located
  28503. * @param scene defines the current scene
  28504. * @param files defines the list of files to load (1 per face)
  28505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28506. * @param onLoad defines an optional callback raised when the texture is loaded
  28507. * @param onError defines an optional callback raised if there is an issue to load the texture
  28508. * @param format defines the format of the data
  28509. * @param forcedExtension defines the extension to use to pick the right loader
  28510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28513. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28514. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28515. * @returns the cube texture as an InternalTexture
  28516. */
  28517. 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;
  28518. /**
  28519. * @hidden
  28520. */
  28521. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28522. /**
  28523. * Update a raw cube texture
  28524. * @param texture defines the texture to udpdate
  28525. * @param data defines the data to store
  28526. * @param format defines the data format
  28527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28528. * @param invertY defines if data must be stored with Y axis inverted
  28529. * @param compression defines the compression used (null by default)
  28530. * @param level defines which level of the texture to update
  28531. */
  28532. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28533. /**
  28534. * Creates a new raw cube texture
  28535. * @param data defines the array of data to use to create each face
  28536. * @param size defines the size of the textures
  28537. * @param format defines the format of the data
  28538. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28539. * @param generateMipMaps defines if the engine should generate the mip levels
  28540. * @param invertY defines if data must be stored with Y axis inverted
  28541. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28542. * @param compression defines the compression used (null by default)
  28543. * @returns the cube texture as an InternalTexture
  28544. */
  28545. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28546. /**
  28547. * Creates a new raw cube texture from a specified url
  28548. * @param url defines the url where the data is located
  28549. * @param scene defines the current scene
  28550. * @param size defines the size of the textures
  28551. * @param format defines the format of the data
  28552. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28553. * @param noMipmap defines if the engine should avoid generating the mip levels
  28554. * @param callback defines a callback used to extract texture data from loaded data
  28555. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28556. * @param onLoad defines a callback called when texture is loaded
  28557. * @param onError defines a callback called if there is an error
  28558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28559. * @param invertY defines if data must be stored with Y axis inverted
  28560. * @returns the cube texture as an InternalTexture
  28561. */
  28562. 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;
  28563. /**
  28564. * Update a raw 3D texture
  28565. * @param texture defines the texture to update
  28566. * @param data defines the data to store
  28567. * @param format defines the data format
  28568. * @param invertY defines if data must be stored with Y axis inverted
  28569. * @param compression defines the used compression (can be null)
  28570. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28571. */
  28572. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28573. /**
  28574. * Creates a new raw 3D texture
  28575. * @param data defines the data used to create the texture
  28576. * @param width defines the width of the texture
  28577. * @param height defines the height of the texture
  28578. * @param depth defines the depth of the texture
  28579. * @param format defines the format of the texture
  28580. * @param generateMipMaps defines if the engine must generate mip levels
  28581. * @param invertY defines if data must be stored with Y axis inverted
  28582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28583. * @param compression defines the compressed used (can be null)
  28584. * @param textureType defines the compressed used (can be null)
  28585. * @returns a new raw 3D texture (stored in an InternalTexture)
  28586. */
  28587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28588. private _prepareWebGLTextureContinuation;
  28589. private _prepareWebGLTexture;
  28590. private _convertRGBtoRGBATextureData;
  28591. /** @hidden */
  28592. _releaseFramebufferObjects(texture: InternalTexture): void;
  28593. /** @hidden */
  28594. _releaseTexture(texture: InternalTexture): void;
  28595. private setProgram;
  28596. private _boundUniforms;
  28597. /**
  28598. * Binds an effect to the webGL context
  28599. * @param effect defines the effect to bind
  28600. */
  28601. bindSamplers(effect: Effect): void;
  28602. private _moveBoundTextureOnTop;
  28603. private _getCorrectTextureChannel;
  28604. private _linkTrackers;
  28605. private _removeDesignatedSlot;
  28606. private _activateCurrentTexture;
  28607. /** @hidden */
  28608. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28609. /** @hidden */
  28610. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28611. /**
  28612. * Sets a texture to the webGL context from a postprocess
  28613. * @param channel defines the channel to use
  28614. * @param postProcess defines the source postprocess
  28615. */
  28616. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28617. /**
  28618. * Binds the output of the passed in post process to the texture channel specified
  28619. * @param channel The channel the texture should be bound to
  28620. * @param postProcess The post process which's output should be bound
  28621. */
  28622. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28623. /**
  28624. * Unbind all textures from the webGL context
  28625. */
  28626. unbindAllTextures(): void;
  28627. /**
  28628. * Sets a texture to the according uniform.
  28629. * @param channel The texture channel
  28630. * @param uniform The uniform to set
  28631. * @param texture The texture to apply
  28632. */
  28633. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28634. /**
  28635. * Sets a depth stencil texture from a render target to the according uniform.
  28636. * @param channel The texture channel
  28637. * @param uniform The uniform to set
  28638. * @param texture The render target texture containing the depth stencil texture to apply
  28639. */
  28640. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28641. private _bindSamplerUniformToChannel;
  28642. private _getTextureWrapMode;
  28643. private _setTexture;
  28644. /**
  28645. * Sets an array of texture to the webGL context
  28646. * @param channel defines the channel where the texture array must be set
  28647. * @param uniform defines the associated uniform location
  28648. * @param textures defines the array of textures to bind
  28649. */
  28650. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28651. /** @hidden */
  28652. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28653. private _setTextureParameterFloat;
  28654. private _setTextureParameterInteger;
  28655. /**
  28656. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28657. * @param x defines the x coordinate of the rectangle where pixels must be read
  28658. * @param y defines the y coordinate of the rectangle where pixels must be read
  28659. * @param width defines the width of the rectangle where pixels must be read
  28660. * @param height defines the height of the rectangle where pixels must be read
  28661. * @returns a Uint8Array containing RGBA colors
  28662. */
  28663. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28664. /**
  28665. * Add an externaly attached data from its key.
  28666. * This method call will fail and return false, if such key already exists.
  28667. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28668. * @param key the unique key that identifies the data
  28669. * @param data the data object to associate to the key for this Engine instance
  28670. * @return true if no such key were already present and the data was added successfully, false otherwise
  28671. */
  28672. addExternalData<T>(key: string, data: T): boolean;
  28673. /**
  28674. * Get an externaly attached data from its key
  28675. * @param key the unique key that identifies the data
  28676. * @return the associated data, if present (can be null), or undefined if not present
  28677. */
  28678. getExternalData<T>(key: string): T;
  28679. /**
  28680. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28681. * @param key the unique key that identifies the data
  28682. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28683. * @return the associated data, can be null if the factory returned null.
  28684. */
  28685. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28686. /**
  28687. * Remove an externaly attached data from the Engine instance
  28688. * @param key the unique key that identifies the data
  28689. * @return true if the data was successfully removed, false if it doesn't exist
  28690. */
  28691. removeExternalData(key: string): boolean;
  28692. /**
  28693. * Unbind all vertex attributes from the webGL context
  28694. */
  28695. unbindAllAttributes(): void;
  28696. /**
  28697. * 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
  28698. */
  28699. releaseEffects(): void;
  28700. /**
  28701. * Dispose and release all associated resources
  28702. */
  28703. dispose(): void;
  28704. /**
  28705. * Display the loading screen
  28706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28707. */
  28708. displayLoadingUI(): void;
  28709. /**
  28710. * Hide the loading screen
  28711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28712. */
  28713. hideLoadingUI(): void;
  28714. /**
  28715. * Gets the current loading screen object
  28716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28717. */
  28718. /**
  28719. * Sets the current loading screen object
  28720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28721. */
  28722. loadingScreen: ILoadingScreen;
  28723. /**
  28724. * Sets the current loading screen text
  28725. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28726. */
  28727. loadingUIText: string;
  28728. /**
  28729. * Sets the current loading screen background color
  28730. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28731. */
  28732. loadingUIBackgroundColor: string;
  28733. /**
  28734. * Attach a new callback raised when context lost event is fired
  28735. * @param callback defines the callback to call
  28736. */
  28737. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28738. /**
  28739. * Attach a new callback raised when context restored event is fired
  28740. * @param callback defines the callback to call
  28741. */
  28742. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28743. /**
  28744. * Gets the source code of the vertex shader associated with a specific webGL program
  28745. * @param program defines the program to use
  28746. * @returns a string containing the source code of the vertex shader associated with the program
  28747. */
  28748. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28749. /**
  28750. * Gets the source code of the fragment shader associated with a specific webGL program
  28751. * @param program defines the program to use
  28752. * @returns a string containing the source code of the fragment shader associated with the program
  28753. */
  28754. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28755. /**
  28756. * Get the current error code of the webGL context
  28757. * @returns the error code
  28758. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28759. */
  28760. getError(): number;
  28761. /**
  28762. * Gets the current framerate
  28763. * @returns a number representing the framerate
  28764. */
  28765. getFps(): number;
  28766. /**
  28767. * Gets the time spent between current and previous frame
  28768. * @returns a number representing the delta time in ms
  28769. */
  28770. getDeltaTime(): number;
  28771. private _measureFps;
  28772. /** @hidden */
  28773. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28774. private _canRenderToFloatFramebuffer;
  28775. private _canRenderToHalfFloatFramebuffer;
  28776. private _canRenderToFramebuffer;
  28777. /** @hidden */
  28778. _getWebGLTextureType(type: number): number;
  28779. private _getInternalFormat;
  28780. /** @hidden */
  28781. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28782. /** @hidden */
  28783. _getRGBAMultiSampleBufferFormat(type: number): number;
  28784. /** @hidden */
  28785. _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;
  28786. /** @hidden */
  28787. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28788. private _partialLoadFile;
  28789. private _cascadeLoadFiles;
  28790. /**
  28791. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28792. * @returns true if the engine can be created
  28793. * @ignorenaming
  28794. */
  28795. static isSupported(): boolean;
  28796. }
  28797. }
  28798. declare module "babylonjs/Materials/effect" {
  28799. import { Observable } from "babylonjs/Misc/observable";
  28800. import { Nullable } from "babylonjs/types";
  28801. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28802. import { Engine } from "babylonjs/Engines/engine";
  28803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28804. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28808. /**
  28809. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28810. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28811. */
  28812. export class EffectFallbacks {
  28813. private _defines;
  28814. private _currentRank;
  28815. private _maxRank;
  28816. private _mesh;
  28817. /**
  28818. * Removes the fallback from the bound mesh.
  28819. */
  28820. unBindMesh(): void;
  28821. /**
  28822. * Adds a fallback on the specified property.
  28823. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28824. * @param define The name of the define in the shader
  28825. */
  28826. addFallback(rank: number, define: string): void;
  28827. /**
  28828. * Sets the mesh to use CPU skinning when needing to fallback.
  28829. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28830. * @param mesh The mesh to use the fallbacks.
  28831. */
  28832. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28833. /**
  28834. * Checks to see if more fallbacks are still availible.
  28835. */
  28836. readonly isMoreFallbacks: boolean;
  28837. /**
  28838. * Removes the defines that shoould be removed when falling back.
  28839. * @param currentDefines defines the current define statements for the shader.
  28840. * @param effect defines the current effect we try to compile
  28841. * @returns The resulting defines with defines of the current rank removed.
  28842. */
  28843. reduce(currentDefines: string, effect: Effect): string;
  28844. }
  28845. /**
  28846. * Options to be used when creating an effect.
  28847. */
  28848. export class EffectCreationOptions {
  28849. /**
  28850. * Atrributes that will be used in the shader.
  28851. */
  28852. attributes: string[];
  28853. /**
  28854. * Uniform varible names that will be set in the shader.
  28855. */
  28856. uniformsNames: string[];
  28857. /**
  28858. * Uniform buffer varible names that will be set in the shader.
  28859. */
  28860. uniformBuffersNames: string[];
  28861. /**
  28862. * Sampler texture variable names that will be set in the shader.
  28863. */
  28864. samplers: string[];
  28865. /**
  28866. * Define statements that will be set in the shader.
  28867. */
  28868. defines: any;
  28869. /**
  28870. * Possible fallbacks for this effect to improve performance when needed.
  28871. */
  28872. fallbacks: Nullable<EffectFallbacks>;
  28873. /**
  28874. * Callback that will be called when the shader is compiled.
  28875. */
  28876. onCompiled: Nullable<(effect: Effect) => void>;
  28877. /**
  28878. * Callback that will be called if an error occurs during shader compilation.
  28879. */
  28880. onError: Nullable<(effect: Effect, errors: string) => void>;
  28881. /**
  28882. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28883. */
  28884. indexParameters: any;
  28885. /**
  28886. * Max number of lights that can be used in the shader.
  28887. */
  28888. maxSimultaneousLights: number;
  28889. /**
  28890. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28891. */
  28892. transformFeedbackVaryings: Nullable<string[]>;
  28893. }
  28894. /**
  28895. * Effect containing vertex and fragment shader that can be executed on an object.
  28896. */
  28897. export class Effect {
  28898. /**
  28899. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28900. */
  28901. static ShadersRepository: string;
  28902. /**
  28903. * Name of the effect.
  28904. */
  28905. name: any;
  28906. /**
  28907. * String container all the define statements that should be set on the shader.
  28908. */
  28909. defines: string;
  28910. /**
  28911. * Callback that will be called when the shader is compiled.
  28912. */
  28913. onCompiled: Nullable<(effect: Effect) => void>;
  28914. /**
  28915. * Callback that will be called if an error occurs during shader compilation.
  28916. */
  28917. onError: Nullable<(effect: Effect, errors: string) => void>;
  28918. /**
  28919. * Callback that will be called when effect is bound.
  28920. */
  28921. onBind: Nullable<(effect: Effect) => void>;
  28922. /**
  28923. * Unique ID of the effect.
  28924. */
  28925. uniqueId: number;
  28926. /**
  28927. * Observable that will be called when the shader is compiled.
  28928. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28929. */
  28930. onCompileObservable: Observable<Effect>;
  28931. /**
  28932. * Observable that will be called if an error occurs during shader compilation.
  28933. */
  28934. onErrorObservable: Observable<Effect>;
  28935. /** @hidden */
  28936. _onBindObservable: Nullable<Observable<Effect>>;
  28937. /**
  28938. * Observable that will be called when effect is bound.
  28939. */
  28940. readonly onBindObservable: Observable<Effect>;
  28941. /** @hidden */
  28942. _bonesComputationForcedToCPU: boolean;
  28943. private static _uniqueIdSeed;
  28944. private _engine;
  28945. private _uniformBuffersNames;
  28946. private _uniformsNames;
  28947. private _samplers;
  28948. private _isReady;
  28949. private _compilationError;
  28950. private _attributesNames;
  28951. private _attributes;
  28952. private _uniforms;
  28953. /**
  28954. * Key for the effect.
  28955. * @hidden
  28956. */
  28957. _key: string;
  28958. private _indexParameters;
  28959. private _fallbacks;
  28960. private _vertexSourceCode;
  28961. private _fragmentSourceCode;
  28962. private _vertexSourceCodeOverride;
  28963. private _fragmentSourceCodeOverride;
  28964. private _transformFeedbackVaryings;
  28965. /**
  28966. * Compiled shader to webGL program.
  28967. * @hidden
  28968. */
  28969. _program: WebGLProgram;
  28970. private _valueCache;
  28971. private static _baseCache;
  28972. /**
  28973. * Instantiates an effect.
  28974. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28975. * @param baseName Name of the effect.
  28976. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28977. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28978. * @param samplers List of sampler variables that will be passed to the shader.
  28979. * @param engine Engine to be used to render the effect
  28980. * @param defines Define statements to be added to the shader.
  28981. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28982. * @param onCompiled Callback that will be called when the shader is compiled.
  28983. * @param onError Callback that will be called if an error occurs during shader compilation.
  28984. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28985. */
  28986. 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);
  28987. /**
  28988. * Unique key for this effect
  28989. */
  28990. readonly key: string;
  28991. /**
  28992. * If the effect has been compiled and prepared.
  28993. * @returns if the effect is compiled and prepared.
  28994. */
  28995. isReady(): boolean;
  28996. /**
  28997. * The engine the effect was initialized with.
  28998. * @returns the engine.
  28999. */
  29000. getEngine(): Engine;
  29001. /**
  29002. * The compiled webGL program for the effect
  29003. * @returns the webGL program.
  29004. */
  29005. getProgram(): WebGLProgram;
  29006. /**
  29007. * The set of names of attribute variables for the shader.
  29008. * @returns An array of attribute names.
  29009. */
  29010. getAttributesNames(): string[];
  29011. /**
  29012. * Returns the attribute at the given index.
  29013. * @param index The index of the attribute.
  29014. * @returns The location of the attribute.
  29015. */
  29016. getAttributeLocation(index: number): number;
  29017. /**
  29018. * Returns the attribute based on the name of the variable.
  29019. * @param name of the attribute to look up.
  29020. * @returns the attribute location.
  29021. */
  29022. getAttributeLocationByName(name: string): number;
  29023. /**
  29024. * The number of attributes.
  29025. * @returns the numnber of attributes.
  29026. */
  29027. getAttributesCount(): number;
  29028. /**
  29029. * Gets the index of a uniform variable.
  29030. * @param uniformName of the uniform to look up.
  29031. * @returns the index.
  29032. */
  29033. getUniformIndex(uniformName: string): number;
  29034. /**
  29035. * Returns the attribute based on the name of the variable.
  29036. * @param uniformName of the uniform to look up.
  29037. * @returns the location of the uniform.
  29038. */
  29039. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29040. /**
  29041. * Returns an array of sampler variable names
  29042. * @returns The array of sampler variable neames.
  29043. */
  29044. getSamplers(): string[];
  29045. /**
  29046. * The error from the last compilation.
  29047. * @returns the error string.
  29048. */
  29049. getCompilationError(): string;
  29050. /**
  29051. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29052. * @param func The callback to be used.
  29053. */
  29054. executeWhenCompiled(func: (effect: Effect) => void): void;
  29055. private _checkIsReady;
  29056. /** @hidden */
  29057. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29058. /** @hidden */
  29059. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29060. /** @hidden */
  29061. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29062. private _processShaderConversion;
  29063. private _processIncludes;
  29064. private _processPrecision;
  29065. /**
  29066. * Recompiles the webGL program
  29067. * @param vertexSourceCode The source code for the vertex shader.
  29068. * @param fragmentSourceCode The source code for the fragment shader.
  29069. * @param onCompiled Callback called when completed.
  29070. * @param onError Callback called on error.
  29071. * @hidden
  29072. */
  29073. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29074. /**
  29075. * Gets the uniform locations of the the specified variable names
  29076. * @param names THe names of the variables to lookup.
  29077. * @returns Array of locations in the same order as variable names.
  29078. */
  29079. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29080. /**
  29081. * Prepares the effect
  29082. * @hidden
  29083. */
  29084. _prepareEffect(): void;
  29085. /**
  29086. * Checks if the effect is supported. (Must be called after compilation)
  29087. */
  29088. readonly isSupported: boolean;
  29089. /**
  29090. * Binds a texture to the engine to be used as output of the shader.
  29091. * @param channel Name of the output variable.
  29092. * @param texture Texture to bind.
  29093. * @hidden
  29094. */
  29095. _bindTexture(channel: string, texture: InternalTexture): void;
  29096. /**
  29097. * Sets a texture on the engine to be used in the shader.
  29098. * @param channel Name of the sampler variable.
  29099. * @param texture Texture to set.
  29100. */
  29101. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29102. /**
  29103. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29104. * @param channel Name of the sampler variable.
  29105. * @param texture Texture to set.
  29106. */
  29107. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29108. /**
  29109. * Sets an array of textures on the engine to be used in the shader.
  29110. * @param channel Name of the variable.
  29111. * @param textures Textures to set.
  29112. */
  29113. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29114. /**
  29115. * 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)
  29116. * @param channel Name of the sampler variable.
  29117. * @param postProcess Post process to get the input texture from.
  29118. */
  29119. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29120. /**
  29121. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29122. * 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)
  29123. * @param channel Name of the sampler variable.
  29124. * @param postProcess Post process to get the output texture from.
  29125. */
  29126. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29127. /** @hidden */
  29128. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29129. /** @hidden */
  29130. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29131. /** @hidden */
  29132. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29133. /** @hidden */
  29134. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29135. /**
  29136. * Binds a buffer to a uniform.
  29137. * @param buffer Buffer to bind.
  29138. * @param name Name of the uniform variable to bind to.
  29139. */
  29140. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29141. /**
  29142. * Binds block to a uniform.
  29143. * @param blockName Name of the block to bind.
  29144. * @param index Index to bind.
  29145. */
  29146. bindUniformBlock(blockName: string, index: number): void;
  29147. /**
  29148. * Sets an interger value on a uniform variable.
  29149. * @param uniformName Name of the variable.
  29150. * @param value Value to be set.
  29151. * @returns this effect.
  29152. */
  29153. setInt(uniformName: string, value: number): Effect;
  29154. /**
  29155. * Sets an int array on a uniform variable.
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setIntArray(uniformName: string, array: Int32Array): Effect;
  29161. /**
  29162. * 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)
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29175. /**
  29176. * 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)
  29177. * @param uniformName Name of the variable.
  29178. * @param array array to be set.
  29179. * @returns this effect.
  29180. */
  29181. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29182. /**
  29183. * Sets an float array on a uniform variable.
  29184. * @param uniformName Name of the variable.
  29185. * @param array array to be set.
  29186. * @returns this effect.
  29187. */
  29188. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29189. /**
  29190. * 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)
  29191. * @param uniformName Name of the variable.
  29192. * @param array array to be set.
  29193. * @returns this effect.
  29194. */
  29195. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29196. /**
  29197. * 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)
  29198. * @param uniformName Name of the variable.
  29199. * @param array array to be set.
  29200. * @returns this effect.
  29201. */
  29202. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29203. /**
  29204. * 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)
  29205. * @param uniformName Name of the variable.
  29206. * @param array array to be set.
  29207. * @returns this effect.
  29208. */
  29209. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29210. /**
  29211. * Sets an array on a uniform variable.
  29212. * @param uniformName Name of the variable.
  29213. * @param array array to be set.
  29214. * @returns this effect.
  29215. */
  29216. setArray(uniformName: string, array: number[]): Effect;
  29217. /**
  29218. * 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)
  29219. * @param uniformName Name of the variable.
  29220. * @param array array to be set.
  29221. * @returns this effect.
  29222. */
  29223. setArray2(uniformName: string, array: number[]): Effect;
  29224. /**
  29225. * 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)
  29226. * @param uniformName Name of the variable.
  29227. * @param array array to be set.
  29228. * @returns this effect.
  29229. */
  29230. setArray3(uniformName: string, array: number[]): Effect;
  29231. /**
  29232. * 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)
  29233. * @param uniformName Name of the variable.
  29234. * @param array array to be set.
  29235. * @returns this effect.
  29236. */
  29237. setArray4(uniformName: string, array: number[]): Effect;
  29238. /**
  29239. * Sets matrices on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param matrices matrices to be set.
  29242. * @returns this effect.
  29243. */
  29244. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29245. /**
  29246. * Sets matrix on a uniform variable.
  29247. * @param uniformName Name of the variable.
  29248. * @param matrix matrix to be set.
  29249. * @returns this effect.
  29250. */
  29251. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29252. /**
  29253. * 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)
  29254. * @param uniformName Name of the variable.
  29255. * @param matrix matrix to be set.
  29256. * @returns this effect.
  29257. */
  29258. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29259. /**
  29260. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29261. * @param uniformName Name of the variable.
  29262. * @param matrix matrix to be set.
  29263. * @returns this effect.
  29264. */
  29265. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29266. /**
  29267. * Sets a float on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param value value to be set.
  29270. * @returns this effect.
  29271. */
  29272. setFloat(uniformName: string, value: number): Effect;
  29273. /**
  29274. * Sets a boolean on a uniform variable.
  29275. * @param uniformName Name of the variable.
  29276. * @param bool value to be set.
  29277. * @returns this effect.
  29278. */
  29279. setBool(uniformName: string, bool: boolean): Effect;
  29280. /**
  29281. * Sets a Vector2 on a uniform variable.
  29282. * @param uniformName Name of the variable.
  29283. * @param vector2 vector2 to be set.
  29284. * @returns this effect.
  29285. */
  29286. setVector2(uniformName: string, vector2: Vector2): Effect;
  29287. /**
  29288. * Sets a float2 on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param x First float in float2.
  29291. * @param y Second float in float2.
  29292. * @returns this effect.
  29293. */
  29294. setFloat2(uniformName: string, x: number, y: number): Effect;
  29295. /**
  29296. * Sets a Vector3 on a uniform variable.
  29297. * @param uniformName Name of the variable.
  29298. * @param vector3 Value to be set.
  29299. * @returns this effect.
  29300. */
  29301. setVector3(uniformName: string, vector3: Vector3): Effect;
  29302. /**
  29303. * Sets a float3 on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param x First float in float3.
  29306. * @param y Second float in float3.
  29307. * @param z Third float in float3.
  29308. * @returns this effect.
  29309. */
  29310. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29311. /**
  29312. * Sets a Vector4 on a uniform variable.
  29313. * @param uniformName Name of the variable.
  29314. * @param vector4 Value to be set.
  29315. * @returns this effect.
  29316. */
  29317. setVector4(uniformName: string, vector4: Vector4): Effect;
  29318. /**
  29319. * Sets a float4 on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param x First float in float4.
  29322. * @param y Second float in float4.
  29323. * @param z Third float in float4.
  29324. * @param w Fourth float in float4.
  29325. * @returns this effect.
  29326. */
  29327. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29328. /**
  29329. * Sets a Color3 on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param color3 Value to be set.
  29332. * @returns this effect.
  29333. */
  29334. setColor3(uniformName: string, color3: Color3): Effect;
  29335. /**
  29336. * Sets a Color4 on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param color3 Value to be set.
  29339. * @param alpha Alpha value to be set.
  29340. * @returns this effect.
  29341. */
  29342. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29343. /**
  29344. * Sets a Color4 on a uniform variable
  29345. * @param uniformName defines the name of the variable
  29346. * @param color4 defines the value to be set
  29347. * @returns this effect.
  29348. */
  29349. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29350. /**
  29351. * This function will add a new shader to the shader store
  29352. * @param name the name of the shader
  29353. * @param pixelShader optional pixel shader content
  29354. * @param vertexShader optional vertex shader content
  29355. */
  29356. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29357. /**
  29358. * Store of each shader (The can be looked up using effect.key)
  29359. */
  29360. static ShadersStore: {
  29361. [key: string]: string;
  29362. };
  29363. /**
  29364. * Store of each included file for a shader (The can be looked up using effect.key)
  29365. */
  29366. static IncludesShadersStore: {
  29367. [key: string]: string;
  29368. };
  29369. /**
  29370. * Resets the cache of effects.
  29371. */
  29372. static ResetCache(): void;
  29373. }
  29374. }
  29375. declare module "babylonjs/Materials/colorCurves" {
  29376. import { Effect } from "babylonjs/Materials/effect";
  29377. /**
  29378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29380. * 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;
  29381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29382. */
  29383. export class ColorCurves {
  29384. private _dirty;
  29385. private _tempColor;
  29386. private _globalCurve;
  29387. private _highlightsCurve;
  29388. private _midtonesCurve;
  29389. private _shadowsCurve;
  29390. private _positiveCurve;
  29391. private _negativeCurve;
  29392. private _globalHue;
  29393. private _globalDensity;
  29394. private _globalSaturation;
  29395. private _globalExposure;
  29396. /**
  29397. * Gets the global Hue value.
  29398. * 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).
  29399. */
  29400. /**
  29401. * Sets the global Hue value.
  29402. * 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).
  29403. */
  29404. globalHue: number;
  29405. /**
  29406. * Gets the global Density value.
  29407. * 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.
  29408. * Values less than zero provide a filter of opposite hue.
  29409. */
  29410. /**
  29411. * Sets the global Density value.
  29412. * 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.
  29413. * Values less than zero provide a filter of opposite hue.
  29414. */
  29415. globalDensity: number;
  29416. /**
  29417. * Gets the global Saturation value.
  29418. * 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.
  29419. */
  29420. /**
  29421. * Sets the global Saturation value.
  29422. * 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.
  29423. */
  29424. globalSaturation: number;
  29425. /**
  29426. * Gets the global Exposure value.
  29427. * 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.
  29428. */
  29429. /**
  29430. * Sets the global Exposure value.
  29431. * 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.
  29432. */
  29433. globalExposure: number;
  29434. private _highlightsHue;
  29435. private _highlightsDensity;
  29436. private _highlightsSaturation;
  29437. private _highlightsExposure;
  29438. /**
  29439. * Gets the highlights Hue value.
  29440. * 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).
  29441. */
  29442. /**
  29443. * Sets the highlights Hue value.
  29444. * 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).
  29445. */
  29446. highlightsHue: number;
  29447. /**
  29448. * Gets the highlights Density value.
  29449. * 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.
  29450. * Values less than zero provide a filter of opposite hue.
  29451. */
  29452. /**
  29453. * Sets the highlights Density value.
  29454. * 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.
  29455. * Values less than zero provide a filter of opposite hue.
  29456. */
  29457. highlightsDensity: number;
  29458. /**
  29459. * Gets the highlights Saturation value.
  29460. * 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.
  29461. */
  29462. /**
  29463. * Sets the highlights Saturation value.
  29464. * 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.
  29465. */
  29466. highlightsSaturation: number;
  29467. /**
  29468. * Gets the highlights Exposure value.
  29469. * 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.
  29470. */
  29471. /**
  29472. * Sets the highlights Exposure value.
  29473. * 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.
  29474. */
  29475. highlightsExposure: number;
  29476. private _midtonesHue;
  29477. private _midtonesDensity;
  29478. private _midtonesSaturation;
  29479. private _midtonesExposure;
  29480. /**
  29481. * Gets the midtones Hue value.
  29482. * 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).
  29483. */
  29484. /**
  29485. * Sets the midtones Hue value.
  29486. * 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).
  29487. */
  29488. midtonesHue: number;
  29489. /**
  29490. * Gets the midtones Density value.
  29491. * 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.
  29492. * Values less than zero provide a filter of opposite hue.
  29493. */
  29494. /**
  29495. * Sets the midtones Density value.
  29496. * 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.
  29497. * Values less than zero provide a filter of opposite hue.
  29498. */
  29499. midtonesDensity: number;
  29500. /**
  29501. * Gets the midtones Saturation value.
  29502. * 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.
  29503. */
  29504. /**
  29505. * Sets the midtones Saturation value.
  29506. * 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.
  29507. */
  29508. midtonesSaturation: number;
  29509. /**
  29510. * Gets the midtones Exposure value.
  29511. * 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.
  29512. */
  29513. /**
  29514. * Sets the midtones Exposure value.
  29515. * 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.
  29516. */
  29517. midtonesExposure: number;
  29518. private _shadowsHue;
  29519. private _shadowsDensity;
  29520. private _shadowsSaturation;
  29521. private _shadowsExposure;
  29522. /**
  29523. * Gets the shadows Hue value.
  29524. * 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).
  29525. */
  29526. /**
  29527. * Sets the shadows Hue value.
  29528. * 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).
  29529. */
  29530. shadowsHue: number;
  29531. /**
  29532. * Gets the shadows Density value.
  29533. * 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.
  29534. * Values less than zero provide a filter of opposite hue.
  29535. */
  29536. /**
  29537. * Sets the shadows Density value.
  29538. * 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.
  29539. * Values less than zero provide a filter of opposite hue.
  29540. */
  29541. shadowsDensity: number;
  29542. /**
  29543. * Gets the shadows Saturation value.
  29544. * 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.
  29545. */
  29546. /**
  29547. * Sets the shadows Saturation value.
  29548. * 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.
  29549. */
  29550. shadowsSaturation: number;
  29551. /**
  29552. * Gets the shadows Exposure value.
  29553. * 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.
  29554. */
  29555. /**
  29556. * Sets the shadows Exposure value.
  29557. * 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.
  29558. */
  29559. shadowsExposure: number;
  29560. /**
  29561. * Returns the class name
  29562. * @returns The class name
  29563. */
  29564. getClassName(): string;
  29565. /**
  29566. * Binds the color curves to the shader.
  29567. * @param colorCurves The color curve to bind
  29568. * @param effect The effect to bind to
  29569. * @param positiveUniform The positive uniform shader parameter
  29570. * @param neutralUniform The neutral uniform shader parameter
  29571. * @param negativeUniform The negative uniform shader parameter
  29572. */
  29573. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29574. /**
  29575. * Prepare the list of uniforms associated with the ColorCurves effects.
  29576. * @param uniformsList The list of uniforms used in the effect
  29577. */
  29578. static PrepareUniforms(uniformsList: string[]): void;
  29579. /**
  29580. * Returns color grading data based on a hue, density, saturation and exposure value.
  29581. * @param filterHue The hue of the color filter.
  29582. * @param filterDensity The density of the color filter.
  29583. * @param saturation The saturation.
  29584. * @param exposure The exposure.
  29585. * @param result The result data container.
  29586. */
  29587. private getColorGradingDataToRef;
  29588. /**
  29589. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29590. * @param value The input slider value in range [-100,100].
  29591. * @returns Adjusted value.
  29592. */
  29593. private static applyColorGradingSliderNonlinear;
  29594. /**
  29595. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29596. * @param hue The hue (H) input.
  29597. * @param saturation The saturation (S) input.
  29598. * @param brightness The brightness (B) input.
  29599. * @result An RGBA color represented as Vector4.
  29600. */
  29601. private static fromHSBToRef;
  29602. /**
  29603. * Returns a value clamped between min and max
  29604. * @param value The value to clamp
  29605. * @param min The minimum of value
  29606. * @param max The maximum of value
  29607. * @returns The clamped value.
  29608. */
  29609. private static clamp;
  29610. /**
  29611. * Clones the current color curve instance.
  29612. * @return The cloned curves
  29613. */
  29614. clone(): ColorCurves;
  29615. /**
  29616. * Serializes the current color curve instance to a json representation.
  29617. * @return a JSON representation
  29618. */
  29619. serialize(): any;
  29620. /**
  29621. * Parses the color curve from a json representation.
  29622. * @param source the JSON source to parse
  29623. * @return The parsed curves
  29624. */
  29625. static Parse(source: any): ColorCurves;
  29626. }
  29627. }
  29628. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29629. import { Observable } from "babylonjs/Misc/observable";
  29630. import { Nullable } from "babylonjs/types";
  29631. import { Color4 } from "babylonjs/Maths/math";
  29632. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29633. import { Effect } from "babylonjs/Materials/effect";
  29634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29635. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29636. /**
  29637. * Interface to follow in your material defines to integrate easily the
  29638. * Image proccessing functions.
  29639. * @hidden
  29640. */
  29641. export interface IImageProcessingConfigurationDefines {
  29642. IMAGEPROCESSING: boolean;
  29643. VIGNETTE: boolean;
  29644. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29645. VIGNETTEBLENDMODEOPAQUE: boolean;
  29646. TONEMAPPING: boolean;
  29647. TONEMAPPING_ACES: boolean;
  29648. CONTRAST: boolean;
  29649. EXPOSURE: boolean;
  29650. COLORCURVES: boolean;
  29651. COLORGRADING: boolean;
  29652. COLORGRADING3D: boolean;
  29653. SAMPLER3DGREENDEPTH: boolean;
  29654. SAMPLER3DBGRMAP: boolean;
  29655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29656. }
  29657. /**
  29658. * @hidden
  29659. */
  29660. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29661. IMAGEPROCESSING: boolean;
  29662. VIGNETTE: boolean;
  29663. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29664. VIGNETTEBLENDMODEOPAQUE: boolean;
  29665. TONEMAPPING: boolean;
  29666. TONEMAPPING_ACES: boolean;
  29667. CONTRAST: boolean;
  29668. COLORCURVES: boolean;
  29669. COLORGRADING: boolean;
  29670. COLORGRADING3D: boolean;
  29671. SAMPLER3DGREENDEPTH: boolean;
  29672. SAMPLER3DBGRMAP: boolean;
  29673. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29674. EXPOSURE: boolean;
  29675. constructor();
  29676. }
  29677. /**
  29678. * This groups together the common properties used for image processing either in direct forward pass
  29679. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29680. * or not.
  29681. */
  29682. export class ImageProcessingConfiguration {
  29683. /**
  29684. * Default tone mapping applied in BabylonJS.
  29685. */
  29686. static readonly TONEMAPPING_STANDARD: number;
  29687. /**
  29688. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29689. * to other engines rendering to increase portability.
  29690. */
  29691. static readonly TONEMAPPING_ACES: number;
  29692. /**
  29693. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29694. */
  29695. colorCurves: Nullable<ColorCurves>;
  29696. private _colorCurvesEnabled;
  29697. /**
  29698. * Gets wether the color curves effect is enabled.
  29699. */
  29700. /**
  29701. * Sets wether the color curves effect is enabled.
  29702. */
  29703. colorCurvesEnabled: boolean;
  29704. private _colorGradingTexture;
  29705. /**
  29706. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29707. */
  29708. /**
  29709. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29710. */
  29711. colorGradingTexture: Nullable<BaseTexture>;
  29712. private _colorGradingEnabled;
  29713. /**
  29714. * Gets wether the color grading effect is enabled.
  29715. */
  29716. /**
  29717. * Sets wether the color grading effect is enabled.
  29718. */
  29719. colorGradingEnabled: boolean;
  29720. private _colorGradingWithGreenDepth;
  29721. /**
  29722. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29723. */
  29724. /**
  29725. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29726. */
  29727. colorGradingWithGreenDepth: boolean;
  29728. private _colorGradingBGR;
  29729. /**
  29730. * Gets wether the color grading texture contains BGR values.
  29731. */
  29732. /**
  29733. * Sets wether the color grading texture contains BGR values.
  29734. */
  29735. colorGradingBGR: boolean;
  29736. /** @hidden */
  29737. _exposure: number;
  29738. /**
  29739. * Gets the Exposure used in the effect.
  29740. */
  29741. /**
  29742. * Sets the Exposure used in the effect.
  29743. */
  29744. exposure: number;
  29745. private _toneMappingEnabled;
  29746. /**
  29747. * Gets wether the tone mapping effect is enabled.
  29748. */
  29749. /**
  29750. * Sets wether the tone mapping effect is enabled.
  29751. */
  29752. toneMappingEnabled: boolean;
  29753. private _toneMappingType;
  29754. /**
  29755. * Gets the type of tone mapping effect.
  29756. */
  29757. /**
  29758. * Sets the type of tone mapping effect used in BabylonJS.
  29759. */
  29760. toneMappingType: number;
  29761. protected _contrast: number;
  29762. /**
  29763. * Gets the contrast used in the effect.
  29764. */
  29765. /**
  29766. * Sets the contrast used in the effect.
  29767. */
  29768. contrast: number;
  29769. /**
  29770. * Vignette stretch size.
  29771. */
  29772. vignetteStretch: number;
  29773. /**
  29774. * Vignette centre X Offset.
  29775. */
  29776. vignetteCentreX: number;
  29777. /**
  29778. * Vignette centre Y Offset.
  29779. */
  29780. vignetteCentreY: number;
  29781. /**
  29782. * Vignette weight or intensity of the vignette effect.
  29783. */
  29784. vignetteWeight: number;
  29785. /**
  29786. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29787. * if vignetteEnabled is set to true.
  29788. */
  29789. vignetteColor: Color4;
  29790. /**
  29791. * Camera field of view used by the Vignette effect.
  29792. */
  29793. vignetteCameraFov: number;
  29794. private _vignetteBlendMode;
  29795. /**
  29796. * Gets the vignette blend mode allowing different kind of effect.
  29797. */
  29798. /**
  29799. * Sets the vignette blend mode allowing different kind of effect.
  29800. */
  29801. vignetteBlendMode: number;
  29802. private _vignetteEnabled;
  29803. /**
  29804. * Gets wether the vignette effect is enabled.
  29805. */
  29806. /**
  29807. * Sets wether the vignette effect is enabled.
  29808. */
  29809. vignetteEnabled: boolean;
  29810. private _applyByPostProcess;
  29811. /**
  29812. * Gets wether the image processing is applied through a post process or not.
  29813. */
  29814. /**
  29815. * Sets wether the image processing is applied through a post process or not.
  29816. */
  29817. applyByPostProcess: boolean;
  29818. private _isEnabled;
  29819. /**
  29820. * Gets wether the image processing is enabled or not.
  29821. */
  29822. /**
  29823. * Sets wether the image processing is enabled or not.
  29824. */
  29825. isEnabled: boolean;
  29826. /**
  29827. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29828. */
  29829. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29830. /**
  29831. * Method called each time the image processing information changes requires to recompile the effect.
  29832. */
  29833. protected _updateParameters(): void;
  29834. /**
  29835. * Gets the current class name.
  29836. * @return "ImageProcessingConfiguration"
  29837. */
  29838. getClassName(): string;
  29839. /**
  29840. * Prepare the list of uniforms associated with the Image Processing effects.
  29841. * @param uniforms The list of uniforms used in the effect
  29842. * @param defines the list of defines currently in use
  29843. */
  29844. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29845. /**
  29846. * Prepare the list of samplers associated with the Image Processing effects.
  29847. * @param samplersList The list of uniforms used in the effect
  29848. * @param defines the list of defines currently in use
  29849. */
  29850. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29851. /**
  29852. * Prepare the list of defines associated to the shader.
  29853. * @param defines the list of defines to complete
  29854. * @param forPostProcess Define if we are currently in post process mode or not
  29855. */
  29856. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29857. /**
  29858. * Returns true if all the image processing information are ready.
  29859. * @returns True if ready, otherwise, false
  29860. */
  29861. isReady(): boolean;
  29862. /**
  29863. * Binds the image processing to the shader.
  29864. * @param effect The effect to bind to
  29865. * @param aspectRatio Define the current aspect ratio of the effect
  29866. */
  29867. bind(effect: Effect, aspectRatio?: number): void;
  29868. /**
  29869. * Clones the current image processing instance.
  29870. * @return The cloned image processing
  29871. */
  29872. clone(): ImageProcessingConfiguration;
  29873. /**
  29874. * Serializes the current image processing instance to a json representation.
  29875. * @return a JSON representation
  29876. */
  29877. serialize(): any;
  29878. /**
  29879. * Parses the image processing from a json representation.
  29880. * @param source the JSON source to parse
  29881. * @return The parsed image processing
  29882. */
  29883. static Parse(source: any): ImageProcessingConfiguration;
  29884. private static _VIGNETTEMODE_MULTIPLY;
  29885. private static _VIGNETTEMODE_OPAQUE;
  29886. /**
  29887. * Used to apply the vignette as a mix with the pixel color.
  29888. */
  29889. static readonly VIGNETTEMODE_MULTIPLY: number;
  29890. /**
  29891. * Used to apply the vignette as a replacement of the pixel color.
  29892. */
  29893. static readonly VIGNETTEMODE_OPAQUE: number;
  29894. }
  29895. }
  29896. declare module "babylonjs/Materials/fresnelParameters" {
  29897. import { Color3 } from "babylonjs/Maths/math";
  29898. /**
  29899. * This represents all the required information to add a fresnel effect on a material:
  29900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29901. */
  29902. export class FresnelParameters {
  29903. private _isEnabled;
  29904. /**
  29905. * Define if the fresnel effect is enable or not.
  29906. */
  29907. isEnabled: boolean;
  29908. /**
  29909. * Define the color used on edges (grazing angle)
  29910. */
  29911. leftColor: Color3;
  29912. /**
  29913. * Define the color used on center
  29914. */
  29915. rightColor: Color3;
  29916. /**
  29917. * Define bias applied to computed fresnel term
  29918. */
  29919. bias: number;
  29920. /**
  29921. * Defined the power exponent applied to fresnel term
  29922. */
  29923. power: number;
  29924. /**
  29925. * Clones the current fresnel and its valuues
  29926. * @returns a clone fresnel configuration
  29927. */
  29928. clone(): FresnelParameters;
  29929. /**
  29930. * Serializes the current fresnel parameters to a JSON representation.
  29931. * @return the JSON serialization
  29932. */
  29933. serialize(): any;
  29934. /**
  29935. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29936. * @param parsedFresnelParameters Define the JSON representation
  29937. * @returns the parsed parameters
  29938. */
  29939. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29940. }
  29941. }
  29942. declare module "babylonjs/Misc/decorators" {
  29943. import { Nullable } from "babylonjs/types";
  29944. import { Scene } from "babylonjs/scene";
  29945. import { IAnimatable } from "babylonjs/Misc/tools";
  29946. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29947. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29948. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29949. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29950. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29951. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29952. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29953. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29954. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29955. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29956. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29957. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29958. /**
  29959. * Decorator used to define property that can be serialized as reference to a camera
  29960. * @param sourceName defines the name of the property to decorate
  29961. */
  29962. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29963. /**
  29964. * Class used to help serialization objects
  29965. */
  29966. export class SerializationHelper {
  29967. /** hidden */
  29968. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29969. /** hidden */
  29970. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29971. /** hidden */
  29972. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29973. /** hidden */
  29974. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29975. /**
  29976. * Appends the serialized animations from the source animations
  29977. * @param source Source containing the animations
  29978. * @param destination Target to store the animations
  29979. */
  29980. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29981. /**
  29982. * Static function used to serialized a specific entity
  29983. * @param entity defines the entity to serialize
  29984. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29985. * @returns a JSON compatible object representing the serialization of the entity
  29986. */
  29987. static Serialize<T>(entity: T, serializationObject?: any): any;
  29988. /**
  29989. * Creates a new entity from a serialization data object
  29990. * @param creationFunction defines a function used to instanciated the new entity
  29991. * @param source defines the source serialization data
  29992. * @param scene defines the hosting scene
  29993. * @param rootUrl defines the root url for resources
  29994. * @returns a new entity
  29995. */
  29996. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29997. /**
  29998. * Clones an object
  29999. * @param creationFunction defines the function used to instanciate the new object
  30000. * @param source defines the source object
  30001. * @returns the cloned object
  30002. */
  30003. static Clone<T>(creationFunction: () => T, source: T): T;
  30004. /**
  30005. * Instanciates a new object based on a source one (some data will be shared between both object)
  30006. * @param creationFunction defines the function used to instanciate the new object
  30007. * @param source defines the source object
  30008. * @returns the new object
  30009. */
  30010. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30011. }
  30012. }
  30013. declare module "babylonjs/Cameras/camera" {
  30014. import { SmartArray } from "babylonjs/Misc/smartArray";
  30015. import { Observable } from "babylonjs/Misc/observable";
  30016. import { Nullable } from "babylonjs/types";
  30017. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30018. import { Scene } from "babylonjs/scene";
  30019. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30020. import { Node } from "babylonjs/node";
  30021. import { Mesh } from "babylonjs/Meshes/mesh";
  30022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30023. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30026. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30027. import { Ray } from "babylonjs/Culling/ray";
  30028. /**
  30029. * This is the base class of all the camera used in the application.
  30030. * @see http://doc.babylonjs.com/features/cameras
  30031. */
  30032. export class Camera extends Node {
  30033. /** @hidden */
  30034. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30035. /**
  30036. * This is the default projection mode used by the cameras.
  30037. * It helps recreating a feeling of perspective and better appreciate depth.
  30038. * This is the best way to simulate real life cameras.
  30039. */
  30040. static readonly PERSPECTIVE_CAMERA: number;
  30041. /**
  30042. * This helps creating camera with an orthographic mode.
  30043. * 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.
  30044. */
  30045. static readonly ORTHOGRAPHIC_CAMERA: number;
  30046. /**
  30047. * This is the default FOV mode for perspective cameras.
  30048. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30049. */
  30050. static readonly FOVMODE_VERTICAL_FIXED: number;
  30051. /**
  30052. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30053. */
  30054. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30055. /**
  30056. * This specifies ther is no need for a camera rig.
  30057. * Basically only one eye is rendered corresponding to the camera.
  30058. */
  30059. static readonly RIG_MODE_NONE: number;
  30060. /**
  30061. * Simulates a camera Rig with one blue eye and one red eye.
  30062. * This can be use with 3d blue and red glasses.
  30063. */
  30064. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30065. /**
  30066. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30067. */
  30068. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30069. /**
  30070. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30071. */
  30072. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30073. /**
  30074. * Defines that both eyes of the camera will be rendered over under each other.
  30075. */
  30076. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30077. /**
  30078. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30079. */
  30080. static readonly RIG_MODE_VR: number;
  30081. /**
  30082. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30083. */
  30084. static readonly RIG_MODE_WEBVR: number;
  30085. /**
  30086. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30087. */
  30088. static readonly RIG_MODE_CUSTOM: number;
  30089. /**
  30090. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30091. */
  30092. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30093. /**
  30094. * @hidden
  30095. * Might be removed once multiview will be a thing
  30096. */
  30097. static UseAlternateWebVRRendering: boolean;
  30098. /**
  30099. * Define the input manager associated with the camera.
  30100. */
  30101. inputs: CameraInputsManager<Camera>;
  30102. /**
  30103. * Define the current local position of the camera in the scene
  30104. */
  30105. position: Vector3;
  30106. /**
  30107. * The vector the camera should consider as up.
  30108. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30109. */
  30110. upVector: Vector3;
  30111. /**
  30112. * Define the current limit on the left side for an orthographic camera
  30113. * In scene unit
  30114. */
  30115. orthoLeft: Nullable<number>;
  30116. /**
  30117. * Define the current limit on the right side for an orthographic camera
  30118. * In scene unit
  30119. */
  30120. orthoRight: Nullable<number>;
  30121. /**
  30122. * Define the current limit on the bottom side for an orthographic camera
  30123. * In scene unit
  30124. */
  30125. orthoBottom: Nullable<number>;
  30126. /**
  30127. * Define the current limit on the top side for an orthographic camera
  30128. * In scene unit
  30129. */
  30130. orthoTop: Nullable<number>;
  30131. /**
  30132. * Field Of View is set in Radians. (default is 0.8)
  30133. */
  30134. fov: number;
  30135. /**
  30136. * Define the minimum distance the camera can see from.
  30137. * This is important to note that the depth buffer are not infinite and the closer it starts
  30138. * the more your scene might encounter depth fighting issue.
  30139. */
  30140. minZ: number;
  30141. /**
  30142. * Define the maximum distance the camera can see to.
  30143. * This is important to note that the depth buffer are not infinite and the further it end
  30144. * the more your scene might encounter depth fighting issue.
  30145. */
  30146. maxZ: number;
  30147. /**
  30148. * Define the default inertia of the camera.
  30149. * This helps giving a smooth feeling to the camera movement.
  30150. */
  30151. inertia: number;
  30152. /**
  30153. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30154. */
  30155. mode: number;
  30156. /**
  30157. * Define wether the camera is intermediate.
  30158. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30159. */
  30160. isIntermediate: boolean;
  30161. /**
  30162. * Define the viewport of the camera.
  30163. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30164. */
  30165. viewport: Viewport;
  30166. /**
  30167. * Restricts the camera to viewing objects with the same layerMask.
  30168. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30169. */
  30170. layerMask: number;
  30171. /**
  30172. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30173. */
  30174. fovMode: number;
  30175. /**
  30176. * Rig mode of the camera.
  30177. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30178. * This is normally controlled byt the camera themselves as internal use.
  30179. */
  30180. cameraRigMode: number;
  30181. /**
  30182. * Defines the distance between both "eyes" in case of a RIG
  30183. */
  30184. interaxialDistance: number;
  30185. /**
  30186. * Defines if stereoscopic rendering is done side by side or over under.
  30187. */
  30188. isStereoscopicSideBySide: boolean;
  30189. /**
  30190. * 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
  30191. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30192. * else in the scene.
  30193. */
  30194. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30195. /**
  30196. * When set, the camera will render to this render target instead of the default canvas
  30197. */
  30198. outputRenderTarget: Nullable<RenderTargetTexture>;
  30199. /**
  30200. * Observable triggered when the camera view matrix has changed.
  30201. */
  30202. onViewMatrixChangedObservable: Observable<Camera>;
  30203. /**
  30204. * Observable triggered when the camera Projection matrix has changed.
  30205. */
  30206. onProjectionMatrixChangedObservable: Observable<Camera>;
  30207. /**
  30208. * Observable triggered when the inputs have been processed.
  30209. */
  30210. onAfterCheckInputsObservable: Observable<Camera>;
  30211. /**
  30212. * Observable triggered when reset has been called and applied to the camera.
  30213. */
  30214. onRestoreStateObservable: Observable<Camera>;
  30215. /** @hidden */
  30216. _cameraRigParams: any;
  30217. /** @hidden */
  30218. _rigCameras: Camera[];
  30219. /** @hidden */
  30220. _rigPostProcess: Nullable<PostProcess>;
  30221. protected _webvrViewMatrix: Matrix;
  30222. /** @hidden */
  30223. _skipRendering: boolean;
  30224. /** @hidden */
  30225. _alternateCamera: Camera;
  30226. /** @hidden */
  30227. _projectionMatrix: Matrix;
  30228. /** @hidden */
  30229. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30230. /** @hidden */
  30231. _activeMeshes: SmartArray<AbstractMesh>;
  30232. protected _globalPosition: Vector3;
  30233. /** hidden */
  30234. _computedViewMatrix: Matrix;
  30235. private _doNotComputeProjectionMatrix;
  30236. private _transformMatrix;
  30237. private _frustumPlanes;
  30238. private _refreshFrustumPlanes;
  30239. private _storedFov;
  30240. private _stateStored;
  30241. /**
  30242. * Instantiates a new camera object.
  30243. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30244. * @see http://doc.babylonjs.com/features/cameras
  30245. * @param name Defines the name of the camera in the scene
  30246. * @param position Defines the position of the camera
  30247. * @param scene Defines the scene the camera belongs too
  30248. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30249. */
  30250. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30251. /**
  30252. * Store current camera state (fov, position, etc..)
  30253. * @returns the camera
  30254. */
  30255. storeState(): Camera;
  30256. /**
  30257. * Restores the camera state values if it has been stored. You must call storeState() first
  30258. */
  30259. protected _restoreStateValues(): boolean;
  30260. /**
  30261. * Restored camera state. You must call storeState() first.
  30262. * @returns true if restored and false otherwise
  30263. */
  30264. restoreState(): boolean;
  30265. /**
  30266. * Gets the class name of the camera.
  30267. * @returns the class name
  30268. */
  30269. getClassName(): string;
  30270. /** @hidden */
  30271. readonly _isCamera: boolean;
  30272. /**
  30273. * Gets a string representation of the camera useful for debug purpose.
  30274. * @param fullDetails Defines that a more verboe level of logging is required
  30275. * @returns the string representation
  30276. */
  30277. toString(fullDetails?: boolean): string;
  30278. /**
  30279. * Gets the current world space position of the camera.
  30280. */
  30281. readonly globalPosition: Vector3;
  30282. /**
  30283. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30284. * @returns the active meshe list
  30285. */
  30286. getActiveMeshes(): SmartArray<AbstractMesh>;
  30287. /**
  30288. * Check wether a mesh is part of the current active mesh list of the camera
  30289. * @param mesh Defines the mesh to check
  30290. * @returns true if active, false otherwise
  30291. */
  30292. isActiveMesh(mesh: Mesh): boolean;
  30293. /**
  30294. * Is this camera ready to be used/rendered
  30295. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30296. * @return true if the camera is ready
  30297. */
  30298. isReady(completeCheck?: boolean): boolean;
  30299. /** @hidden */
  30300. _initCache(): void;
  30301. /** @hidden */
  30302. _updateCache(ignoreParentClass?: boolean): void;
  30303. /** @hidden */
  30304. _isSynchronized(): boolean;
  30305. /** @hidden */
  30306. _isSynchronizedViewMatrix(): boolean;
  30307. /** @hidden */
  30308. _isSynchronizedProjectionMatrix(): boolean;
  30309. /**
  30310. * Attach the input controls to a specific dom element to get the input from.
  30311. * @param element Defines the element the controls should be listened from
  30312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30313. */
  30314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30315. /**
  30316. * Detach the current controls from the specified dom element.
  30317. * @param element Defines the element to stop listening the inputs from
  30318. */
  30319. detachControl(element: HTMLElement): void;
  30320. /**
  30321. * Update the camera state according to the different inputs gathered during the frame.
  30322. */
  30323. update(): void;
  30324. /** @hidden */
  30325. _checkInputs(): void;
  30326. /** @hidden */
  30327. readonly rigCameras: Camera[];
  30328. /**
  30329. * Gets the post process used by the rig cameras
  30330. */
  30331. readonly rigPostProcess: Nullable<PostProcess>;
  30332. /**
  30333. * Internal, gets the first post proces.
  30334. * @returns the first post process to be run on this camera.
  30335. */
  30336. _getFirstPostProcess(): Nullable<PostProcess>;
  30337. private _cascadePostProcessesToRigCams;
  30338. /**
  30339. * Attach a post process to the camera.
  30340. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30341. * @param postProcess The post process to attach to the camera
  30342. * @param insertAt The position of the post process in case several of them are in use in the scene
  30343. * @returns the position the post process has been inserted at
  30344. */
  30345. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30346. /**
  30347. * Detach a post process to the camera.
  30348. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30349. * @param postProcess The post process to detach from the camera
  30350. */
  30351. detachPostProcess(postProcess: PostProcess): void;
  30352. /**
  30353. * Gets the current world matrix of the camera
  30354. */
  30355. getWorldMatrix(): Matrix;
  30356. /** @hidden */
  30357. _getViewMatrix(): Matrix;
  30358. /**
  30359. * Gets the current view matrix of the camera.
  30360. * @param force forces the camera to recompute the matrix without looking at the cached state
  30361. * @returns the view matrix
  30362. */
  30363. getViewMatrix(force?: boolean): Matrix;
  30364. /**
  30365. * Freeze the projection matrix.
  30366. * It will prevent the cache check of the camera projection compute and can speed up perf
  30367. * if no parameter of the camera are meant to change
  30368. * @param projection Defines manually a projection if necessary
  30369. */
  30370. freezeProjectionMatrix(projection?: Matrix): void;
  30371. /**
  30372. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30373. */
  30374. unfreezeProjectionMatrix(): void;
  30375. /**
  30376. * Gets the current projection matrix of the camera.
  30377. * @param force forces the camera to recompute the matrix without looking at the cached state
  30378. * @returns the projection matrix
  30379. */
  30380. getProjectionMatrix(force?: boolean): Matrix;
  30381. /**
  30382. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30383. * @returns a Matrix
  30384. */
  30385. getTransformationMatrix(): Matrix;
  30386. private _updateFrustumPlanes;
  30387. /**
  30388. * Checks if a cullable object (mesh...) is in the camera frustum
  30389. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30390. * @param target The object to check
  30391. * @returns true if the object is in frustum otherwise false
  30392. */
  30393. isInFrustum(target: ICullable): boolean;
  30394. /**
  30395. * Checks if a cullable object (mesh...) is in the camera frustum
  30396. * Unlike isInFrustum this cheks the full bounding box
  30397. * @param target The object to check
  30398. * @returns true if the object is in frustum otherwise false
  30399. */
  30400. isCompletelyInFrustum(target: ICullable): boolean;
  30401. /**
  30402. * Gets a ray in the forward direction from the camera.
  30403. * @param length Defines the length of the ray to create
  30404. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30405. * @param origin Defines the start point of the ray which defaults to the camera position
  30406. * @returns the forward ray
  30407. */
  30408. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30409. /**
  30410. * Releases resources associated with this node.
  30411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30413. */
  30414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30415. /**
  30416. * Gets the left camera of a rig setup in case of Rigged Camera
  30417. */
  30418. readonly leftCamera: Nullable<FreeCamera>;
  30419. /**
  30420. * Gets the right camera of a rig setup in case of Rigged Camera
  30421. */
  30422. readonly rightCamera: Nullable<FreeCamera>;
  30423. /**
  30424. * Gets the left camera target of a rig setup in case of Rigged Camera
  30425. * @returns the target position
  30426. */
  30427. getLeftTarget(): Nullable<Vector3>;
  30428. /**
  30429. * Gets the right camera target of a rig setup in case of Rigged Camera
  30430. * @returns the target position
  30431. */
  30432. getRightTarget(): Nullable<Vector3>;
  30433. /**
  30434. * @hidden
  30435. */
  30436. setCameraRigMode(mode: number, rigParams: any): void;
  30437. /** @hidden */
  30438. static _setStereoscopicRigMode(camera: Camera): void;
  30439. /** @hidden */
  30440. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30441. /** @hidden */
  30442. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30443. /** @hidden */
  30444. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30445. /** @hidden */
  30446. _getVRProjectionMatrix(): Matrix;
  30447. protected _updateCameraRotationMatrix(): void;
  30448. protected _updateWebVRCameraRotationMatrix(): void;
  30449. /**
  30450. * This function MUST be overwritten by the different WebVR cameras available.
  30451. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30452. * @hidden
  30453. */
  30454. _getWebVRProjectionMatrix(): Matrix;
  30455. /**
  30456. * This function MUST be overwritten by the different WebVR cameras available.
  30457. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30458. * @hidden
  30459. */
  30460. _getWebVRViewMatrix(): Matrix;
  30461. /** @hidden */
  30462. setCameraRigParameter(name: string, value: any): void;
  30463. /**
  30464. * needs to be overridden by children so sub has required properties to be copied
  30465. * @hidden
  30466. */
  30467. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30468. /**
  30469. * May need to be overridden by children
  30470. * @hidden
  30471. */
  30472. _updateRigCameras(): void;
  30473. /** @hidden */
  30474. _setupInputs(): void;
  30475. /**
  30476. * Serialiaze the camera setup to a json represention
  30477. * @returns the JSON representation
  30478. */
  30479. serialize(): any;
  30480. /**
  30481. * Clones the current camera.
  30482. * @param name The cloned camera name
  30483. * @returns the cloned camera
  30484. */
  30485. clone(name: string): Camera;
  30486. /**
  30487. * Gets the direction of the camera relative to a given local axis.
  30488. * @param localAxis Defines the reference axis to provide a relative direction.
  30489. * @return the direction
  30490. */
  30491. getDirection(localAxis: Vector3): Vector3;
  30492. /**
  30493. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30494. * @param localAxis Defines the reference axis to provide a relative direction.
  30495. * @param result Defines the vector to store the result in
  30496. */
  30497. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30498. /**
  30499. * Gets a camera constructor for a given camera type
  30500. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30501. * @param name The name of the camera the result will be able to instantiate
  30502. * @param scene The scene the result will construct the camera in
  30503. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30504. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30505. * @returns a factory method to construc the camera
  30506. */
  30507. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30508. /**
  30509. * Compute the world matrix of the camera.
  30510. * @returns the camera workd matrix
  30511. */
  30512. computeWorldMatrix(): Matrix;
  30513. /**
  30514. * Parse a JSON and creates the camera from the parsed information
  30515. * @param parsedCamera The JSON to parse
  30516. * @param scene The scene to instantiate the camera in
  30517. * @returns the newly constructed camera
  30518. */
  30519. static Parse(parsedCamera: any, scene: Scene): Camera;
  30520. }
  30521. }
  30522. declare module "babylonjs/Misc/tools" {
  30523. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30524. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30525. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30526. import { Observable } from "babylonjs/Misc/observable";
  30527. import { DomManagement } from "babylonjs/Misc/domManagement";
  30528. import { Camera } from "babylonjs/Cameras/camera";
  30529. import { Engine } from "babylonjs/Engines/engine";
  30530. import { Animation } from "babylonjs/Animations/animation";
  30531. /**
  30532. * Interface for any object that can request an animation frame
  30533. */
  30534. export interface ICustomAnimationFrameRequester {
  30535. /**
  30536. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30537. */
  30538. renderFunction?: Function;
  30539. /**
  30540. * Called to request the next frame to render to
  30541. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30542. */
  30543. requestAnimationFrame: Function;
  30544. /**
  30545. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30546. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30547. */
  30548. requestID?: number;
  30549. }
  30550. /**
  30551. * Interface containing an array of animations
  30552. */
  30553. export interface IAnimatable {
  30554. /**
  30555. * Array of animations
  30556. */
  30557. animations: Array<Animation>;
  30558. }
  30559. /** Interface used by value gradients (color, factor, ...) */
  30560. export interface IValueGradient {
  30561. /**
  30562. * Gets or sets the gradient value (between 0 and 1)
  30563. */
  30564. gradient: number;
  30565. }
  30566. /** Class used to store color4 gradient */
  30567. export class ColorGradient implements IValueGradient {
  30568. /**
  30569. * Gets or sets the gradient value (between 0 and 1)
  30570. */
  30571. gradient: number;
  30572. /**
  30573. * Gets or sets first associated color
  30574. */
  30575. color1: Color4;
  30576. /**
  30577. * Gets or sets second associated color
  30578. */
  30579. color2?: Color4;
  30580. /**
  30581. * Will get a color picked randomly between color1 and color2.
  30582. * If color2 is undefined then color1 will be used
  30583. * @param result defines the target Color4 to store the result in
  30584. */
  30585. getColorToRef(result: Color4): void;
  30586. }
  30587. /** Class used to store color 3 gradient */
  30588. export class Color3Gradient implements IValueGradient {
  30589. /**
  30590. * Gets or sets the gradient value (between 0 and 1)
  30591. */
  30592. gradient: number;
  30593. /**
  30594. * Gets or sets the associated color
  30595. */
  30596. color: Color3;
  30597. }
  30598. /** Class used to store factor gradient */
  30599. export class FactorGradient implements IValueGradient {
  30600. /**
  30601. * Gets or sets the gradient value (between 0 and 1)
  30602. */
  30603. gradient: number;
  30604. /**
  30605. * Gets or sets first associated factor
  30606. */
  30607. factor1: number;
  30608. /**
  30609. * Gets or sets second associated factor
  30610. */
  30611. factor2?: number;
  30612. /**
  30613. * Will get a number picked randomly between factor1 and factor2.
  30614. * If factor2 is undefined then factor1 will be used
  30615. * @returns the picked number
  30616. */
  30617. getFactor(): number;
  30618. }
  30619. /**
  30620. * @ignore
  30621. * Application error to support additional information when loading a file
  30622. */
  30623. export class LoadFileError extends Error {
  30624. /** defines the optional XHR request */
  30625. request?: XMLHttpRequest | undefined;
  30626. private static _setPrototypeOf;
  30627. /**
  30628. * Creates a new LoadFileError
  30629. * @param message defines the message of the error
  30630. * @param request defines the optional XHR request
  30631. */
  30632. constructor(message: string,
  30633. /** defines the optional XHR request */
  30634. request?: XMLHttpRequest | undefined);
  30635. }
  30636. /**
  30637. * Class used to define a retry strategy when error happens while loading assets
  30638. */
  30639. export class RetryStrategy {
  30640. /**
  30641. * Function used to defines an exponential back off strategy
  30642. * @param maxRetries defines the maximum number of retries (3 by default)
  30643. * @param baseInterval defines the interval between retries
  30644. * @returns the strategy function to use
  30645. */
  30646. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30647. }
  30648. /**
  30649. * File request interface
  30650. */
  30651. export interface IFileRequest {
  30652. /**
  30653. * Raised when the request is complete (success or error).
  30654. */
  30655. onCompleteObservable: Observable<IFileRequest>;
  30656. /**
  30657. * Aborts the request for a file.
  30658. */
  30659. abort: () => void;
  30660. }
  30661. /**
  30662. * Class containing a set of static utilities functions
  30663. */
  30664. export class Tools {
  30665. /**
  30666. * Gets or sets the base URL to use to load assets
  30667. */
  30668. static BaseUrl: string;
  30669. /**
  30670. * Enable/Disable Custom HTTP Request Headers globally.
  30671. * default = false
  30672. * @see CustomRequestHeaders
  30673. */
  30674. static UseCustomRequestHeaders: boolean;
  30675. /**
  30676. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30677. * i.e. when loading files, where the server/service expects an Authorization header.
  30678. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30679. */
  30680. static CustomRequestHeaders: {
  30681. [key: string]: string;
  30682. };
  30683. /**
  30684. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30685. */
  30686. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30687. /**
  30688. * Default behaviour for cors in the application.
  30689. * It can be a string if the expected behavior is identical in the entire app.
  30690. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30691. */
  30692. static CorsBehavior: string | ((url: string | string[]) => string);
  30693. /**
  30694. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30695. * @ignorenaming
  30696. */
  30697. static UseFallbackTexture: boolean;
  30698. /**
  30699. * Use this object to register external classes like custom textures or material
  30700. * to allow the laoders to instantiate them
  30701. */
  30702. static RegisteredExternalClasses: {
  30703. [key: string]: Object;
  30704. };
  30705. /**
  30706. * Texture content used if a texture cannot loaded
  30707. * @ignorenaming
  30708. */
  30709. static fallbackTexture: string;
  30710. /**
  30711. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30712. * @param u defines the coordinate on X axis
  30713. * @param v defines the coordinate on Y axis
  30714. * @param width defines the width of the source data
  30715. * @param height defines the height of the source data
  30716. * @param pixels defines the source byte array
  30717. * @param color defines the output color
  30718. */
  30719. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30720. /**
  30721. * Interpolates between a and b via alpha
  30722. * @param a The lower value (returned when alpha = 0)
  30723. * @param b The upper value (returned when alpha = 1)
  30724. * @param alpha The interpolation-factor
  30725. * @return The mixed value
  30726. */
  30727. static Mix(a: number, b: number, alpha: number): number;
  30728. /**
  30729. * Tries to instantiate a new object from a given class name
  30730. * @param className defines the class name to instantiate
  30731. * @returns the new object or null if the system was not able to do the instantiation
  30732. */
  30733. static Instantiate(className: string): any;
  30734. /**
  30735. * Provides a slice function that will work even on IE
  30736. * @param data defines the array to slice
  30737. * @param start defines the start of the data (optional)
  30738. * @param end defines the end of the data (optional)
  30739. * @returns the new sliced array
  30740. */
  30741. static Slice<T>(data: T, start?: number, end?: number): T;
  30742. /**
  30743. * Polyfill for setImmediate
  30744. * @param action defines the action to execute after the current execution block
  30745. */
  30746. static SetImmediate(action: () => void): void;
  30747. /**
  30748. * Function indicating if a number is an exponent of 2
  30749. * @param value defines the value to test
  30750. * @returns true if the value is an exponent of 2
  30751. */
  30752. static IsExponentOfTwo(value: number): boolean;
  30753. private static _tmpFloatArray;
  30754. /**
  30755. * Returns the nearest 32-bit single precision float representation of a Number
  30756. * @param value A Number. If the parameter is of a different type, it will get converted
  30757. * to a number or to NaN if it cannot be converted
  30758. * @returns number
  30759. */
  30760. static FloatRound(value: number): number;
  30761. /**
  30762. * Find the next highest power of two.
  30763. * @param x Number to start search from.
  30764. * @return Next highest power of two.
  30765. */
  30766. static CeilingPOT(x: number): number;
  30767. /**
  30768. * Find the next lowest power of two.
  30769. * @param x Number to start search from.
  30770. * @return Next lowest power of two.
  30771. */
  30772. static FloorPOT(x: number): number;
  30773. /**
  30774. * Find the nearest power of two.
  30775. * @param x Number to start search from.
  30776. * @return Next nearest power of two.
  30777. */
  30778. static NearestPOT(x: number): number;
  30779. /**
  30780. * Get the closest exponent of two
  30781. * @param value defines the value to approximate
  30782. * @param max defines the maximum value to return
  30783. * @param mode defines how to define the closest value
  30784. * @returns closest exponent of two of the given value
  30785. */
  30786. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30787. /**
  30788. * Extracts the filename from a path
  30789. * @param path defines the path to use
  30790. * @returns the filename
  30791. */
  30792. static GetFilename(path: string): string;
  30793. /**
  30794. * Extracts the "folder" part of a path (everything before the filename).
  30795. * @param uri The URI to extract the info from
  30796. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30797. * @returns The "folder" part of the path
  30798. */
  30799. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30800. /**
  30801. * Extracts text content from a DOM element hierarchy
  30802. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30803. */
  30804. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30805. /**
  30806. * Convert an angle in radians to degrees
  30807. * @param angle defines the angle to convert
  30808. * @returns the angle in degrees
  30809. */
  30810. static ToDegrees(angle: number): number;
  30811. /**
  30812. * Convert an angle in degrees to radians
  30813. * @param angle defines the angle to convert
  30814. * @returns the angle in radians
  30815. */
  30816. static ToRadians(angle: number): number;
  30817. /**
  30818. * Encode a buffer to a base64 string
  30819. * @param buffer defines the buffer to encode
  30820. * @returns the encoded string
  30821. */
  30822. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30823. /**
  30824. * Extracts minimum and maximum values from a list of indexed positions
  30825. * @param positions defines the positions to use
  30826. * @param indices defines the indices to the positions
  30827. * @param indexStart defines the start index
  30828. * @param indexCount defines the end index
  30829. * @param bias defines bias value to add to the result
  30830. * @return minimum and maximum values
  30831. */
  30832. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30833. minimum: Vector3;
  30834. maximum: Vector3;
  30835. };
  30836. /**
  30837. * Extracts minimum and maximum values from a list of positions
  30838. * @param positions defines the positions to use
  30839. * @param start defines the start index in the positions array
  30840. * @param count defines the number of positions to handle
  30841. * @param bias defines bias value to add to the result
  30842. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30843. * @return minimum and maximum values
  30844. */
  30845. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30846. minimum: Vector3;
  30847. maximum: Vector3;
  30848. };
  30849. /**
  30850. * Returns an array if obj is not an array
  30851. * @param obj defines the object to evaluate as an array
  30852. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30853. * @returns either obj directly if obj is an array or a new array containing obj
  30854. */
  30855. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30856. /**
  30857. * Gets the pointer prefix to use
  30858. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30859. */
  30860. static GetPointerPrefix(): string;
  30861. /**
  30862. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30863. * @param func - the function to be called
  30864. * @param requester - the object that will request the next frame. Falls back to window.
  30865. * @returns frame number
  30866. */
  30867. static QueueNewFrame(func: () => void, requester?: any): number;
  30868. /**
  30869. * Ask the browser to promote the current element to fullscreen rendering mode
  30870. * @param element defines the DOM element to promote
  30871. */
  30872. static RequestFullscreen(element: HTMLElement): void;
  30873. /**
  30874. * Asks the browser to exit fullscreen mode
  30875. */
  30876. static ExitFullscreen(): void;
  30877. /**
  30878. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30879. * @param url define the url we are trying
  30880. * @param element define the dom element where to configure the cors policy
  30881. */
  30882. static SetCorsBehavior(url: string | string[], element: {
  30883. crossOrigin: string | null;
  30884. }): void;
  30885. /**
  30886. * Removes unwanted characters from an url
  30887. * @param url defines the url to clean
  30888. * @returns the cleaned url
  30889. */
  30890. static CleanUrl(url: string): string;
  30891. /**
  30892. * Gets or sets a function used to pre-process url before using them to load assets
  30893. */
  30894. static PreprocessUrl: (url: string) => string;
  30895. /**
  30896. * Loads an image as an HTMLImageElement.
  30897. * @param input url string, ArrayBuffer, or Blob to load
  30898. * @param onLoad callback called when the image successfully loads
  30899. * @param onError callback called when the image fails to load
  30900. * @param offlineProvider offline provider for caching
  30901. * @returns the HTMLImageElement of the loaded image
  30902. */
  30903. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30904. /**
  30905. * Loads a file
  30906. * @param url url string, ArrayBuffer, or Blob to load
  30907. * @param onSuccess callback called when the file successfully loads
  30908. * @param onProgress callback called while file is loading (if the server supports this mode)
  30909. * @param offlineProvider defines the offline provider for caching
  30910. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30911. * @param onError callback called when the file fails to load
  30912. * @returns a file request object
  30913. */
  30914. 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;
  30915. /**
  30916. * Load a script (identified by an url). When the url returns, the
  30917. * content of this file is added into a new script element, attached to the DOM (body element)
  30918. * @param scriptUrl defines the url of the script to laod
  30919. * @param onSuccess defines the callback called when the script is loaded
  30920. * @param onError defines the callback to call if an error occurs
  30921. */
  30922. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30923. /**
  30924. * Loads a file from a blob
  30925. * @param fileToLoad defines the blob to use
  30926. * @param callback defines the callback to call when data is loaded
  30927. * @param progressCallback defines the callback to call during loading process
  30928. * @returns a file request object
  30929. */
  30930. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30931. /**
  30932. * Loads a file
  30933. * @param fileToLoad defines the file to load
  30934. * @param callback defines the callback to call when data is loaded
  30935. * @param progressCallBack defines the callback to call during loading process
  30936. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30937. * @returns a file request object
  30938. */
  30939. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30940. /**
  30941. * Creates a data url from a given string content
  30942. * @param content defines the content to convert
  30943. * @returns the new data url link
  30944. */
  30945. static FileAsURL(content: string): string;
  30946. /**
  30947. * Format the given number to a specific decimal format
  30948. * @param value defines the number to format
  30949. * @param decimals defines the number of decimals to use
  30950. * @returns the formatted string
  30951. */
  30952. static Format(value: number, decimals?: number): string;
  30953. /**
  30954. * Checks if a given vector is inside a specific range
  30955. * @param v defines the vector to test
  30956. * @param min defines the minimum range
  30957. * @param max defines the maximum range
  30958. */
  30959. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30960. /**
  30961. * Tries to copy an object by duplicating every property
  30962. * @param source defines the source object
  30963. * @param destination defines the target object
  30964. * @param doNotCopyList defines a list of properties to avoid
  30965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30966. */
  30967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30968. /**
  30969. * Gets a boolean indicating if the given object has no own property
  30970. * @param obj defines the object to test
  30971. * @returns true if object has no own property
  30972. */
  30973. static IsEmpty(obj: any): boolean;
  30974. /**
  30975. * Function used to register events at window level
  30976. * @param events defines the events to register
  30977. */
  30978. static RegisterTopRootEvents(events: {
  30979. name: string;
  30980. handler: Nullable<(e: FocusEvent) => any>;
  30981. }[]): void;
  30982. /**
  30983. * Function used to unregister events from window level
  30984. * @param events defines the events to unregister
  30985. */
  30986. static UnregisterTopRootEvents(events: {
  30987. name: string;
  30988. handler: Nullable<(e: FocusEvent) => any>;
  30989. }[]): void;
  30990. /**
  30991. * Dumps the current bound framebuffer
  30992. * @param width defines the rendering width
  30993. * @param height defines the rendering height
  30994. * @param engine defines the hosting engine
  30995. * @param successCallback defines the callback triggered once the data are available
  30996. * @param mimeType defines the mime type of the result
  30997. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30998. */
  30999. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31000. /**
  31001. * Converts the canvas data to blob.
  31002. * This acts as a polyfill for browsers not supporting the to blob function.
  31003. * @param canvas Defines the canvas to extract the data from
  31004. * @param successCallback Defines the callback triggered once the data are available
  31005. * @param mimeType Defines the mime type of the result
  31006. */
  31007. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31008. /**
  31009. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31010. * @param successCallback defines the callback triggered once the data are available
  31011. * @param mimeType defines the mime type of the result
  31012. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31013. */
  31014. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31015. /**
  31016. * Downloads a blob in the browser
  31017. * @param blob defines the blob to download
  31018. * @param fileName defines the name of the downloaded file
  31019. */
  31020. static Download(blob: Blob, fileName: string): void;
  31021. /**
  31022. * Captures a screenshot of the current rendering
  31023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31024. * @param engine defines the rendering engine
  31025. * @param camera defines the source camera
  31026. * @param size This parameter can be set to a single number or to an object with the
  31027. * following (optional) properties: precision, width, height. If a single number is passed,
  31028. * it will be used for both width and height. If an object is passed, the screenshot size
  31029. * will be derived from the parameters. The precision property is a multiplier allowing
  31030. * rendering at a higher or lower resolution
  31031. * @param successCallback defines the callback receives a single parameter which contains the
  31032. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31033. * src parameter of an <img> to display it
  31034. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31035. * Check your browser for supported MIME types
  31036. */
  31037. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31038. /**
  31039. * Generates an image screenshot from the specified camera.
  31040. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31041. * @param engine The engine to use for rendering
  31042. * @param camera The camera to use for rendering
  31043. * @param size This parameter can be set to a single number or to an object with the
  31044. * following (optional) properties: precision, width, height. If a single number is passed,
  31045. * it will be used for both width and height. If an object is passed, the screenshot size
  31046. * will be derived from the parameters. The precision property is a multiplier allowing
  31047. * rendering at a higher or lower resolution
  31048. * @param successCallback The callback receives a single parameter which contains the
  31049. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31050. * src parameter of an <img> to display it
  31051. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31052. * Check your browser for supported MIME types
  31053. * @param samples Texture samples (default: 1)
  31054. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31055. * @param fileName A name for for the downloaded file.
  31056. */
  31057. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31058. /**
  31059. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31060. * Be aware Math.random() could cause collisions, but:
  31061. * "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"
  31062. * @returns a pseudo random id
  31063. */
  31064. static RandomId(): string;
  31065. /**
  31066. * Test if the given uri is a base64 string
  31067. * @param uri The uri to test
  31068. * @return True if the uri is a base64 string or false otherwise
  31069. */
  31070. static IsBase64(uri: string): boolean;
  31071. /**
  31072. * Decode the given base64 uri.
  31073. * @param uri The uri to decode
  31074. * @return The decoded base64 data.
  31075. */
  31076. static DecodeBase64(uri: string): ArrayBuffer;
  31077. /**
  31078. * No log
  31079. */
  31080. static readonly NoneLogLevel: number;
  31081. /**
  31082. * Only message logs
  31083. */
  31084. static readonly MessageLogLevel: number;
  31085. /**
  31086. * Only warning logs
  31087. */
  31088. static readonly WarningLogLevel: number;
  31089. /**
  31090. * Only error logs
  31091. */
  31092. static readonly ErrorLogLevel: number;
  31093. /**
  31094. * All logs
  31095. */
  31096. static readonly AllLogLevel: number;
  31097. /**
  31098. * Gets a value indicating the number of loading errors
  31099. * @ignorenaming
  31100. */
  31101. static readonly errorsCount: number;
  31102. /**
  31103. * Callback called when a new log is added
  31104. */
  31105. static OnNewCacheEntry: (entry: string) => void;
  31106. /**
  31107. * Log a message to the console
  31108. * @param message defines the message to log
  31109. */
  31110. static Log(message: string): void;
  31111. /**
  31112. * Write a warning message to the console
  31113. * @param message defines the message to log
  31114. */
  31115. static Warn(message: string): void;
  31116. /**
  31117. * Write an error message to the console
  31118. * @param message defines the message to log
  31119. */
  31120. static Error(message: string): void;
  31121. /**
  31122. * Gets current log cache (list of logs)
  31123. */
  31124. static readonly LogCache: string;
  31125. /**
  31126. * Clears the log cache
  31127. */
  31128. static ClearLogCache(): void;
  31129. /**
  31130. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31131. */
  31132. static LogLevels: number;
  31133. /**
  31134. * Checks if the loaded document was accessed via `file:`-Protocol.
  31135. * @returns boolean
  31136. */
  31137. static IsFileURL(): boolean;
  31138. /**
  31139. * Checks if the window object exists
  31140. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31141. */
  31142. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31143. /**
  31144. * No performance log
  31145. */
  31146. static readonly PerformanceNoneLogLevel: number;
  31147. /**
  31148. * Use user marks to log performance
  31149. */
  31150. static readonly PerformanceUserMarkLogLevel: number;
  31151. /**
  31152. * Log performance to the console
  31153. */
  31154. static readonly PerformanceConsoleLogLevel: number;
  31155. private static _performance;
  31156. /**
  31157. * Sets the current performance log level
  31158. */
  31159. static PerformanceLogLevel: number;
  31160. private static _StartPerformanceCounterDisabled;
  31161. private static _EndPerformanceCounterDisabled;
  31162. private static _StartUserMark;
  31163. private static _EndUserMark;
  31164. private static _StartPerformanceConsole;
  31165. private static _EndPerformanceConsole;
  31166. /**
  31167. * Injects the @see CustomRequestHeaders into the given request
  31168. * @param request the request that should be used for injection
  31169. */
  31170. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31171. /**
  31172. * Starts a performance counter
  31173. */
  31174. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31175. /**
  31176. * Ends a specific performance coutner
  31177. */
  31178. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31179. /**
  31180. * Gets either window.performance.now() if supported or Date.now() else
  31181. */
  31182. static readonly Now: number;
  31183. /**
  31184. * This method will return the name of the class used to create the instance of the given object.
  31185. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31186. * @param object the object to get the class name from
  31187. * @param isType defines if the object is actually a type
  31188. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31189. */
  31190. static GetClassName(object: any, isType?: boolean): string;
  31191. /**
  31192. * Gets the first element of an array satisfying a given predicate
  31193. * @param array defines the array to browse
  31194. * @param predicate defines the predicate to use
  31195. * @returns null if not found or the element
  31196. */
  31197. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31198. /**
  31199. * This method will return the name of the full name of the class, including its owning module (if any).
  31200. * 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).
  31201. * @param object the object to get the class name from
  31202. * @param isType defines if the object is actually a type
  31203. * @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.
  31204. * @ignorenaming
  31205. */
  31206. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31207. /**
  31208. * Returns a promise that resolves after the given amount of time.
  31209. * @param delay Number of milliseconds to delay
  31210. * @returns Promise that resolves after the given amount of time
  31211. */
  31212. static DelayAsync(delay: number): Promise<void>;
  31213. /**
  31214. * Gets the current gradient from an array of IValueGradient
  31215. * @param ratio defines the current ratio to get
  31216. * @param gradients defines the array of IValueGradient
  31217. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31218. */
  31219. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31220. }
  31221. /**
  31222. * This class is used to track a performance counter which is number based.
  31223. * The user has access to many properties which give statistics of different nature.
  31224. *
  31225. * The implementer can track two kinds of Performance Counter: time and count.
  31226. * 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.
  31227. * 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.
  31228. */
  31229. export class PerfCounter {
  31230. /**
  31231. * Gets or sets a global boolean to turn on and off all the counters
  31232. */
  31233. static Enabled: boolean;
  31234. /**
  31235. * Returns the smallest value ever
  31236. */
  31237. readonly min: number;
  31238. /**
  31239. * Returns the biggest value ever
  31240. */
  31241. readonly max: number;
  31242. /**
  31243. * Returns the average value since the performance counter is running
  31244. */
  31245. readonly average: number;
  31246. /**
  31247. * Returns the average value of the last second the counter was monitored
  31248. */
  31249. readonly lastSecAverage: number;
  31250. /**
  31251. * Returns the current value
  31252. */
  31253. readonly current: number;
  31254. /**
  31255. * Gets the accumulated total
  31256. */
  31257. readonly total: number;
  31258. /**
  31259. * Gets the total value count
  31260. */
  31261. readonly count: number;
  31262. /**
  31263. * Creates a new counter
  31264. */
  31265. constructor();
  31266. /**
  31267. * Call this method to start monitoring a new frame.
  31268. * 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.
  31269. */
  31270. fetchNewFrame(): void;
  31271. /**
  31272. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31273. * @param newCount the count value to add to the monitored count
  31274. * @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.
  31275. */
  31276. addCount(newCount: number, fetchResult: boolean): void;
  31277. /**
  31278. * Start monitoring this performance counter
  31279. */
  31280. beginMonitoring(): void;
  31281. /**
  31282. * Compute the time lapsed since the previous beginMonitoring() call.
  31283. * @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
  31284. */
  31285. endMonitoring(newFrame?: boolean): void;
  31286. private _fetchResult;
  31287. private _startMonitoringTime;
  31288. private _min;
  31289. private _max;
  31290. private _average;
  31291. private _current;
  31292. private _totalValueCount;
  31293. private _totalAccumulated;
  31294. private _lastSecAverage;
  31295. private _lastSecAccumulated;
  31296. private _lastSecTime;
  31297. private _lastSecValueCount;
  31298. }
  31299. /**
  31300. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31301. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31302. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31303. * @param name The name of the class, case should be preserved
  31304. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31305. */
  31306. export function className(name: string, module?: string): (target: Object) => void;
  31307. /**
  31308. * An implementation of a loop for asynchronous functions.
  31309. */
  31310. export class AsyncLoop {
  31311. /**
  31312. * Defines the number of iterations for the loop
  31313. */
  31314. iterations: number;
  31315. /**
  31316. * Defines the current index of the loop.
  31317. */
  31318. index: number;
  31319. private _done;
  31320. private _fn;
  31321. private _successCallback;
  31322. /**
  31323. * Constructor.
  31324. * @param iterations the number of iterations.
  31325. * @param func the function to run each iteration
  31326. * @param successCallback the callback that will be called upon succesful execution
  31327. * @param offset starting offset.
  31328. */
  31329. constructor(
  31330. /**
  31331. * Defines the number of iterations for the loop
  31332. */
  31333. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31334. /**
  31335. * Execute the next iteration. Must be called after the last iteration was finished.
  31336. */
  31337. executeNext(): void;
  31338. /**
  31339. * Break the loop and run the success callback.
  31340. */
  31341. breakLoop(): void;
  31342. /**
  31343. * Create and run an async loop.
  31344. * @param iterations the number of iterations.
  31345. * @param fn the function to run each iteration
  31346. * @param successCallback the callback that will be called upon succesful execution
  31347. * @param offset starting offset.
  31348. * @returns the created async loop object
  31349. */
  31350. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31351. /**
  31352. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31353. * @param iterations total number of iterations
  31354. * @param syncedIterations number of synchronous iterations in each async iteration.
  31355. * @param fn the function to call each iteration.
  31356. * @param callback a success call back that will be called when iterating stops.
  31357. * @param breakFunction a break condition (optional)
  31358. * @param timeout timeout settings for the setTimeout function. default - 0.
  31359. * @returns the created async loop object
  31360. */
  31361. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31362. }
  31363. }
  31364. declare module "babylonjs/Collisions/collisionCoordinator" {
  31365. import { Nullable } from "babylonjs/types";
  31366. import { Scene } from "babylonjs/scene";
  31367. import { Vector3 } from "babylonjs/Maths/math";
  31368. import { Collider } from "babylonjs/Collisions/collider";
  31369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31370. /** @hidden */
  31371. export interface ICollisionCoordinator {
  31372. createCollider(): Collider;
  31373. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31374. init(scene: Scene): void;
  31375. }
  31376. /** @hidden */
  31377. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31378. private _scene;
  31379. private _scaledPosition;
  31380. private _scaledVelocity;
  31381. private _finalPosition;
  31382. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31383. createCollider(): Collider;
  31384. init(scene: Scene): void;
  31385. private _collideWithWorld;
  31386. }
  31387. }
  31388. declare module "babylonjs/Animations/animationGroup" {
  31389. import { Animatable } from "babylonjs/Animations/animatable";
  31390. import { Animation } from "babylonjs/Animations/animation";
  31391. import { Scene, IDisposable } from "babylonjs/scene";
  31392. import { Observable } from "babylonjs/Misc/observable";
  31393. import { Nullable } from "babylonjs/types";
  31394. /**
  31395. * This class defines the direct association between an animation and a target
  31396. */
  31397. export class TargetedAnimation {
  31398. /**
  31399. * Animation to perform
  31400. */
  31401. animation: Animation;
  31402. /**
  31403. * Target to animate
  31404. */
  31405. target: any;
  31406. }
  31407. /**
  31408. * Use this class to create coordinated animations on multiple targets
  31409. */
  31410. export class AnimationGroup implements IDisposable {
  31411. /** The name of the animation group */
  31412. name: string;
  31413. private _scene;
  31414. private _targetedAnimations;
  31415. private _animatables;
  31416. private _from;
  31417. private _to;
  31418. private _isStarted;
  31419. private _isPaused;
  31420. private _speedRatio;
  31421. /**
  31422. * Gets or sets the unique id of the node
  31423. */
  31424. uniqueId: number;
  31425. /**
  31426. * This observable will notify when one animation have ended
  31427. */
  31428. onAnimationEndObservable: Observable<TargetedAnimation>;
  31429. /**
  31430. * Observer raised when one animation loops
  31431. */
  31432. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31433. /**
  31434. * This observable will notify when all animations have ended.
  31435. */
  31436. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31437. /**
  31438. * This observable will notify when all animations have paused.
  31439. */
  31440. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31441. /**
  31442. * This observable will notify when all animations are playing.
  31443. */
  31444. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31445. /**
  31446. * Gets the first frame
  31447. */
  31448. readonly from: number;
  31449. /**
  31450. * Gets the last frame
  31451. */
  31452. readonly to: number;
  31453. /**
  31454. * Define if the animations are started
  31455. */
  31456. readonly isStarted: boolean;
  31457. /**
  31458. * Gets a value indicating that the current group is playing
  31459. */
  31460. readonly isPlaying: boolean;
  31461. /**
  31462. * Gets or sets the speed ratio to use for all animations
  31463. */
  31464. /**
  31465. * Gets or sets the speed ratio to use for all animations
  31466. */
  31467. speedRatio: number;
  31468. /**
  31469. * Gets the targeted animations for this animation group
  31470. */
  31471. readonly targetedAnimations: Array<TargetedAnimation>;
  31472. /**
  31473. * returning the list of animatables controlled by this animation group.
  31474. */
  31475. readonly animatables: Array<Animatable>;
  31476. /**
  31477. * Instantiates a new Animation Group.
  31478. * This helps managing several animations at once.
  31479. * @see http://doc.babylonjs.com/how_to/group
  31480. * @param name Defines the name of the group
  31481. * @param scene Defines the scene the group belongs to
  31482. */
  31483. constructor(
  31484. /** The name of the animation group */
  31485. name: string, scene?: Nullable<Scene>);
  31486. /**
  31487. * Add an animation (with its target) in the group
  31488. * @param animation defines the animation we want to add
  31489. * @param target defines the target of the animation
  31490. * @returns the TargetedAnimation object
  31491. */
  31492. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31493. /**
  31494. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31495. * It can add constant keys at begin or end
  31496. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31497. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31498. * @returns the animation group
  31499. */
  31500. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31501. /**
  31502. * Start all animations on given targets
  31503. * @param loop defines if animations must loop
  31504. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31505. * @param from defines the from key (optional)
  31506. * @param to defines the to key (optional)
  31507. * @returns the current animation group
  31508. */
  31509. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31510. /**
  31511. * Pause all animations
  31512. * @returns the animation group
  31513. */
  31514. pause(): AnimationGroup;
  31515. /**
  31516. * Play all animations to initial state
  31517. * This function will start() the animations if they were not started or will restart() them if they were paused
  31518. * @param loop defines if animations must loop
  31519. * @returns the animation group
  31520. */
  31521. play(loop?: boolean): AnimationGroup;
  31522. /**
  31523. * Reset all animations to initial state
  31524. * @returns the animation group
  31525. */
  31526. reset(): AnimationGroup;
  31527. /**
  31528. * Restart animations from key 0
  31529. * @returns the animation group
  31530. */
  31531. restart(): AnimationGroup;
  31532. /**
  31533. * Stop all animations
  31534. * @returns the animation group
  31535. */
  31536. stop(): AnimationGroup;
  31537. /**
  31538. * Set animation weight for all animatables
  31539. * @param weight defines the weight to use
  31540. * @return the animationGroup
  31541. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31542. */
  31543. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31544. /**
  31545. * Synchronize and normalize all animatables with a source animatable
  31546. * @param root defines the root animatable to synchronize with
  31547. * @return the animationGroup
  31548. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31549. */
  31550. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31551. /**
  31552. * Goes to a specific frame in this animation group
  31553. * @param frame the frame number to go to
  31554. * @return the animationGroup
  31555. */
  31556. goToFrame(frame: number): AnimationGroup;
  31557. /**
  31558. * Dispose all associated resources
  31559. */
  31560. dispose(): void;
  31561. private _checkAnimationGroupEnded;
  31562. /**
  31563. * Clone the current animation group and returns a copy
  31564. * @param newName defines the name of the new group
  31565. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31566. * @returns the new aniamtion group
  31567. */
  31568. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31569. /**
  31570. * Returns a new AnimationGroup object parsed from the source provided.
  31571. * @param parsedAnimationGroup defines the source
  31572. * @param scene defines the scene that will receive the animationGroup
  31573. * @returns a new AnimationGroup
  31574. */
  31575. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31576. /**
  31577. * Returns the string "AnimationGroup"
  31578. * @returns "AnimationGroup"
  31579. */
  31580. getClassName(): string;
  31581. /**
  31582. * Creates a detailled string about the object
  31583. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31584. * @returns a string representing the object
  31585. */
  31586. toString(fullDetails?: boolean): string;
  31587. }
  31588. }
  31589. declare module "babylonjs/scene" {
  31590. import { Nullable } from "babylonjs/types";
  31591. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31592. import { Observable } from "babylonjs/Misc/observable";
  31593. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31594. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31595. import { Geometry } from "babylonjs/Meshes/geometry";
  31596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31597. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31599. import { Mesh } from "babylonjs/Meshes/mesh";
  31600. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31601. import { Bone } from "babylonjs/Bones/bone";
  31602. import { Skeleton } from "babylonjs/Bones/skeleton";
  31603. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31604. import { Camera } from "babylonjs/Cameras/camera";
  31605. import { AbstractScene } from "babylonjs/abstractScene";
  31606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31608. import { Material } from "babylonjs/Materials/material";
  31609. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31610. import { Effect } from "babylonjs/Materials/effect";
  31611. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31612. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31613. import { Light } from "babylonjs/Lights/light";
  31614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31615. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31616. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31617. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31618. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31619. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31620. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31621. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31622. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31623. import { Engine } from "babylonjs/Engines/engine";
  31624. import { Node } from "babylonjs/node";
  31625. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31626. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31627. import { Ray } from "babylonjs/Culling/ray";
  31628. import { Animation } from "babylonjs/Animations/animation";
  31629. import { Animatable } from "babylonjs/Animations/animatable";
  31630. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31631. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31632. import { Collider } from "babylonjs/Collisions/collider";
  31633. /**
  31634. * Define an interface for all classes that will hold resources
  31635. */
  31636. export interface IDisposable {
  31637. /**
  31638. * Releases all held resources
  31639. */
  31640. dispose(): void;
  31641. }
  31642. /** Interface defining initialization parameters for Scene class */
  31643. export interface SceneOptions {
  31644. /**
  31645. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31646. * It will improve performance when the number of geometries becomes important.
  31647. */
  31648. useGeometryUniqueIdsMap?: boolean;
  31649. /**
  31650. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31651. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31652. */
  31653. useMaterialMeshMap?: boolean;
  31654. /**
  31655. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31656. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31657. */
  31658. useClonedMeshhMap?: boolean;
  31659. }
  31660. /**
  31661. * Represents a scene to be rendered by the engine.
  31662. * @see http://doc.babylonjs.com/features/scene
  31663. */
  31664. export class Scene extends AbstractScene implements IAnimatable {
  31665. private static _uniqueIdCounter;
  31666. /** The fog is deactivated */
  31667. static readonly FOGMODE_NONE: number;
  31668. /** The fog density is following an exponential function */
  31669. static readonly FOGMODE_EXP: number;
  31670. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31671. static readonly FOGMODE_EXP2: number;
  31672. /** The fog density is following a linear function. */
  31673. static readonly FOGMODE_LINEAR: number;
  31674. /**
  31675. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31677. */
  31678. static MinDeltaTime: number;
  31679. /**
  31680. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31681. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31682. */
  31683. static MaxDeltaTime: number;
  31684. /**
  31685. * Factory used to create the default material.
  31686. * @param name The name of the material to create
  31687. * @param scene The scene to create the material for
  31688. * @returns The default material
  31689. */
  31690. static DefaultMaterialFactory(scene: Scene): Material;
  31691. /**
  31692. * Factory used to create the a collision coordinator.
  31693. * @returns The collision coordinator
  31694. */
  31695. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31696. /** @hidden */
  31697. readonly _isScene: boolean;
  31698. /**
  31699. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31700. */
  31701. autoClear: boolean;
  31702. /**
  31703. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31704. */
  31705. autoClearDepthAndStencil: boolean;
  31706. /**
  31707. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31708. */
  31709. clearColor: Color4;
  31710. /**
  31711. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31712. */
  31713. ambientColor: Color3;
  31714. /** @hidden */
  31715. _environmentBRDFTexture: BaseTexture;
  31716. /** @hidden */
  31717. protected _environmentTexture: Nullable<BaseTexture>;
  31718. /**
  31719. * Texture used in all pbr material as the reflection texture.
  31720. * As in the majority of the scene they are the same (exception for multi room and so on),
  31721. * this is easier to reference from here than from all the materials.
  31722. */
  31723. /**
  31724. * Texture used in all pbr material as the reflection texture.
  31725. * As in the majority of the scene they are the same (exception for multi room and so on),
  31726. * this is easier to set here than in all the materials.
  31727. */
  31728. environmentTexture: Nullable<BaseTexture>;
  31729. /** @hidden */
  31730. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31731. /**
  31732. * Default image processing configuration used either in the rendering
  31733. * Forward main pass or through the imageProcessingPostProcess if present.
  31734. * As in the majority of the scene they are the same (exception for multi camera),
  31735. * this is easier to reference from here than from all the materials and post process.
  31736. *
  31737. * No setter as we it is a shared configuration, you can set the values instead.
  31738. */
  31739. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31740. private _forceWireframe;
  31741. /**
  31742. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31743. */
  31744. forceWireframe: boolean;
  31745. private _forcePointsCloud;
  31746. /**
  31747. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31748. */
  31749. forcePointsCloud: boolean;
  31750. /**
  31751. * Gets or sets the active clipplane 1
  31752. */
  31753. clipPlane: Nullable<Plane>;
  31754. /**
  31755. * Gets or sets the active clipplane 2
  31756. */
  31757. clipPlane2: Nullable<Plane>;
  31758. /**
  31759. * Gets or sets the active clipplane 3
  31760. */
  31761. clipPlane3: Nullable<Plane>;
  31762. /**
  31763. * Gets or sets the active clipplane 4
  31764. */
  31765. clipPlane4: Nullable<Plane>;
  31766. /**
  31767. * Gets or sets a boolean indicating if animations are enabled
  31768. */
  31769. animationsEnabled: boolean;
  31770. private _animationPropertiesOverride;
  31771. /**
  31772. * Gets or sets the animation properties override
  31773. */
  31774. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31775. /**
  31776. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31777. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31778. */
  31779. useConstantAnimationDeltaTime: boolean;
  31780. /**
  31781. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31782. * Please note that it requires to run a ray cast through the scene on every frame
  31783. */
  31784. constantlyUpdateMeshUnderPointer: boolean;
  31785. /**
  31786. * Defines the HTML cursor to use when hovering over interactive elements
  31787. */
  31788. hoverCursor: string;
  31789. /**
  31790. * Defines the HTML default cursor to use (empty by default)
  31791. */
  31792. defaultCursor: string;
  31793. /**
  31794. * This is used to call preventDefault() on pointer down
  31795. * in order to block unwanted artifacts like system double clicks
  31796. */
  31797. preventDefaultOnPointerDown: boolean;
  31798. /**
  31799. * This is used to call preventDefault() on pointer up
  31800. * in order to block unwanted artifacts like system double clicks
  31801. */
  31802. preventDefaultOnPointerUp: boolean;
  31803. /**
  31804. * Gets or sets user defined metadata
  31805. */
  31806. metadata: any;
  31807. /**
  31808. * For internal use only. Please do not use.
  31809. */
  31810. reservedDataStore: any;
  31811. /**
  31812. * Gets the name of the plugin used to load this scene (null by default)
  31813. */
  31814. loadingPluginName: string;
  31815. /**
  31816. * Use this array to add regular expressions used to disable offline support for specific urls
  31817. */
  31818. disableOfflineSupportExceptionRules: RegExp[];
  31819. /**
  31820. * An event triggered when the scene is disposed.
  31821. */
  31822. onDisposeObservable: Observable<Scene>;
  31823. private _onDisposeObserver;
  31824. /** Sets a function to be executed when this scene is disposed. */
  31825. onDispose: () => void;
  31826. /**
  31827. * An event triggered before rendering the scene (right after animations and physics)
  31828. */
  31829. onBeforeRenderObservable: Observable<Scene>;
  31830. private _onBeforeRenderObserver;
  31831. /** Sets a function to be executed before rendering this scene */
  31832. beforeRender: Nullable<() => void>;
  31833. /**
  31834. * An event triggered after rendering the scene
  31835. */
  31836. onAfterRenderObservable: Observable<Scene>;
  31837. private _onAfterRenderObserver;
  31838. /** Sets a function to be executed after rendering this scene */
  31839. afterRender: Nullable<() => void>;
  31840. /**
  31841. * An event triggered before animating the scene
  31842. */
  31843. onBeforeAnimationsObservable: Observable<Scene>;
  31844. /**
  31845. * An event triggered after animations processing
  31846. */
  31847. onAfterAnimationsObservable: Observable<Scene>;
  31848. /**
  31849. * An event triggered before draw calls are ready to be sent
  31850. */
  31851. onBeforeDrawPhaseObservable: Observable<Scene>;
  31852. /**
  31853. * An event triggered after draw calls have been sent
  31854. */
  31855. onAfterDrawPhaseObservable: Observable<Scene>;
  31856. /**
  31857. * An event triggered when the scene is ready
  31858. */
  31859. onReadyObservable: Observable<Scene>;
  31860. /**
  31861. * An event triggered before rendering a camera
  31862. */
  31863. onBeforeCameraRenderObservable: Observable<Camera>;
  31864. private _onBeforeCameraRenderObserver;
  31865. /** Sets a function to be executed before rendering a camera*/
  31866. beforeCameraRender: () => void;
  31867. /**
  31868. * An event triggered after rendering a camera
  31869. */
  31870. onAfterCameraRenderObservable: Observable<Camera>;
  31871. private _onAfterCameraRenderObserver;
  31872. /** Sets a function to be executed after rendering a camera*/
  31873. afterCameraRender: () => void;
  31874. /**
  31875. * An event triggered when active meshes evaluation is about to start
  31876. */
  31877. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31878. /**
  31879. * An event triggered when active meshes evaluation is done
  31880. */
  31881. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31882. /**
  31883. * An event triggered when particles rendering is about to start
  31884. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31885. */
  31886. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31887. /**
  31888. * An event triggered when particles rendering is done
  31889. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31890. */
  31891. onAfterParticlesRenderingObservable: Observable<Scene>;
  31892. /**
  31893. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31894. */
  31895. onDataLoadedObservable: Observable<Scene>;
  31896. /**
  31897. * An event triggered when a camera is created
  31898. */
  31899. onNewCameraAddedObservable: Observable<Camera>;
  31900. /**
  31901. * An event triggered when a camera is removed
  31902. */
  31903. onCameraRemovedObservable: Observable<Camera>;
  31904. /**
  31905. * An event triggered when a light is created
  31906. */
  31907. onNewLightAddedObservable: Observable<Light>;
  31908. /**
  31909. * An event triggered when a light is removed
  31910. */
  31911. onLightRemovedObservable: Observable<Light>;
  31912. /**
  31913. * An event triggered when a geometry is created
  31914. */
  31915. onNewGeometryAddedObservable: Observable<Geometry>;
  31916. /**
  31917. * An event triggered when a geometry is removed
  31918. */
  31919. onGeometryRemovedObservable: Observable<Geometry>;
  31920. /**
  31921. * An event triggered when a transform node is created
  31922. */
  31923. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31924. /**
  31925. * An event triggered when a transform node is removed
  31926. */
  31927. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31928. /**
  31929. * An event triggered when a mesh is created
  31930. */
  31931. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31932. /**
  31933. * An event triggered when a mesh is removed
  31934. */
  31935. onMeshRemovedObservable: Observable<AbstractMesh>;
  31936. /**
  31937. * An event triggered when a material is created
  31938. */
  31939. onNewMaterialAddedObservable: Observable<Material>;
  31940. /**
  31941. * An event triggered when a material is removed
  31942. */
  31943. onMaterialRemovedObservable: Observable<Material>;
  31944. /**
  31945. * An event triggered when a texture is created
  31946. */
  31947. onNewTextureAddedObservable: Observable<BaseTexture>;
  31948. /**
  31949. * An event triggered when a texture is removed
  31950. */
  31951. onTextureRemovedObservable: Observable<BaseTexture>;
  31952. /**
  31953. * An event triggered when render targets are about to be rendered
  31954. * Can happen multiple times per frame.
  31955. */
  31956. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31957. /**
  31958. * An event triggered when render targets were rendered.
  31959. * Can happen multiple times per frame.
  31960. */
  31961. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31962. /**
  31963. * An event triggered before calculating deterministic simulation step
  31964. */
  31965. onBeforeStepObservable: Observable<Scene>;
  31966. /**
  31967. * An event triggered after calculating deterministic simulation step
  31968. */
  31969. onAfterStepObservable: Observable<Scene>;
  31970. /**
  31971. * An event triggered when the activeCamera property is updated
  31972. */
  31973. onActiveCameraChanged: Observable<Scene>;
  31974. /**
  31975. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31976. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31977. * 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)
  31978. */
  31979. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31980. /**
  31981. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31982. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31983. * 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)
  31984. */
  31985. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31986. /**
  31987. * This Observable will when a mesh has been imported into the scene.
  31988. */
  31989. onMeshImportedObservable: Observable<AbstractMesh>;
  31990. /** @hidden */
  31991. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31992. /**
  31993. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31994. */
  31995. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31996. /**
  31997. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31998. */
  31999. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32000. /**
  32001. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32002. */
  32003. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32004. private _onPointerMove;
  32005. private _onPointerDown;
  32006. private _onPointerUp;
  32007. /** Callback called when a pointer move is detected */
  32008. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32009. /** Callback called when a pointer down is detected */
  32010. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32011. /** Callback called when a pointer up is detected */
  32012. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32013. /** Callback called when a pointer pick is detected */
  32014. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32015. /**
  32016. * 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).
  32017. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32018. */
  32019. onPrePointerObservable: Observable<PointerInfoPre>;
  32020. /**
  32021. * Observable event triggered each time an input event is received from the rendering canvas
  32022. */
  32023. onPointerObservable: Observable<PointerInfo>;
  32024. /**
  32025. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32026. */
  32027. readonly unTranslatedPointer: Vector2;
  32028. /** The distance in pixel that you have to move to prevent some events */
  32029. static DragMovementThreshold: number;
  32030. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32031. static LongPressDelay: number;
  32032. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32033. static DoubleClickDelay: number;
  32034. /** If you need to check double click without raising a single click at first click, enable this flag */
  32035. static ExclusiveDoubleClickMode: boolean;
  32036. private _initClickEvent;
  32037. private _initActionManager;
  32038. private _delayedSimpleClick;
  32039. private _delayedSimpleClickTimeout;
  32040. private _previousDelayedSimpleClickTimeout;
  32041. private _meshPickProceed;
  32042. private _previousButtonPressed;
  32043. private _currentPickResult;
  32044. private _previousPickResult;
  32045. private _totalPointersPressed;
  32046. private _doubleClickOccured;
  32047. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32048. cameraToUseForPointers: Nullable<Camera>;
  32049. private _pointerX;
  32050. private _pointerY;
  32051. private _unTranslatedPointerX;
  32052. private _unTranslatedPointerY;
  32053. private _startingPointerPosition;
  32054. private _previousStartingPointerPosition;
  32055. private _startingPointerTime;
  32056. private _previousStartingPointerTime;
  32057. private _pointerCaptures;
  32058. private _timeAccumulator;
  32059. private _currentStepId;
  32060. private _currentInternalStep;
  32061. /** @hidden */
  32062. _mirroredCameraPosition: Nullable<Vector3>;
  32063. /**
  32064. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32065. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32066. */
  32067. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32068. /**
  32069. * Observable event triggered each time an keyboard event is received from the hosting window
  32070. */
  32071. onKeyboardObservable: Observable<KeyboardInfo>;
  32072. private _onKeyDown;
  32073. private _onKeyUp;
  32074. private _onCanvasFocusObserver;
  32075. private _onCanvasBlurObserver;
  32076. private _useRightHandedSystem;
  32077. /**
  32078. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32079. */
  32080. useRightHandedSystem: boolean;
  32081. /**
  32082. * Sets the step Id used by deterministic lock step
  32083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32084. * @param newStepId defines the step Id
  32085. */
  32086. setStepId(newStepId: number): void;
  32087. /**
  32088. * Gets the step Id used by deterministic lock step
  32089. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32090. * @returns the step Id
  32091. */
  32092. getStepId(): number;
  32093. /**
  32094. * Gets the internal step used by deterministic lock step
  32095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32096. * @returns the internal step
  32097. */
  32098. getInternalStep(): number;
  32099. private _fogEnabled;
  32100. /**
  32101. * Gets or sets a boolean indicating if fog is enabled on this scene
  32102. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32103. * (Default is true)
  32104. */
  32105. fogEnabled: boolean;
  32106. private _fogMode;
  32107. /**
  32108. * Gets or sets the fog mode to use
  32109. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32110. * | mode | value |
  32111. * | --- | --- |
  32112. * | FOGMODE_NONE | 0 |
  32113. * | FOGMODE_EXP | 1 |
  32114. * | FOGMODE_EXP2 | 2 |
  32115. * | FOGMODE_LINEAR | 3 |
  32116. */
  32117. fogMode: number;
  32118. /**
  32119. * Gets or sets the fog color to use
  32120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32121. * (Default is Color3(0.2, 0.2, 0.3))
  32122. */
  32123. fogColor: Color3;
  32124. /**
  32125. * Gets or sets the fog density to use
  32126. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32127. * (Default is 0.1)
  32128. */
  32129. fogDensity: number;
  32130. /**
  32131. * Gets or sets the fog start distance to use
  32132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32133. * (Default is 0)
  32134. */
  32135. fogStart: number;
  32136. /**
  32137. * Gets or sets the fog end distance to use
  32138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32139. * (Default is 1000)
  32140. */
  32141. fogEnd: number;
  32142. private _shadowsEnabled;
  32143. /**
  32144. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32145. */
  32146. shadowsEnabled: boolean;
  32147. private _lightsEnabled;
  32148. /**
  32149. * Gets or sets a boolean indicating if lights are enabled on this scene
  32150. */
  32151. lightsEnabled: boolean;
  32152. /** All of the active cameras added to this scene. */
  32153. activeCameras: Camera[];
  32154. private _activeCamera;
  32155. /** Gets or sets the current active camera */
  32156. activeCamera: Nullable<Camera>;
  32157. private _defaultMaterial;
  32158. /** The default material used on meshes when no material is affected */
  32159. /** The default material used on meshes when no material is affected */
  32160. defaultMaterial: Material;
  32161. private _texturesEnabled;
  32162. /**
  32163. * Gets or sets a boolean indicating if textures are enabled on this scene
  32164. */
  32165. texturesEnabled: boolean;
  32166. /**
  32167. * Gets or sets a boolean indicating if particles are enabled on this scene
  32168. */
  32169. particlesEnabled: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32172. */
  32173. spritesEnabled: boolean;
  32174. private _skeletonsEnabled;
  32175. /**
  32176. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32177. */
  32178. skeletonsEnabled: boolean;
  32179. /**
  32180. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32181. */
  32182. lensFlaresEnabled: boolean;
  32183. /**
  32184. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32186. */
  32187. collisionsEnabled: boolean;
  32188. private _collisionCoordinator;
  32189. /** @hidden */
  32190. readonly collisionCoordinator: ICollisionCoordinator;
  32191. /**
  32192. * Defines the gravity applied to this scene (used only for collisions)
  32193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32194. */
  32195. gravity: Vector3;
  32196. /**
  32197. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32198. */
  32199. postProcessesEnabled: boolean;
  32200. /**
  32201. * The list of postprocesses added to the scene
  32202. */
  32203. postProcesses: PostProcess[];
  32204. /**
  32205. * Gets the current postprocess manager
  32206. */
  32207. postProcessManager: PostProcessManager;
  32208. /**
  32209. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32210. */
  32211. renderTargetsEnabled: boolean;
  32212. /**
  32213. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32214. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32215. */
  32216. dumpNextRenderTargets: boolean;
  32217. /**
  32218. * The list of user defined render targets added to the scene
  32219. */
  32220. customRenderTargets: RenderTargetTexture[];
  32221. /**
  32222. * Defines if texture loading must be delayed
  32223. * If true, textures will only be loaded when they need to be rendered
  32224. */
  32225. useDelayedTextureLoading: boolean;
  32226. /**
  32227. * Gets the list of meshes imported to the scene through SceneLoader
  32228. */
  32229. importedMeshesFiles: String[];
  32230. /**
  32231. * Gets or sets a boolean indicating if probes are enabled on this scene
  32232. */
  32233. probesEnabled: boolean;
  32234. /**
  32235. * Gets or sets the current offline provider to use to store scene data
  32236. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32237. */
  32238. offlineProvider: IOfflineProvider;
  32239. /**
  32240. * Gets or sets the action manager associated with the scene
  32241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32242. */
  32243. actionManager: AbstractActionManager;
  32244. private _meshesForIntersections;
  32245. /**
  32246. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32247. */
  32248. proceduralTexturesEnabled: boolean;
  32249. private _engine;
  32250. private _totalVertices;
  32251. /** @hidden */
  32252. _activeIndices: PerfCounter;
  32253. /** @hidden */
  32254. _activeParticles: PerfCounter;
  32255. /** @hidden */
  32256. _activeBones: PerfCounter;
  32257. private _animationRatio;
  32258. /** @hidden */
  32259. _animationTimeLast: number;
  32260. /** @hidden */
  32261. _animationTime: number;
  32262. /**
  32263. * Gets or sets a general scale for animation speed
  32264. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32265. */
  32266. animationTimeScale: number;
  32267. /** @hidden */
  32268. _cachedMaterial: Nullable<Material>;
  32269. /** @hidden */
  32270. _cachedEffect: Nullable<Effect>;
  32271. /** @hidden */
  32272. _cachedVisibility: Nullable<number>;
  32273. private _renderId;
  32274. private _frameId;
  32275. private _executeWhenReadyTimeoutId;
  32276. private _intermediateRendering;
  32277. private _viewUpdateFlag;
  32278. private _projectionUpdateFlag;
  32279. private _alternateViewUpdateFlag;
  32280. private _alternateProjectionUpdateFlag;
  32281. /** @hidden */
  32282. _toBeDisposed: Nullable<IDisposable>[];
  32283. private _activeRequests;
  32284. /** @hidden */
  32285. _pendingData: any[];
  32286. private _isDisposed;
  32287. /**
  32288. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32289. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32290. */
  32291. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32292. private _activeMeshes;
  32293. private _processedMaterials;
  32294. private _renderTargets;
  32295. /** @hidden */
  32296. _activeParticleSystems: SmartArray<IParticleSystem>;
  32297. private _activeSkeletons;
  32298. private _softwareSkinnedMeshes;
  32299. private _renderingManager;
  32300. /** @hidden */
  32301. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32302. private _transformMatrix;
  32303. private _sceneUbo;
  32304. private _alternateSceneUbo;
  32305. private _viewMatrix;
  32306. private _projectionMatrix;
  32307. private _alternateViewMatrix;
  32308. private _alternateProjectionMatrix;
  32309. private _alternateTransformMatrix;
  32310. private _useAlternateCameraConfiguration;
  32311. private _alternateRendering;
  32312. private _wheelEventName;
  32313. /** @hidden */
  32314. _forcedViewPosition: Nullable<Vector3>;
  32315. /** @hidden */
  32316. readonly _isAlternateRenderingEnabled: boolean;
  32317. private _frustumPlanes;
  32318. /**
  32319. * Gets the list of frustum planes (built from the active camera)
  32320. */
  32321. readonly frustumPlanes: Plane[];
  32322. /**
  32323. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32324. * This is useful if there are more lights that the maximum simulteanous authorized
  32325. */
  32326. requireLightSorting: boolean;
  32327. /** @hidden */
  32328. readonly useMaterialMeshMap: boolean;
  32329. /** @hidden */
  32330. readonly useClonedMeshhMap: boolean;
  32331. private _pointerOverMesh;
  32332. private _pickedDownMesh;
  32333. private _pickedUpMesh;
  32334. private _externalData;
  32335. private _uid;
  32336. /**
  32337. * @hidden
  32338. * Backing store of defined scene components.
  32339. */
  32340. _components: ISceneComponent[];
  32341. /**
  32342. * @hidden
  32343. * Backing store of defined scene components.
  32344. */
  32345. _serializableComponents: ISceneSerializableComponent[];
  32346. /**
  32347. * List of components to register on the next registration step.
  32348. */
  32349. private _transientComponents;
  32350. /**
  32351. * Registers the transient components if needed.
  32352. */
  32353. private _registerTransientComponents;
  32354. /**
  32355. * @hidden
  32356. * Add a component to the scene.
  32357. * Note that the ccomponent could be registered on th next frame if this is called after
  32358. * the register component stage.
  32359. * @param component Defines the component to add to the scene
  32360. */
  32361. _addComponent(component: ISceneComponent): void;
  32362. /**
  32363. * @hidden
  32364. * Gets a component from the scene.
  32365. * @param name defines the name of the component to retrieve
  32366. * @returns the component or null if not present
  32367. */
  32368. _getComponent(name: string): Nullable<ISceneComponent>;
  32369. /**
  32370. * @hidden
  32371. * Defines the actions happening before camera updates.
  32372. */
  32373. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32374. /**
  32375. * @hidden
  32376. * Defines the actions happening before clear the canvas.
  32377. */
  32378. _beforeClearStage: Stage<SimpleStageAction>;
  32379. /**
  32380. * @hidden
  32381. * Defines the actions when collecting render targets for the frame.
  32382. */
  32383. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32384. /**
  32385. * @hidden
  32386. * Defines the actions happening for one camera in the frame.
  32387. */
  32388. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32389. /**
  32390. * @hidden
  32391. * Defines the actions happening during the per mesh ready checks.
  32392. */
  32393. _isReadyForMeshStage: Stage<MeshStageAction>;
  32394. /**
  32395. * @hidden
  32396. * Defines the actions happening before evaluate active mesh checks.
  32397. */
  32398. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32399. /**
  32400. * @hidden
  32401. * Defines the actions happening during the evaluate sub mesh checks.
  32402. */
  32403. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32404. /**
  32405. * @hidden
  32406. * Defines the actions happening during the active mesh stage.
  32407. */
  32408. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32409. /**
  32410. * @hidden
  32411. * Defines the actions happening during the per camera render target step.
  32412. */
  32413. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32414. /**
  32415. * @hidden
  32416. * Defines the actions happening just before the active camera is drawing.
  32417. */
  32418. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32419. /**
  32420. * @hidden
  32421. * Defines the actions happening just before a render target is drawing.
  32422. */
  32423. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32424. /**
  32425. * @hidden
  32426. * Defines the actions happening just before a rendering group is drawing.
  32427. */
  32428. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32429. /**
  32430. * @hidden
  32431. * Defines the actions happening just before a mesh is drawing.
  32432. */
  32433. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32434. /**
  32435. * @hidden
  32436. * Defines the actions happening just after a mesh has been drawn.
  32437. */
  32438. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32439. /**
  32440. * @hidden
  32441. * Defines the actions happening just after a rendering group has been drawn.
  32442. */
  32443. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32444. /**
  32445. * @hidden
  32446. * Defines the actions happening just after the active camera has been drawn.
  32447. */
  32448. _afterCameraDrawStage: Stage<CameraStageAction>;
  32449. /**
  32450. * @hidden
  32451. * Defines the actions happening just after a render target has been drawn.
  32452. */
  32453. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32454. /**
  32455. * @hidden
  32456. * Defines the actions happening just after rendering all cameras and computing intersections.
  32457. */
  32458. _afterRenderStage: Stage<SimpleStageAction>;
  32459. /**
  32460. * @hidden
  32461. * Defines the actions happening when a pointer move event happens.
  32462. */
  32463. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32464. /**
  32465. * @hidden
  32466. * Defines the actions happening when a pointer down event happens.
  32467. */
  32468. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32469. /**
  32470. * @hidden
  32471. * Defines the actions happening when a pointer up event happens.
  32472. */
  32473. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32474. /**
  32475. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32476. */
  32477. private geometriesByUniqueId;
  32478. /**
  32479. * Creates a new Scene
  32480. * @param engine defines the engine to use to render this scene
  32481. * @param options defines the scene options
  32482. */
  32483. constructor(engine: Engine, options?: SceneOptions);
  32484. private _defaultMeshCandidates;
  32485. /**
  32486. * @hidden
  32487. */
  32488. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32489. private _defaultSubMeshCandidates;
  32490. /**
  32491. * @hidden
  32492. */
  32493. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32494. /**
  32495. * Sets the default candidate providers for the scene.
  32496. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32497. * and getCollidingSubMeshCandidates to their default function
  32498. */
  32499. setDefaultCandidateProviders(): void;
  32500. /**
  32501. * Gets the mesh that is currently under the pointer
  32502. */
  32503. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32504. /**
  32505. * Gets or sets the current on-screen X position of the pointer
  32506. */
  32507. pointerX: number;
  32508. /**
  32509. * Gets or sets the current on-screen Y position of the pointer
  32510. */
  32511. pointerY: number;
  32512. /**
  32513. * Gets the cached material (ie. the latest rendered one)
  32514. * @returns the cached material
  32515. */
  32516. getCachedMaterial(): Nullable<Material>;
  32517. /**
  32518. * Gets the cached effect (ie. the latest rendered one)
  32519. * @returns the cached effect
  32520. */
  32521. getCachedEffect(): Nullable<Effect>;
  32522. /**
  32523. * Gets the cached visibility state (ie. the latest rendered one)
  32524. * @returns the cached visibility state
  32525. */
  32526. getCachedVisibility(): Nullable<number>;
  32527. /**
  32528. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32529. * @param material defines the current material
  32530. * @param effect defines the current effect
  32531. * @param visibility defines the current visibility state
  32532. * @returns true if one parameter is not cached
  32533. */
  32534. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32535. /**
  32536. * Gets the engine associated with the scene
  32537. * @returns an Engine
  32538. */
  32539. getEngine(): Engine;
  32540. /**
  32541. * Gets the total number of vertices rendered per frame
  32542. * @returns the total number of vertices rendered per frame
  32543. */
  32544. getTotalVertices(): number;
  32545. /**
  32546. * Gets the performance counter for total vertices
  32547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32548. */
  32549. readonly totalVerticesPerfCounter: PerfCounter;
  32550. /**
  32551. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32552. * @returns the total number of active indices rendered per frame
  32553. */
  32554. getActiveIndices(): number;
  32555. /**
  32556. * Gets the performance counter for active indices
  32557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32558. */
  32559. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32560. /**
  32561. * Gets the total number of active particles rendered per frame
  32562. * @returns the total number of active particles rendered per frame
  32563. */
  32564. getActiveParticles(): number;
  32565. /**
  32566. * Gets the performance counter for active particles
  32567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32568. */
  32569. readonly activeParticlesPerfCounter: PerfCounter;
  32570. /**
  32571. * Gets the total number of active bones rendered per frame
  32572. * @returns the total number of active bones rendered per frame
  32573. */
  32574. getActiveBones(): number;
  32575. /**
  32576. * Gets the performance counter for active bones
  32577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32578. */
  32579. readonly activeBonesPerfCounter: PerfCounter;
  32580. /**
  32581. * Gets the array of active meshes
  32582. * @returns an array of AbstractMesh
  32583. */
  32584. getActiveMeshes(): SmartArray<AbstractMesh>;
  32585. /**
  32586. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32587. * @returns a number
  32588. */
  32589. getAnimationRatio(): number;
  32590. /**
  32591. * Gets an unique Id for the current render phase
  32592. * @returns a number
  32593. */
  32594. getRenderId(): number;
  32595. /**
  32596. * Gets an unique Id for the current frame
  32597. * @returns a number
  32598. */
  32599. getFrameId(): number;
  32600. /** Call this function if you want to manually increment the render Id*/
  32601. incrementRenderId(): void;
  32602. private _updatePointerPosition;
  32603. private _createUbo;
  32604. private _createAlternateUbo;
  32605. private _setRayOnPointerInfo;
  32606. /**
  32607. * Use this method to simulate a pointer move on a mesh
  32608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32611. * @returns the current scene
  32612. */
  32613. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32614. private _processPointerMove;
  32615. private _checkPrePointerObservable;
  32616. /**
  32617. * Use this method to simulate a pointer down on a mesh
  32618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32621. * @returns the current scene
  32622. */
  32623. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32624. private _processPointerDown;
  32625. /**
  32626. * Use this method to simulate a pointer up on a mesh
  32627. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32628. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32629. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32630. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32631. * @returns the current scene
  32632. */
  32633. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32634. private _processPointerUp;
  32635. /**
  32636. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32637. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32638. * @returns true if the pointer was captured
  32639. */
  32640. isPointerCaptured(pointerId?: number): boolean;
  32641. /** @hidden */
  32642. _isPointerSwiping(): boolean;
  32643. /**
  32644. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32645. * @param attachUp defines if you want to attach events to pointerup
  32646. * @param attachDown defines if you want to attach events to pointerdown
  32647. * @param attachMove defines if you want to attach events to pointermove
  32648. */
  32649. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32650. /** Detaches all event handlers*/
  32651. detachControl(): void;
  32652. /**
  32653. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32654. * Delay loaded resources are not taking in account
  32655. * @return true if all required resources are ready
  32656. */
  32657. isReady(): boolean;
  32658. /** Resets all cached information relative to material (including effect and visibility) */
  32659. resetCachedMaterial(): void;
  32660. /**
  32661. * Registers a function to be called before every frame render
  32662. * @param func defines the function to register
  32663. */
  32664. registerBeforeRender(func: () => void): void;
  32665. /**
  32666. * Unregisters a function called before every frame render
  32667. * @param func defines the function to unregister
  32668. */
  32669. unregisterBeforeRender(func: () => void): void;
  32670. /**
  32671. * Registers a function to be called after every frame render
  32672. * @param func defines the function to register
  32673. */
  32674. registerAfterRender(func: () => void): void;
  32675. /**
  32676. * Unregisters a function called after every frame render
  32677. * @param func defines the function to unregister
  32678. */
  32679. unregisterAfterRender(func: () => void): void;
  32680. private _executeOnceBeforeRender;
  32681. /**
  32682. * The provided function will run before render once and will be disposed afterwards.
  32683. * A timeout delay can be provided so that the function will be executed in N ms.
  32684. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32685. * @param func The function to be executed.
  32686. * @param timeout optional delay in ms
  32687. */
  32688. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32689. /** @hidden */
  32690. _addPendingData(data: any): void;
  32691. /** @hidden */
  32692. _removePendingData(data: any): void;
  32693. /**
  32694. * Returns the number of items waiting to be loaded
  32695. * @returns the number of items waiting to be loaded
  32696. */
  32697. getWaitingItemsCount(): number;
  32698. /**
  32699. * Returns a boolean indicating if the scene is still loading data
  32700. */
  32701. readonly isLoading: boolean;
  32702. /**
  32703. * Registers a function to be executed when the scene is ready
  32704. * @param {Function} func - the function to be executed
  32705. */
  32706. executeWhenReady(func: () => void): void;
  32707. /**
  32708. * Returns a promise that resolves when the scene is ready
  32709. * @returns A promise that resolves when the scene is ready
  32710. */
  32711. whenReadyAsync(): Promise<void>;
  32712. /** @hidden */
  32713. _checkIsReady(): void;
  32714. /**
  32715. * Gets all animatable attached to the scene
  32716. */
  32717. readonly animatables: Animatable[];
  32718. /**
  32719. * Resets the last animation time frame.
  32720. * Useful to override when animations start running when loading a scene for the first time.
  32721. */
  32722. resetLastAnimationTimeFrame(): void;
  32723. /** @hidden */
  32724. _switchToAlternateCameraConfiguration(active: boolean): void;
  32725. /**
  32726. * Gets the current view matrix
  32727. * @returns a Matrix
  32728. */
  32729. getViewMatrix(): Matrix;
  32730. /**
  32731. * Gets the current projection matrix
  32732. * @returns a Matrix
  32733. */
  32734. getProjectionMatrix(): Matrix;
  32735. /**
  32736. * Gets the current transform matrix
  32737. * @returns a Matrix made of View * Projection
  32738. */
  32739. getTransformMatrix(): Matrix;
  32740. /**
  32741. * Sets the current transform matrix
  32742. * @param view defines the View matrix to use
  32743. * @param projection defines the Projection matrix to use
  32744. */
  32745. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32746. /** @hidden */
  32747. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32748. /**
  32749. * Gets the uniform buffer used to store scene data
  32750. * @returns a UniformBuffer
  32751. */
  32752. getSceneUniformBuffer(): UniformBuffer;
  32753. /**
  32754. * Gets an unique (relatively to the current scene) Id
  32755. * @returns an unique number for the scene
  32756. */
  32757. getUniqueId(): number;
  32758. /**
  32759. * Add a mesh to the list of scene's meshes
  32760. * @param newMesh defines the mesh to add
  32761. * @param recursive if all child meshes should also be added to the scene
  32762. */
  32763. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32764. /**
  32765. * Remove a mesh for the list of scene's meshes
  32766. * @param toRemove defines the mesh to remove
  32767. * @param recursive if all child meshes should also be removed from the scene
  32768. * @returns the index where the mesh was in the mesh list
  32769. */
  32770. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32771. /**
  32772. * Add a transform node to the list of scene's transform nodes
  32773. * @param newTransformNode defines the transform node to add
  32774. */
  32775. addTransformNode(newTransformNode: TransformNode): void;
  32776. /**
  32777. * Remove a transform node for the list of scene's transform nodes
  32778. * @param toRemove defines the transform node to remove
  32779. * @returns the index where the transform node was in the transform node list
  32780. */
  32781. removeTransformNode(toRemove: TransformNode): number;
  32782. /**
  32783. * Remove a skeleton for the list of scene's skeletons
  32784. * @param toRemove defines the skeleton to remove
  32785. * @returns the index where the skeleton was in the skeleton list
  32786. */
  32787. removeSkeleton(toRemove: Skeleton): number;
  32788. /**
  32789. * Remove a morph target for the list of scene's morph targets
  32790. * @param toRemove defines the morph target to remove
  32791. * @returns the index where the morph target was in the morph target list
  32792. */
  32793. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32794. /**
  32795. * Remove a light for the list of scene's lights
  32796. * @param toRemove defines the light to remove
  32797. * @returns the index where the light was in the light list
  32798. */
  32799. removeLight(toRemove: Light): number;
  32800. /**
  32801. * Remove a camera for the list of scene's cameras
  32802. * @param toRemove defines the camera to remove
  32803. * @returns the index where the camera was in the camera list
  32804. */
  32805. removeCamera(toRemove: Camera): number;
  32806. /**
  32807. * Remove a particle system for the list of scene's particle systems
  32808. * @param toRemove defines the particle system to remove
  32809. * @returns the index where the particle system was in the particle system list
  32810. */
  32811. removeParticleSystem(toRemove: IParticleSystem): number;
  32812. /**
  32813. * Remove a animation for the list of scene's animations
  32814. * @param toRemove defines the animation to remove
  32815. * @returns the index where the animation was in the animation list
  32816. */
  32817. removeAnimation(toRemove: Animation): number;
  32818. /**
  32819. * Removes the given animation group from this scene.
  32820. * @param toRemove The animation group to remove
  32821. * @returns The index of the removed animation group
  32822. */
  32823. removeAnimationGroup(toRemove: AnimationGroup): number;
  32824. /**
  32825. * Removes the given multi-material from this scene.
  32826. * @param toRemove The multi-material to remove
  32827. * @returns The index of the removed multi-material
  32828. */
  32829. removeMultiMaterial(toRemove: MultiMaterial): number;
  32830. /**
  32831. * Removes the given material from this scene.
  32832. * @param toRemove The material to remove
  32833. * @returns The index of the removed material
  32834. */
  32835. removeMaterial(toRemove: Material): number;
  32836. /**
  32837. * Removes the given action manager from this scene.
  32838. * @param toRemove The action manager to remove
  32839. * @returns The index of the removed action manager
  32840. */
  32841. removeActionManager(toRemove: AbstractActionManager): number;
  32842. /**
  32843. * Removes the given texture from this scene.
  32844. * @param toRemove The texture to remove
  32845. * @returns The index of the removed texture
  32846. */
  32847. removeTexture(toRemove: BaseTexture): number;
  32848. /**
  32849. * Adds the given light to this scene
  32850. * @param newLight The light to add
  32851. */
  32852. addLight(newLight: Light): void;
  32853. /**
  32854. * Sorts the list list based on light priorities
  32855. */
  32856. sortLightsByPriority(): void;
  32857. /**
  32858. * Adds the given camera to this scene
  32859. * @param newCamera The camera to add
  32860. */
  32861. addCamera(newCamera: Camera): void;
  32862. /**
  32863. * Adds the given skeleton to this scene
  32864. * @param newSkeleton The skeleton to add
  32865. */
  32866. addSkeleton(newSkeleton: Skeleton): void;
  32867. /**
  32868. * Adds the given particle system to this scene
  32869. * @param newParticleSystem The particle system to add
  32870. */
  32871. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32872. /**
  32873. * Adds the given animation to this scene
  32874. * @param newAnimation The animation to add
  32875. */
  32876. addAnimation(newAnimation: Animation): void;
  32877. /**
  32878. * Adds the given animation group to this scene.
  32879. * @param newAnimationGroup The animation group to add
  32880. */
  32881. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32882. /**
  32883. * Adds the given multi-material to this scene
  32884. * @param newMultiMaterial The multi-material to add
  32885. */
  32886. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32887. /**
  32888. * Adds the given material to this scene
  32889. * @param newMaterial The material to add
  32890. */
  32891. addMaterial(newMaterial: Material): void;
  32892. /**
  32893. * Adds the given morph target to this scene
  32894. * @param newMorphTargetManager The morph target to add
  32895. */
  32896. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32897. /**
  32898. * Adds the given geometry to this scene
  32899. * @param newGeometry The geometry to add
  32900. */
  32901. addGeometry(newGeometry: Geometry): void;
  32902. /**
  32903. * Adds the given action manager to this scene
  32904. * @param newActionManager The action manager to add
  32905. */
  32906. addActionManager(newActionManager: AbstractActionManager): void;
  32907. /**
  32908. * Adds the given texture to this scene.
  32909. * @param newTexture The texture to add
  32910. */
  32911. addTexture(newTexture: BaseTexture): void;
  32912. /**
  32913. * Switch active camera
  32914. * @param newCamera defines the new active camera
  32915. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32916. */
  32917. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32918. /**
  32919. * sets the active camera of the scene using its ID
  32920. * @param id defines the camera's ID
  32921. * @return the new active camera or null if none found.
  32922. */
  32923. setActiveCameraByID(id: string): Nullable<Camera>;
  32924. /**
  32925. * sets the active camera of the scene using its name
  32926. * @param name defines the camera's name
  32927. * @returns the new active camera or null if none found.
  32928. */
  32929. setActiveCameraByName(name: string): Nullable<Camera>;
  32930. /**
  32931. * get an animation group using its name
  32932. * @param name defines the material's name
  32933. * @return the animation group or null if none found.
  32934. */
  32935. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32936. /**
  32937. * get a material using its id
  32938. * @param id defines the material's ID
  32939. * @return the material or null if none found.
  32940. */
  32941. getMaterialByID(id: string): Nullable<Material>;
  32942. /**
  32943. * Gets a material using its name
  32944. * @param name defines the material's name
  32945. * @return the material or null if none found.
  32946. */
  32947. getMaterialByName(name: string): Nullable<Material>;
  32948. /**
  32949. * Gets a camera using its id
  32950. * @param id defines the id to look for
  32951. * @returns the camera or null if not found
  32952. */
  32953. getCameraByID(id: string): Nullable<Camera>;
  32954. /**
  32955. * Gets a camera using its unique id
  32956. * @param uniqueId defines the unique id to look for
  32957. * @returns the camera or null if not found
  32958. */
  32959. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32960. /**
  32961. * Gets a camera using its name
  32962. * @param name defines the camera's name
  32963. * @return the camera or null if none found.
  32964. */
  32965. getCameraByName(name: string): Nullable<Camera>;
  32966. /**
  32967. * Gets a bone using its id
  32968. * @param id defines the bone's id
  32969. * @return the bone or null if not found
  32970. */
  32971. getBoneByID(id: string): Nullable<Bone>;
  32972. /**
  32973. * Gets a bone using its id
  32974. * @param name defines the bone's name
  32975. * @return the bone or null if not found
  32976. */
  32977. getBoneByName(name: string): Nullable<Bone>;
  32978. /**
  32979. * Gets a light node using its name
  32980. * @param name defines the the light's name
  32981. * @return the light or null if none found.
  32982. */
  32983. getLightByName(name: string): Nullable<Light>;
  32984. /**
  32985. * Gets a light node using its id
  32986. * @param id defines the light's id
  32987. * @return the light or null if none found.
  32988. */
  32989. getLightByID(id: string): Nullable<Light>;
  32990. /**
  32991. * Gets a light node using its scene-generated unique ID
  32992. * @param uniqueId defines the light's unique id
  32993. * @return the light or null if none found.
  32994. */
  32995. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32996. /**
  32997. * Gets a particle system by id
  32998. * @param id defines the particle system id
  32999. * @return the corresponding system or null if none found
  33000. */
  33001. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33002. /**
  33003. * Gets a geometry using its ID
  33004. * @param id defines the geometry's id
  33005. * @return the geometry or null if none found.
  33006. */
  33007. getGeometryByID(id: string): Nullable<Geometry>;
  33008. private _getGeometryByUniqueID;
  33009. /**
  33010. * Add a new geometry to this scene
  33011. * @param geometry defines the geometry to be added to the scene.
  33012. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33013. * @return a boolean defining if the geometry was added or not
  33014. */
  33015. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33016. /**
  33017. * Removes an existing geometry
  33018. * @param geometry defines the geometry to be removed from the scene
  33019. * @return a boolean defining if the geometry was removed or not
  33020. */
  33021. removeGeometry(geometry: Geometry): boolean;
  33022. /**
  33023. * Gets the list of geometries attached to the scene
  33024. * @returns an array of Geometry
  33025. */
  33026. getGeometries(): Geometry[];
  33027. /**
  33028. * Gets the first added mesh found of a given ID
  33029. * @param id defines the id to search for
  33030. * @return the mesh found or null if not found at all
  33031. */
  33032. getMeshByID(id: string): Nullable<AbstractMesh>;
  33033. /**
  33034. * Gets a list of meshes using their id
  33035. * @param id defines the id to search for
  33036. * @returns a list of meshes
  33037. */
  33038. getMeshesByID(id: string): Array<AbstractMesh>;
  33039. /**
  33040. * Gets the first added transform node found of a given ID
  33041. * @param id defines the id to search for
  33042. * @return the found transform node or null if not found at all.
  33043. */
  33044. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33045. /**
  33046. * Gets a list of transform nodes using their id
  33047. * @param id defines the id to search for
  33048. * @returns a list of transform nodes
  33049. */
  33050. getTransformNodesByID(id: string): Array<TransformNode>;
  33051. /**
  33052. * Gets a mesh with its auto-generated unique id
  33053. * @param uniqueId defines the unique id to search for
  33054. * @return the found mesh or null if not found at all.
  33055. */
  33056. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33057. /**
  33058. * Gets a the last added mesh using a given id
  33059. * @param id defines the id to search for
  33060. * @return the found mesh or null if not found at all.
  33061. */
  33062. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33063. /**
  33064. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33065. * @param id defines the id to search for
  33066. * @return the found node or null if not found at all
  33067. */
  33068. getLastEntryByID(id: string): Nullable<Node>;
  33069. /**
  33070. * Gets a node (Mesh, Camera, Light) using a given id
  33071. * @param id defines the id to search for
  33072. * @return the found node or null if not found at all
  33073. */
  33074. getNodeByID(id: string): Nullable<Node>;
  33075. /**
  33076. * Gets a node (Mesh, Camera, Light) using a given name
  33077. * @param name defines the name to search for
  33078. * @return the found node or null if not found at all.
  33079. */
  33080. getNodeByName(name: string): Nullable<Node>;
  33081. /**
  33082. * Gets a mesh using a given name
  33083. * @param name defines the name to search for
  33084. * @return the found mesh or null if not found at all.
  33085. */
  33086. getMeshByName(name: string): Nullable<AbstractMesh>;
  33087. /**
  33088. * Gets a transform node using a given name
  33089. * @param name defines the name to search for
  33090. * @return the found transform node or null if not found at all.
  33091. */
  33092. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33093. /**
  33094. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33095. * @param id defines the id to search for
  33096. * @return the found skeleton or null if not found at all.
  33097. */
  33098. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33099. /**
  33100. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33101. * @param id defines the id to search for
  33102. * @return the found skeleton or null if not found at all.
  33103. */
  33104. getSkeletonById(id: string): Nullable<Skeleton>;
  33105. /**
  33106. * Gets a skeleton using a given name
  33107. * @param name defines the name to search for
  33108. * @return the found skeleton or null if not found at all.
  33109. */
  33110. getSkeletonByName(name: string): Nullable<Skeleton>;
  33111. /**
  33112. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33113. * @param id defines the id to search for
  33114. * @return the found morph target manager or null if not found at all.
  33115. */
  33116. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33117. /**
  33118. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33119. * @param id defines the id to search for
  33120. * @return the found morph target or null if not found at all.
  33121. */
  33122. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33123. /**
  33124. * Gets a boolean indicating if the given mesh is active
  33125. * @param mesh defines the mesh to look for
  33126. * @returns true if the mesh is in the active list
  33127. */
  33128. isActiveMesh(mesh: AbstractMesh): boolean;
  33129. /**
  33130. * Return a unique id as a string which can serve as an identifier for the scene
  33131. */
  33132. readonly uid: string;
  33133. /**
  33134. * Add an externaly attached data from its key.
  33135. * This method call will fail and return false, if such key already exists.
  33136. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33137. * @param key the unique key that identifies the data
  33138. * @param data the data object to associate to the key for this Engine instance
  33139. * @return true if no such key were already present and the data was added successfully, false otherwise
  33140. */
  33141. addExternalData<T>(key: string, data: T): boolean;
  33142. /**
  33143. * Get an externaly attached data from its key
  33144. * @param key the unique key that identifies the data
  33145. * @return the associated data, if present (can be null), or undefined if not present
  33146. */
  33147. getExternalData<T>(key: string): Nullable<T>;
  33148. /**
  33149. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33150. * @param key the unique key that identifies the data
  33151. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33152. * @return the associated data, can be null if the factory returned null.
  33153. */
  33154. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33155. /**
  33156. * Remove an externaly attached data from the Engine instance
  33157. * @param key the unique key that identifies the data
  33158. * @return true if the data was successfully removed, false if it doesn't exist
  33159. */
  33160. removeExternalData(key: string): boolean;
  33161. private _evaluateSubMesh;
  33162. /**
  33163. * Clear the processed materials smart array preventing retention point in material dispose.
  33164. */
  33165. freeProcessedMaterials(): void;
  33166. private _preventFreeActiveMeshesAndRenderingGroups;
  33167. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33168. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33169. * when disposing several meshes in a row or a hierarchy of meshes.
  33170. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33171. */
  33172. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33173. /**
  33174. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33175. */
  33176. freeActiveMeshes(): void;
  33177. /**
  33178. * Clear the info related to rendering groups preventing retention points during dispose.
  33179. */
  33180. freeRenderingGroups(): void;
  33181. /** @hidden */
  33182. _isInIntermediateRendering(): boolean;
  33183. /**
  33184. * Lambda returning the list of potentially active meshes.
  33185. */
  33186. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33187. /**
  33188. * Lambda returning the list of potentially active sub meshes.
  33189. */
  33190. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33191. /**
  33192. * Lambda returning the list of potentially intersecting sub meshes.
  33193. */
  33194. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33195. /**
  33196. * Lambda returning the list of potentially colliding sub meshes.
  33197. */
  33198. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33199. private _activeMeshesFrozen;
  33200. /**
  33201. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33202. * @returns the current scene
  33203. */
  33204. freezeActiveMeshes(): Scene;
  33205. /**
  33206. * Use this function to restart evaluating active meshes on every frame
  33207. * @returns the current scene
  33208. */
  33209. unfreezeActiveMeshes(): Scene;
  33210. private _evaluateActiveMeshes;
  33211. private _activeMesh;
  33212. /**
  33213. * Update the transform matrix to update from the current active camera
  33214. * @param force defines a boolean used to force the update even if cache is up to date
  33215. */
  33216. updateTransformMatrix(force?: boolean): void;
  33217. /**
  33218. * 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)
  33219. * @param alternateCamera defines the camera to use
  33220. */
  33221. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33222. /** @hidden */
  33223. _allowPostProcessClearColor: boolean;
  33224. private _renderForCamera;
  33225. private _processSubCameras;
  33226. private _checkIntersections;
  33227. /** @hidden */
  33228. _advancePhysicsEngineStep(step: number): void;
  33229. /**
  33230. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33231. */
  33232. getDeterministicFrameTime: () => number;
  33233. /** @hidden */
  33234. _animate(): void;
  33235. /**
  33236. * Render the scene
  33237. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33238. */
  33239. render(updateCameras?: boolean): void;
  33240. /**
  33241. * Freeze all materials
  33242. * A frozen material will not be updatable but should be faster to render
  33243. */
  33244. freezeMaterials(): void;
  33245. /**
  33246. * Unfreeze all materials
  33247. * A frozen material will not be updatable but should be faster to render
  33248. */
  33249. unfreezeMaterials(): void;
  33250. /**
  33251. * Releases all held ressources
  33252. */
  33253. dispose(): void;
  33254. /**
  33255. * Gets if the scene is already disposed
  33256. */
  33257. readonly isDisposed: boolean;
  33258. /**
  33259. * Call this function to reduce memory footprint of the scene.
  33260. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33261. */
  33262. clearCachedVertexData(): void;
  33263. /**
  33264. * This function will remove the local cached buffer data from texture.
  33265. * It will save memory but will prevent the texture from being rebuilt
  33266. */
  33267. cleanCachedTextureBuffer(): void;
  33268. /**
  33269. * Get the world extend vectors with an optional filter
  33270. *
  33271. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33272. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33273. */
  33274. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33275. min: Vector3;
  33276. max: Vector3;
  33277. };
  33278. /**
  33279. * Creates a ray that can be used to pick in the scene
  33280. * @param x defines the x coordinate of the origin (on-screen)
  33281. * @param y defines the y coordinate of the origin (on-screen)
  33282. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33283. * @param camera defines the camera to use for the picking
  33284. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33285. * @returns a Ray
  33286. */
  33287. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33288. /**
  33289. * Creates a ray that can be used to pick in the scene
  33290. * @param x defines the x coordinate of the origin (on-screen)
  33291. * @param y defines the y coordinate of the origin (on-screen)
  33292. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33293. * @param result defines the ray where to store the picking ray
  33294. * @param camera defines the camera to use for the picking
  33295. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33296. * @returns the current scene
  33297. */
  33298. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33299. /**
  33300. * Creates a ray that can be used to pick in the scene
  33301. * @param x defines the x coordinate of the origin (on-screen)
  33302. * @param y defines the y coordinate of the origin (on-screen)
  33303. * @param camera defines the camera to use for the picking
  33304. * @returns a Ray
  33305. */
  33306. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33307. /**
  33308. * Creates a ray that can be used to pick in the scene
  33309. * @param x defines the x coordinate of the origin (on-screen)
  33310. * @param y defines the y coordinate of the origin (on-screen)
  33311. * @param result defines the ray where to store the picking ray
  33312. * @param camera defines the camera to use for the picking
  33313. * @returns the current scene
  33314. */
  33315. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33316. /** Launch a ray to try to pick a mesh in the scene
  33317. * @param x position on screen
  33318. * @param y position on screen
  33319. * @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
  33320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33321. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33322. * @returns a PickingInfo
  33323. */
  33324. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33325. /** Use the given ray to pick a mesh in the scene
  33326. * @param ray The ray to use to pick meshes
  33327. * @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
  33328. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33329. * @returns a PickingInfo
  33330. */
  33331. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33332. /**
  33333. * Launch a ray to try to pick a mesh in the scene
  33334. * @param x X position on screen
  33335. * @param y Y position on screen
  33336. * @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
  33337. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33338. * @returns an array of PickingInfo
  33339. */
  33340. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33341. /**
  33342. * Launch a ray to try to pick a mesh in the scene
  33343. * @param ray Ray to use
  33344. * @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
  33345. * @returns an array of PickingInfo
  33346. */
  33347. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33348. /**
  33349. * Force the value of meshUnderPointer
  33350. * @param mesh defines the mesh to use
  33351. */
  33352. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33353. /**
  33354. * Gets the mesh under the pointer
  33355. * @returns a Mesh or null if no mesh is under the pointer
  33356. */
  33357. getPointerOverMesh(): Nullable<AbstractMesh>;
  33358. /** @hidden */
  33359. _rebuildGeometries(): void;
  33360. /** @hidden */
  33361. _rebuildTextures(): void;
  33362. private _getByTags;
  33363. /**
  33364. * Get a list of meshes by tags
  33365. * @param tagsQuery defines the tags query to use
  33366. * @param forEach defines a predicate used to filter results
  33367. * @returns an array of Mesh
  33368. */
  33369. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33370. /**
  33371. * Get a list of cameras by tags
  33372. * @param tagsQuery defines the tags query to use
  33373. * @param forEach defines a predicate used to filter results
  33374. * @returns an array of Camera
  33375. */
  33376. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33377. /**
  33378. * Get a list of lights by tags
  33379. * @param tagsQuery defines the tags query to use
  33380. * @param forEach defines a predicate used to filter results
  33381. * @returns an array of Light
  33382. */
  33383. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33384. /**
  33385. * Get a list of materials by tags
  33386. * @param tagsQuery defines the tags query to use
  33387. * @param forEach defines a predicate used to filter results
  33388. * @returns an array of Material
  33389. */
  33390. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33391. /**
  33392. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33393. * This allowed control for front to back rendering or reversly depending of the special needs.
  33394. *
  33395. * @param renderingGroupId The rendering group id corresponding to its index
  33396. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33397. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33398. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33399. */
  33400. 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;
  33401. /**
  33402. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33403. *
  33404. * @param renderingGroupId The rendering group id corresponding to its index
  33405. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33406. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33407. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33408. */
  33409. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33410. /**
  33411. * Gets the current auto clear configuration for one rendering group of the rendering
  33412. * manager.
  33413. * @param index the rendering group index to get the information for
  33414. * @returns The auto clear setup for the requested rendering group
  33415. */
  33416. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33417. private _blockMaterialDirtyMechanism;
  33418. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33419. blockMaterialDirtyMechanism: boolean;
  33420. /**
  33421. * Will flag all materials as dirty to trigger new shader compilation
  33422. * @param flag defines the flag used to specify which material part must be marked as dirty
  33423. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33424. */
  33425. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33426. /** @hidden */
  33427. _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;
  33428. /** @hidden */
  33429. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33430. }
  33431. }
  33432. declare module "babylonjs/assetContainer" {
  33433. import { AbstractScene } from "babylonjs/abstractScene";
  33434. import { Scene } from "babylonjs/scene";
  33435. import { Mesh } from "babylonjs/Meshes/mesh";
  33436. /**
  33437. * Set of assets to keep when moving a scene into an asset container.
  33438. */
  33439. export class KeepAssets extends AbstractScene {
  33440. }
  33441. /**
  33442. * Container with a set of assets that can be added or removed from a scene.
  33443. */
  33444. export class AssetContainer extends AbstractScene {
  33445. /**
  33446. * The scene the AssetContainer belongs to.
  33447. */
  33448. scene: Scene;
  33449. /**
  33450. * Instantiates an AssetContainer.
  33451. * @param scene The scene the AssetContainer belongs to.
  33452. */
  33453. constructor(scene: Scene);
  33454. /**
  33455. * Adds all the assets from the container to the scene.
  33456. */
  33457. addAllToScene(): void;
  33458. /**
  33459. * Removes all the assets in the container from the scene
  33460. */
  33461. removeAllFromScene(): void;
  33462. /**
  33463. * Disposes all the assets in the container
  33464. */
  33465. dispose(): void;
  33466. private _moveAssets;
  33467. /**
  33468. * Removes all the assets contained in the scene and adds them to the container.
  33469. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33470. */
  33471. moveAllFromScene(keepAssets?: KeepAssets): void;
  33472. /**
  33473. * 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.
  33474. * @returns the root mesh
  33475. */
  33476. createRootMesh(): Mesh;
  33477. }
  33478. }
  33479. declare module "babylonjs/abstractScene" {
  33480. import { Scene } from "babylonjs/scene";
  33481. import { Nullable } from "babylonjs/types";
  33482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33484. import { Geometry } from "babylonjs/Meshes/geometry";
  33485. import { Skeleton } from "babylonjs/Bones/skeleton";
  33486. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33487. import { AssetContainer } from "babylonjs/assetContainer";
  33488. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33489. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33491. import { Material } from "babylonjs/Materials/material";
  33492. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33493. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33494. import { Camera } from "babylonjs/Cameras/camera";
  33495. import { Light } from "babylonjs/Lights/light";
  33496. import { Node } from "babylonjs/node";
  33497. import { Animation } from "babylonjs/Animations/animation";
  33498. /**
  33499. * Defines how the parser contract is defined.
  33500. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33501. */
  33502. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33503. /**
  33504. * Defines how the individual parser contract is defined.
  33505. * These parser can parse an individual asset
  33506. */
  33507. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33508. /**
  33509. * Base class of the scene acting as a container for the different elements composing a scene.
  33510. * This class is dynamically extended by the different components of the scene increasing
  33511. * flexibility and reducing coupling
  33512. */
  33513. export abstract class AbstractScene {
  33514. /**
  33515. * Stores the list of available parsers in the application.
  33516. */
  33517. private static _BabylonFileParsers;
  33518. /**
  33519. * Stores the list of available individual parsers in the application.
  33520. */
  33521. private static _IndividualBabylonFileParsers;
  33522. /**
  33523. * Adds a parser in the list of available ones
  33524. * @param name Defines the name of the parser
  33525. * @param parser Defines the parser to add
  33526. */
  33527. static AddParser(name: string, parser: BabylonFileParser): void;
  33528. /**
  33529. * Gets a general parser from the list of avaialble ones
  33530. * @param name Defines the name of the parser
  33531. * @returns the requested parser or null
  33532. */
  33533. static GetParser(name: string): Nullable<BabylonFileParser>;
  33534. /**
  33535. * Adds n individual parser in the list of available ones
  33536. * @param name Defines the name of the parser
  33537. * @param parser Defines the parser to add
  33538. */
  33539. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33540. /**
  33541. * Gets an individual parser from the list of avaialble ones
  33542. * @param name Defines the name of the parser
  33543. * @returns the requested parser or null
  33544. */
  33545. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33546. /**
  33547. * Parser json data and populate both a scene and its associated container object
  33548. * @param jsonData Defines the data to parse
  33549. * @param scene Defines the scene to parse the data for
  33550. * @param container Defines the container attached to the parsing sequence
  33551. * @param rootUrl Defines the root url of the data
  33552. */
  33553. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33554. /**
  33555. * Gets the list of root nodes (ie. nodes with no parent)
  33556. */
  33557. rootNodes: Node[];
  33558. /** All of the cameras added to this scene
  33559. * @see http://doc.babylonjs.com/babylon101/cameras
  33560. */
  33561. cameras: Camera[];
  33562. /**
  33563. * All of the lights added to this scene
  33564. * @see http://doc.babylonjs.com/babylon101/lights
  33565. */
  33566. lights: Light[];
  33567. /**
  33568. * All of the (abstract) meshes added to this scene
  33569. */
  33570. meshes: AbstractMesh[];
  33571. /**
  33572. * The list of skeletons added to the scene
  33573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33574. */
  33575. skeletons: Skeleton[];
  33576. /**
  33577. * All of the particle systems added to this scene
  33578. * @see http://doc.babylonjs.com/babylon101/particles
  33579. */
  33580. particleSystems: IParticleSystem[];
  33581. /**
  33582. * Gets a list of Animations associated with the scene
  33583. */
  33584. animations: Animation[];
  33585. /**
  33586. * All of the animation groups added to this scene
  33587. * @see http://doc.babylonjs.com/how_to/group
  33588. */
  33589. animationGroups: AnimationGroup[];
  33590. /**
  33591. * All of the multi-materials added to this scene
  33592. * @see http://doc.babylonjs.com/how_to/multi_materials
  33593. */
  33594. multiMaterials: MultiMaterial[];
  33595. /**
  33596. * All of the materials added to this scene
  33597. * In the context of a Scene, it is not supposed to be modified manually.
  33598. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33599. * Note also that the order of the Material wihin the array is not significant and might change.
  33600. * @see http://doc.babylonjs.com/babylon101/materials
  33601. */
  33602. materials: Material[];
  33603. /**
  33604. * The list of morph target managers added to the scene
  33605. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33606. */
  33607. morphTargetManagers: MorphTargetManager[];
  33608. /**
  33609. * The list of geometries used in the scene.
  33610. */
  33611. geometries: Geometry[];
  33612. /**
  33613. * All of the tranform nodes added to this scene
  33614. * In the context of a Scene, it is not supposed to be modified manually.
  33615. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33616. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33617. * @see http://doc.babylonjs.com/how_to/transformnode
  33618. */
  33619. transformNodes: TransformNode[];
  33620. /**
  33621. * ActionManagers available on the scene.
  33622. */
  33623. actionManagers: AbstractActionManager[];
  33624. /**
  33625. * Textures to keep.
  33626. */
  33627. textures: BaseTexture[];
  33628. }
  33629. }
  33630. declare module "babylonjs/Audio/sound" {
  33631. import { Observable } from "babylonjs/Misc/observable";
  33632. import { Vector3 } from "babylonjs/Maths/math";
  33633. import { Nullable } from "babylonjs/types";
  33634. import { Scene } from "babylonjs/scene";
  33635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33636. /**
  33637. * Defines a sound that can be played in the application.
  33638. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33640. */
  33641. export class Sound {
  33642. /**
  33643. * The name of the sound in the scene.
  33644. */
  33645. name: string;
  33646. /**
  33647. * Does the sound autoplay once loaded.
  33648. */
  33649. autoplay: boolean;
  33650. /**
  33651. * Does the sound loop after it finishes playing once.
  33652. */
  33653. loop: boolean;
  33654. /**
  33655. * Does the sound use a custom attenuation curve to simulate the falloff
  33656. * happening when the source gets further away from the camera.
  33657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33658. */
  33659. useCustomAttenuation: boolean;
  33660. /**
  33661. * The sound track id this sound belongs to.
  33662. */
  33663. soundTrackId: number;
  33664. /**
  33665. * Is this sound currently played.
  33666. */
  33667. isPlaying: boolean;
  33668. /**
  33669. * Is this sound currently paused.
  33670. */
  33671. isPaused: boolean;
  33672. /**
  33673. * Does this sound enables spatial sound.
  33674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33675. */
  33676. spatialSound: boolean;
  33677. /**
  33678. * Define the reference distance the sound should be heard perfectly.
  33679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33680. */
  33681. refDistance: number;
  33682. /**
  33683. * Define the roll off factor of spatial sounds.
  33684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33685. */
  33686. rolloffFactor: number;
  33687. /**
  33688. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33690. */
  33691. maxDistance: number;
  33692. /**
  33693. * Define the distance attenuation model the sound will follow.
  33694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33695. */
  33696. distanceModel: string;
  33697. /**
  33698. * @hidden
  33699. * Back Compat
  33700. **/
  33701. onended: () => any;
  33702. /**
  33703. * Observable event when the current playing sound finishes.
  33704. */
  33705. onEndedObservable: Observable<Sound>;
  33706. private _panningModel;
  33707. private _playbackRate;
  33708. private _streaming;
  33709. private _startTime;
  33710. private _startOffset;
  33711. private _position;
  33712. /** @hidden */
  33713. _positionInEmitterSpace: boolean;
  33714. private _localDirection;
  33715. private _volume;
  33716. private _isReadyToPlay;
  33717. private _isDirectional;
  33718. private _readyToPlayCallback;
  33719. private _audioBuffer;
  33720. private _soundSource;
  33721. private _streamingSource;
  33722. private _soundPanner;
  33723. private _soundGain;
  33724. private _inputAudioNode;
  33725. private _outputAudioNode;
  33726. private _coneInnerAngle;
  33727. private _coneOuterAngle;
  33728. private _coneOuterGain;
  33729. private _scene;
  33730. private _connectedTransformNode;
  33731. private _customAttenuationFunction;
  33732. private _registerFunc;
  33733. private _isOutputConnected;
  33734. private _htmlAudioElement;
  33735. private _urlType;
  33736. /** @hidden */
  33737. static _SceneComponentInitialization: (scene: Scene) => void;
  33738. /**
  33739. * Create a sound and attach it to a scene
  33740. * @param name Name of your sound
  33741. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33742. * @param scene defines the scene the sound belongs to
  33743. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33744. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33745. */
  33746. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33747. /**
  33748. * Release the sound and its associated resources
  33749. */
  33750. dispose(): void;
  33751. /**
  33752. * Gets if the sounds is ready to be played or not.
  33753. * @returns true if ready, otherwise false
  33754. */
  33755. isReady(): boolean;
  33756. private _soundLoaded;
  33757. /**
  33758. * Sets the data of the sound from an audiobuffer
  33759. * @param audioBuffer The audioBuffer containing the data
  33760. */
  33761. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33762. /**
  33763. * Updates the current sounds options such as maxdistance, loop...
  33764. * @param options A JSON object containing values named as the object properties
  33765. */
  33766. updateOptions(options: any): void;
  33767. private _createSpatialParameters;
  33768. private _updateSpatialParameters;
  33769. /**
  33770. * Switch the panning model to HRTF:
  33771. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33773. */
  33774. switchPanningModelToHRTF(): void;
  33775. /**
  33776. * Switch the panning model to Equal Power:
  33777. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33779. */
  33780. switchPanningModelToEqualPower(): void;
  33781. private _switchPanningModel;
  33782. /**
  33783. * Connect this sound to a sound track audio node like gain...
  33784. * @param soundTrackAudioNode the sound track audio node to connect to
  33785. */
  33786. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33787. /**
  33788. * Transform this sound into a directional source
  33789. * @param coneInnerAngle Size of the inner cone in degree
  33790. * @param coneOuterAngle Size of the outer cone in degree
  33791. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33792. */
  33793. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33794. /**
  33795. * Gets or sets the inner angle for the directional cone.
  33796. */
  33797. /**
  33798. * Gets or sets the inner angle for the directional cone.
  33799. */
  33800. directionalConeInnerAngle: number;
  33801. /**
  33802. * Gets or sets the outer angle for the directional cone.
  33803. */
  33804. /**
  33805. * Gets or sets the outer angle for the directional cone.
  33806. */
  33807. directionalConeOuterAngle: number;
  33808. /**
  33809. * Sets the position of the emitter if spatial sound is enabled
  33810. * @param newPosition Defines the new posisiton
  33811. */
  33812. setPosition(newPosition: Vector3): void;
  33813. /**
  33814. * Sets the local direction of the emitter if spatial sound is enabled
  33815. * @param newLocalDirection Defines the new local direction
  33816. */
  33817. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33818. private _updateDirection;
  33819. /** @hidden */
  33820. updateDistanceFromListener(): void;
  33821. /**
  33822. * Sets a new custom attenuation function for the sound.
  33823. * @param callback Defines the function used for the attenuation
  33824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33825. */
  33826. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33827. /**
  33828. * Play the sound
  33829. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33830. * @param offset (optional) Start the sound setting it at a specific time
  33831. */
  33832. play(time?: number, offset?: number): void;
  33833. private _onended;
  33834. /**
  33835. * Stop the sound
  33836. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33837. */
  33838. stop(time?: number): void;
  33839. /**
  33840. * Put the sound in pause
  33841. */
  33842. pause(): void;
  33843. /**
  33844. * Sets a dedicated volume for this sounds
  33845. * @param newVolume Define the new volume of the sound
  33846. * @param time Define in how long the sound should be at this value
  33847. */
  33848. setVolume(newVolume: number, time?: number): void;
  33849. /**
  33850. * Set the sound play back rate
  33851. * @param newPlaybackRate Define the playback rate the sound should be played at
  33852. */
  33853. setPlaybackRate(newPlaybackRate: number): void;
  33854. /**
  33855. * Gets the volume of the sound.
  33856. * @returns the volume of the sound
  33857. */
  33858. getVolume(): number;
  33859. /**
  33860. * Attach the sound to a dedicated mesh
  33861. * @param transformNode The transform node to connect the sound with
  33862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33863. */
  33864. attachToMesh(transformNode: TransformNode): void;
  33865. /**
  33866. * Detach the sound from the previously attached mesh
  33867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33868. */
  33869. detachFromMesh(): void;
  33870. private _onRegisterAfterWorldMatrixUpdate;
  33871. /**
  33872. * Clone the current sound in the scene.
  33873. * @returns the new sound clone
  33874. */
  33875. clone(): Nullable<Sound>;
  33876. /**
  33877. * Gets the current underlying audio buffer containing the data
  33878. * @returns the audio buffer
  33879. */
  33880. getAudioBuffer(): Nullable<AudioBuffer>;
  33881. /**
  33882. * Serializes the Sound in a JSON representation
  33883. * @returns the JSON representation of the sound
  33884. */
  33885. serialize(): any;
  33886. /**
  33887. * Parse a JSON representation of a sound to innstantiate in a given scene
  33888. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33889. * @param scene Define the scene the new parsed sound should be created in
  33890. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33891. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33892. * @returns the newly parsed sound
  33893. */
  33894. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33895. }
  33896. }
  33897. declare module "babylonjs/Actions/directAudioActions" {
  33898. import { Action } from "babylonjs/Actions/action";
  33899. import { Condition } from "babylonjs/Actions/condition";
  33900. import { Sound } from "babylonjs/Audio/sound";
  33901. /**
  33902. * This defines an action helpful to play a defined sound on a triggered action.
  33903. */
  33904. export class PlaySoundAction extends Action {
  33905. private _sound;
  33906. /**
  33907. * Instantiate the action
  33908. * @param triggerOptions defines the trigger options
  33909. * @param sound defines the sound to play
  33910. * @param condition defines the trigger related conditions
  33911. */
  33912. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33913. /** @hidden */
  33914. _prepare(): void;
  33915. /**
  33916. * Execute the action and play the sound.
  33917. */
  33918. execute(): void;
  33919. /**
  33920. * Serializes the actions and its related information.
  33921. * @param parent defines the object to serialize in
  33922. * @returns the serialized object
  33923. */
  33924. serialize(parent: any): any;
  33925. }
  33926. /**
  33927. * This defines an action helpful to stop a defined sound on a triggered action.
  33928. */
  33929. export class StopSoundAction extends Action {
  33930. private _sound;
  33931. /**
  33932. * Instantiate the action
  33933. * @param triggerOptions defines the trigger options
  33934. * @param sound defines the sound to stop
  33935. * @param condition defines the trigger related conditions
  33936. */
  33937. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33938. /** @hidden */
  33939. _prepare(): void;
  33940. /**
  33941. * Execute the action and stop the sound.
  33942. */
  33943. execute(): void;
  33944. /**
  33945. * Serializes the actions and its related information.
  33946. * @param parent defines the object to serialize in
  33947. * @returns the serialized object
  33948. */
  33949. serialize(parent: any): any;
  33950. }
  33951. }
  33952. declare module "babylonjs/Actions/interpolateValueAction" {
  33953. import { Action } from "babylonjs/Actions/action";
  33954. import { Condition } from "babylonjs/Actions/condition";
  33955. import { Observable } from "babylonjs/Misc/observable";
  33956. /**
  33957. * This defines an action responsible to change the value of a property
  33958. * by interpolating between its current value and the newly set one once triggered.
  33959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33960. */
  33961. export class InterpolateValueAction extends Action {
  33962. /**
  33963. * Defines the path of the property where the value should be interpolated
  33964. */
  33965. propertyPath: string;
  33966. /**
  33967. * Defines the target value at the end of the interpolation.
  33968. */
  33969. value: any;
  33970. /**
  33971. * Defines the time it will take for the property to interpolate to the value.
  33972. */
  33973. duration: number;
  33974. /**
  33975. * Defines if the other scene animations should be stopped when the action has been triggered
  33976. */
  33977. stopOtherAnimations?: boolean;
  33978. /**
  33979. * Defines a callback raised once the interpolation animation has been done.
  33980. */
  33981. onInterpolationDone?: () => void;
  33982. /**
  33983. * Observable triggered once the interpolation animation has been done.
  33984. */
  33985. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33986. private _target;
  33987. private _effectiveTarget;
  33988. private _property;
  33989. /**
  33990. * Instantiate the action
  33991. * @param triggerOptions defines the trigger options
  33992. * @param target defines the object containing the value to interpolate
  33993. * @param propertyPath defines the path to the property in the target object
  33994. * @param value defines the target value at the end of the interpolation
  33995. * @param duration deines the time it will take for the property to interpolate to the value.
  33996. * @param condition defines the trigger related conditions
  33997. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33998. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33999. */
  34000. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34001. /** @hidden */
  34002. _prepare(): void;
  34003. /**
  34004. * Execute the action starts the value interpolation.
  34005. */
  34006. execute(): void;
  34007. /**
  34008. * Serializes the actions and its related information.
  34009. * @param parent defines the object to serialize in
  34010. * @returns the serialized object
  34011. */
  34012. serialize(parent: any): any;
  34013. }
  34014. }
  34015. declare module "babylonjs/Actions/index" {
  34016. export * from "babylonjs/Actions/action";
  34017. export * from "babylonjs/Actions/actionEvent";
  34018. export * from "babylonjs/Actions/actionManager";
  34019. export * from "babylonjs/Actions/condition";
  34020. export * from "babylonjs/Actions/directActions";
  34021. export * from "babylonjs/Actions/directAudioActions";
  34022. export * from "babylonjs/Actions/interpolateValueAction";
  34023. }
  34024. declare module "babylonjs/Animations/index" {
  34025. export * from "babylonjs/Animations/animatable";
  34026. export * from "babylonjs/Animations/animation";
  34027. export * from "babylonjs/Animations/animationGroup";
  34028. export * from "babylonjs/Animations/animationPropertiesOverride";
  34029. export * from "babylonjs/Animations/easing";
  34030. export * from "babylonjs/Animations/runtimeAnimation";
  34031. export * from "babylonjs/Animations/animationEvent";
  34032. export * from "babylonjs/Animations/animationGroup";
  34033. export * from "babylonjs/Animations/animationKey";
  34034. export * from "babylonjs/Animations/animationRange";
  34035. }
  34036. declare module "babylonjs/Audio/soundTrack" {
  34037. import { Sound } from "babylonjs/Audio/sound";
  34038. import { Analyser } from "babylonjs/Audio/analyser";
  34039. import { Scene } from "babylonjs/scene";
  34040. /**
  34041. * Options allowed during the creation of a sound track.
  34042. */
  34043. export interface ISoundTrackOptions {
  34044. /**
  34045. * The volume the sound track should take during creation
  34046. */
  34047. volume?: number;
  34048. /**
  34049. * Define if the sound track is the main sound track of the scene
  34050. */
  34051. mainTrack?: boolean;
  34052. }
  34053. /**
  34054. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34055. * It will be also used in a future release to apply effects on a specific track.
  34056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34057. */
  34058. export class SoundTrack {
  34059. /**
  34060. * The unique identifier of the sound track in the scene.
  34061. */
  34062. id: number;
  34063. /**
  34064. * The list of sounds included in the sound track.
  34065. */
  34066. soundCollection: Array<Sound>;
  34067. private _outputAudioNode;
  34068. private _scene;
  34069. private _isMainTrack;
  34070. private _connectedAnalyser;
  34071. private _options;
  34072. private _isInitialized;
  34073. /**
  34074. * Creates a new sound track.
  34075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34076. * @param scene Define the scene the sound track belongs to
  34077. * @param options
  34078. */
  34079. constructor(scene: Scene, options?: ISoundTrackOptions);
  34080. private _initializeSoundTrackAudioGraph;
  34081. /**
  34082. * Release the sound track and its associated resources
  34083. */
  34084. dispose(): void;
  34085. /**
  34086. * Adds a sound to this sound track
  34087. * @param sound define the cound to add
  34088. * @ignoreNaming
  34089. */
  34090. AddSound(sound: Sound): void;
  34091. /**
  34092. * Removes a sound to this sound track
  34093. * @param sound define the cound to remove
  34094. * @ignoreNaming
  34095. */
  34096. RemoveSound(sound: Sound): void;
  34097. /**
  34098. * Set a global volume for the full sound track.
  34099. * @param newVolume Define the new volume of the sound track
  34100. */
  34101. setVolume(newVolume: number): void;
  34102. /**
  34103. * Switch the panning model to HRTF:
  34104. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34106. */
  34107. switchPanningModelToHRTF(): void;
  34108. /**
  34109. * Switch the panning model to Equal Power:
  34110. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34112. */
  34113. switchPanningModelToEqualPower(): void;
  34114. /**
  34115. * Connect the sound track to an audio analyser allowing some amazing
  34116. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34118. * @param analyser The analyser to connect to the engine
  34119. */
  34120. connectToAnalyser(analyser: Analyser): void;
  34121. }
  34122. }
  34123. declare module "babylonjs/Audio/audioSceneComponent" {
  34124. import { Sound } from "babylonjs/Audio/sound";
  34125. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34126. import { Nullable } from "babylonjs/types";
  34127. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34128. import { Scene } from "babylonjs/scene";
  34129. import { AbstractScene } from "babylonjs/abstractScene";
  34130. module "babylonjs/abstractScene" {
  34131. interface AbstractScene {
  34132. /**
  34133. * The list of sounds used in the scene.
  34134. */
  34135. sounds: Nullable<Array<Sound>>;
  34136. }
  34137. }
  34138. module "babylonjs/scene" {
  34139. interface Scene {
  34140. /**
  34141. * @hidden
  34142. * Backing field
  34143. */
  34144. _mainSoundTrack: SoundTrack;
  34145. /**
  34146. * The main sound track played by the scene.
  34147. * It cotains your primary collection of sounds.
  34148. */
  34149. mainSoundTrack: SoundTrack;
  34150. /**
  34151. * The list of sound tracks added to the scene
  34152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34153. */
  34154. soundTracks: Nullable<Array<SoundTrack>>;
  34155. /**
  34156. * Gets a sound using a given name
  34157. * @param name defines the name to search for
  34158. * @return the found sound or null if not found at all.
  34159. */
  34160. getSoundByName(name: string): Nullable<Sound>;
  34161. /**
  34162. * Gets or sets if audio support is enabled
  34163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34164. */
  34165. audioEnabled: boolean;
  34166. /**
  34167. * Gets or sets if audio will be output to headphones
  34168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34169. */
  34170. headphone: boolean;
  34171. }
  34172. }
  34173. /**
  34174. * Defines the sound scene component responsible to manage any sounds
  34175. * in a given scene.
  34176. */
  34177. export class AudioSceneComponent implements ISceneSerializableComponent {
  34178. /**
  34179. * The component name helpfull to identify the component in the list of scene components.
  34180. */
  34181. readonly name: string;
  34182. /**
  34183. * The scene the component belongs to.
  34184. */
  34185. scene: Scene;
  34186. private _audioEnabled;
  34187. /**
  34188. * Gets whether audio is enabled or not.
  34189. * Please use related enable/disable method to switch state.
  34190. */
  34191. readonly audioEnabled: boolean;
  34192. private _headphone;
  34193. /**
  34194. * Gets whether audio is outputing to headphone or not.
  34195. * Please use the according Switch methods to change output.
  34196. */
  34197. readonly headphone: boolean;
  34198. /**
  34199. * Creates a new instance of the component for the given scene
  34200. * @param scene Defines the scene to register the component in
  34201. */
  34202. constructor(scene: Scene);
  34203. /**
  34204. * Registers the component in a given scene
  34205. */
  34206. register(): void;
  34207. /**
  34208. * Rebuilds the elements related to this component in case of
  34209. * context lost for instance.
  34210. */
  34211. rebuild(): void;
  34212. /**
  34213. * Serializes the component data to the specified json object
  34214. * @param serializationObject The object to serialize to
  34215. */
  34216. serialize(serializationObject: any): void;
  34217. /**
  34218. * Adds all the element from the container to the scene
  34219. * @param container the container holding the elements
  34220. */
  34221. addFromContainer(container: AbstractScene): void;
  34222. /**
  34223. * Removes all the elements in the container from the scene
  34224. * @param container contains the elements to remove
  34225. */
  34226. removeFromContainer(container: AbstractScene): void;
  34227. /**
  34228. * Disposes the component and the associated ressources.
  34229. */
  34230. dispose(): void;
  34231. /**
  34232. * Disables audio in the associated scene.
  34233. */
  34234. disableAudio(): void;
  34235. /**
  34236. * Enables audio in the associated scene.
  34237. */
  34238. enableAudio(): void;
  34239. /**
  34240. * Switch audio to headphone output.
  34241. */
  34242. switchAudioModeForHeadphones(): void;
  34243. /**
  34244. * Switch audio to normal speakers.
  34245. */
  34246. switchAudioModeForNormalSpeakers(): void;
  34247. private _afterRender;
  34248. }
  34249. }
  34250. declare module "babylonjs/Audio/weightedsound" {
  34251. import { Sound } from "babylonjs/Audio/sound";
  34252. /**
  34253. * Wraps one or more Sound objects and selects one with random weight for playback.
  34254. */
  34255. export class WeightedSound {
  34256. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34257. loop: boolean;
  34258. private _coneInnerAngle;
  34259. private _coneOuterAngle;
  34260. private _volume;
  34261. /** A Sound is currently playing. */
  34262. isPlaying: boolean;
  34263. /** A Sound is currently paused. */
  34264. isPaused: boolean;
  34265. private _sounds;
  34266. private _weights;
  34267. private _currentIndex?;
  34268. /**
  34269. * Creates a new WeightedSound from the list of sounds given.
  34270. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34271. * @param sounds Array of Sounds that will be selected from.
  34272. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34273. */
  34274. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34275. /**
  34276. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34277. */
  34278. /**
  34279. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34280. */
  34281. directionalConeInnerAngle: number;
  34282. /**
  34283. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34284. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34285. */
  34286. /**
  34287. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34288. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34289. */
  34290. directionalConeOuterAngle: number;
  34291. /**
  34292. * Playback volume.
  34293. */
  34294. /**
  34295. * Playback volume.
  34296. */
  34297. volume: number;
  34298. private _onended;
  34299. /**
  34300. * Suspend playback
  34301. */
  34302. pause(): void;
  34303. /**
  34304. * Stop playback
  34305. */
  34306. stop(): void;
  34307. /**
  34308. * Start playback.
  34309. * @param startOffset Position the clip head at a specific time in seconds.
  34310. */
  34311. play(startOffset?: number): void;
  34312. }
  34313. }
  34314. declare module "babylonjs/Audio/index" {
  34315. export * from "babylonjs/Audio/analyser";
  34316. export * from "babylonjs/Audio/audioEngine";
  34317. export * from "babylonjs/Audio/audioSceneComponent";
  34318. export * from "babylonjs/Audio/sound";
  34319. export * from "babylonjs/Audio/soundTrack";
  34320. export * from "babylonjs/Audio/weightedsound";
  34321. }
  34322. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34323. import { Behavior } from "babylonjs/Behaviors/behavior";
  34324. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34325. import { BackEase } from "babylonjs/Animations/easing";
  34326. /**
  34327. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34329. */
  34330. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34331. /**
  34332. * Gets the name of the behavior.
  34333. */
  34334. readonly name: string;
  34335. /**
  34336. * The easing function used by animations
  34337. */
  34338. static EasingFunction: BackEase;
  34339. /**
  34340. * The easing mode used by animations
  34341. */
  34342. static EasingMode: number;
  34343. /**
  34344. * The duration of the animation, in milliseconds
  34345. */
  34346. transitionDuration: number;
  34347. /**
  34348. * Length of the distance animated by the transition when lower radius is reached
  34349. */
  34350. lowerRadiusTransitionRange: number;
  34351. /**
  34352. * Length of the distance animated by the transition when upper radius is reached
  34353. */
  34354. upperRadiusTransitionRange: number;
  34355. private _autoTransitionRange;
  34356. /**
  34357. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34358. */
  34359. /**
  34360. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34361. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34362. */
  34363. autoTransitionRange: boolean;
  34364. private _attachedCamera;
  34365. private _onAfterCheckInputsObserver;
  34366. private _onMeshTargetChangedObserver;
  34367. /**
  34368. * Initializes the behavior.
  34369. */
  34370. init(): void;
  34371. /**
  34372. * Attaches the behavior to its arc rotate camera.
  34373. * @param camera Defines the camera to attach the behavior to
  34374. */
  34375. attach(camera: ArcRotateCamera): void;
  34376. /**
  34377. * Detaches the behavior from its current arc rotate camera.
  34378. */
  34379. detach(): void;
  34380. private _radiusIsAnimating;
  34381. private _radiusBounceTransition;
  34382. private _animatables;
  34383. private _cachedWheelPrecision;
  34384. /**
  34385. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34386. * @param radiusLimit The limit to check against.
  34387. * @return Bool to indicate if at limit.
  34388. */
  34389. private _isRadiusAtLimit;
  34390. /**
  34391. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34392. * @param radiusDelta The delta by which to animate to. Can be negative.
  34393. */
  34394. private _applyBoundRadiusAnimation;
  34395. /**
  34396. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34397. */
  34398. protected _clearAnimationLocks(): void;
  34399. /**
  34400. * Stops and removes all animations that have been applied to the camera
  34401. */
  34402. stopAllAnimations(): void;
  34403. }
  34404. }
  34405. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34406. import { Behavior } from "babylonjs/Behaviors/behavior";
  34407. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34408. import { ExponentialEase } from "babylonjs/Animations/easing";
  34409. import { Nullable } from "babylonjs/types";
  34410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34411. import { Vector3 } from "babylonjs/Maths/math";
  34412. /**
  34413. * 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.
  34414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34415. */
  34416. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34417. /**
  34418. * Gets the name of the behavior.
  34419. */
  34420. readonly name: string;
  34421. private _mode;
  34422. private _radiusScale;
  34423. private _positionScale;
  34424. private _defaultElevation;
  34425. private _elevationReturnTime;
  34426. private _elevationReturnWaitTime;
  34427. private _zoomStopsAnimation;
  34428. private _framingTime;
  34429. /**
  34430. * The easing function used by animations
  34431. */
  34432. static EasingFunction: ExponentialEase;
  34433. /**
  34434. * The easing mode used by animations
  34435. */
  34436. static EasingMode: number;
  34437. /**
  34438. * Sets the current mode used by the behavior
  34439. */
  34440. /**
  34441. * Gets current mode used by the behavior.
  34442. */
  34443. mode: number;
  34444. /**
  34445. * Sets the scale applied to the radius (1 by default)
  34446. */
  34447. /**
  34448. * Gets the scale applied to the radius
  34449. */
  34450. radiusScale: number;
  34451. /**
  34452. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34453. */
  34454. /**
  34455. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34456. */
  34457. positionScale: number;
  34458. /**
  34459. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34460. * behaviour is triggered, in radians.
  34461. */
  34462. /**
  34463. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34464. * behaviour is triggered, in radians.
  34465. */
  34466. defaultElevation: number;
  34467. /**
  34468. * Sets the time (in milliseconds) taken to return to the default beta position.
  34469. * Negative value indicates camera should not return to default.
  34470. */
  34471. /**
  34472. * Gets the time (in milliseconds) taken to return to the default beta position.
  34473. * Negative value indicates camera should not return to default.
  34474. */
  34475. elevationReturnTime: number;
  34476. /**
  34477. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34478. */
  34479. /**
  34480. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34481. */
  34482. elevationReturnWaitTime: number;
  34483. /**
  34484. * Sets the flag that indicates if user zooming should stop animation.
  34485. */
  34486. /**
  34487. * Gets the flag that indicates if user zooming should stop animation.
  34488. */
  34489. zoomStopsAnimation: boolean;
  34490. /**
  34491. * Sets the transition time when framing the mesh, in milliseconds
  34492. */
  34493. /**
  34494. * Gets the transition time when framing the mesh, in milliseconds
  34495. */
  34496. framingTime: number;
  34497. /**
  34498. * Define if the behavior should automatically change the configured
  34499. * camera limits and sensibilities.
  34500. */
  34501. autoCorrectCameraLimitsAndSensibility: boolean;
  34502. private _onPrePointerObservableObserver;
  34503. private _onAfterCheckInputsObserver;
  34504. private _onMeshTargetChangedObserver;
  34505. private _attachedCamera;
  34506. private _isPointerDown;
  34507. private _lastInteractionTime;
  34508. /**
  34509. * Initializes the behavior.
  34510. */
  34511. init(): void;
  34512. /**
  34513. * Attaches the behavior to its arc rotate camera.
  34514. * @param camera Defines the camera to attach the behavior to
  34515. */
  34516. attach(camera: ArcRotateCamera): void;
  34517. /**
  34518. * Detaches the behavior from its current arc rotate camera.
  34519. */
  34520. detach(): void;
  34521. private _animatables;
  34522. private _betaIsAnimating;
  34523. private _betaTransition;
  34524. private _radiusTransition;
  34525. private _vectorTransition;
  34526. /**
  34527. * Targets the given mesh and updates zoom level accordingly.
  34528. * @param mesh The mesh to target.
  34529. * @param radius Optional. If a cached radius position already exists, overrides default.
  34530. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34533. */
  34534. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34535. /**
  34536. * Targets the given mesh with its children and updates zoom level accordingly.
  34537. * @param mesh The mesh to target.
  34538. * @param radius Optional. If a cached radius position already exists, overrides default.
  34539. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34542. */
  34543. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34544. /**
  34545. * Targets the given meshes with their children and updates zoom level accordingly.
  34546. * @param meshes The mesh to target.
  34547. * @param radius Optional. If a cached radius position already exists, overrides default.
  34548. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34551. */
  34552. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34553. /**
  34554. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34555. * @param minimumWorld Determines the smaller position of the bounding box extend
  34556. * @param maximumWorld Determines the bigger position of the bounding box extend
  34557. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34558. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34559. */
  34560. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34561. /**
  34562. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34563. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34564. * frustum width.
  34565. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34566. * to fully enclose the mesh in the viewing frustum.
  34567. */
  34568. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34569. /**
  34570. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34571. * is automatically returned to its default position (expected to be above ground plane).
  34572. */
  34573. private _maintainCameraAboveGround;
  34574. /**
  34575. * Returns the frustum slope based on the canvas ratio and camera FOV
  34576. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34577. */
  34578. private _getFrustumSlope;
  34579. /**
  34580. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34581. */
  34582. private _clearAnimationLocks;
  34583. /**
  34584. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34585. */
  34586. private _applyUserInteraction;
  34587. /**
  34588. * Stops and removes all animations that have been applied to the camera
  34589. */
  34590. stopAllAnimations(): void;
  34591. /**
  34592. * Gets a value indicating if the user is moving the camera
  34593. */
  34594. readonly isUserIsMoving: boolean;
  34595. /**
  34596. * The camera can move all the way towards the mesh.
  34597. */
  34598. static IgnoreBoundsSizeMode: number;
  34599. /**
  34600. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34601. */
  34602. static FitFrustumSidesMode: number;
  34603. }
  34604. }
  34605. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34606. import { Nullable } from "babylonjs/types";
  34607. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34609. /**
  34610. * Manage the pointers inputs to control an arc rotate camera.
  34611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34612. */
  34613. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34614. /**
  34615. * Defines the camera the input is attached to.
  34616. */
  34617. camera: ArcRotateCamera;
  34618. /**
  34619. * Defines the buttons associated with the input to handle camera move.
  34620. */
  34621. buttons: number[];
  34622. /**
  34623. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34624. */
  34625. angularSensibilityX: number;
  34626. /**
  34627. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34628. */
  34629. angularSensibilityY: number;
  34630. /**
  34631. * Defines the pointer pinch precision or how fast is the camera zooming.
  34632. */
  34633. pinchPrecision: number;
  34634. /**
  34635. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34636. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34637. */
  34638. pinchDeltaPercentage: number;
  34639. /**
  34640. * Defines the pointer panning sensibility or how fast is the camera moving.
  34641. */
  34642. panningSensibility: number;
  34643. /**
  34644. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34645. */
  34646. multiTouchPanning: boolean;
  34647. /**
  34648. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34649. */
  34650. multiTouchPanAndZoom: boolean;
  34651. /**
  34652. * Revers pinch action direction.
  34653. */
  34654. pinchInwards: boolean;
  34655. private _isPanClick;
  34656. private _pointerInput;
  34657. private _observer;
  34658. private _onMouseMove;
  34659. private _onGestureStart;
  34660. private _onGesture;
  34661. private _MSGestureHandler;
  34662. private _onLostFocus;
  34663. private _onContextMenu;
  34664. /**
  34665. * Attach the input controls to a specific dom element to get the input from.
  34666. * @param element Defines the element the controls should be listened from
  34667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34668. */
  34669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34670. /**
  34671. * Detach the current controls from the specified dom element.
  34672. * @param element Defines the element to stop listening the inputs from
  34673. */
  34674. detachControl(element: Nullable<HTMLElement>): void;
  34675. /**
  34676. * Gets the class name of the current intput.
  34677. * @returns the class name
  34678. */
  34679. getClassName(): string;
  34680. /**
  34681. * Get the friendly name associated with the input class.
  34682. * @returns the input friendly name
  34683. */
  34684. getSimpleName(): string;
  34685. }
  34686. }
  34687. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34688. import { Nullable } from "babylonjs/types";
  34689. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34690. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34691. /**
  34692. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34694. */
  34695. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34696. /**
  34697. * Defines the camera the input is attached to.
  34698. */
  34699. camera: ArcRotateCamera;
  34700. /**
  34701. * Defines the list of key codes associated with the up action (increase alpha)
  34702. */
  34703. keysUp: number[];
  34704. /**
  34705. * Defines the list of key codes associated with the down action (decrease alpha)
  34706. */
  34707. keysDown: number[];
  34708. /**
  34709. * Defines the list of key codes associated with the left action (increase beta)
  34710. */
  34711. keysLeft: number[];
  34712. /**
  34713. * Defines the list of key codes associated with the right action (decrease beta)
  34714. */
  34715. keysRight: number[];
  34716. /**
  34717. * Defines the list of key codes associated with the reset action.
  34718. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34719. */
  34720. keysReset: number[];
  34721. /**
  34722. * Defines the panning sensibility of the inputs.
  34723. * (How fast is the camera paning)
  34724. */
  34725. panningSensibility: number;
  34726. /**
  34727. * Defines the zooming sensibility of the inputs.
  34728. * (How fast is the camera zooming)
  34729. */
  34730. zoomingSensibility: number;
  34731. /**
  34732. * Defines wether maintaining the alt key down switch the movement mode from
  34733. * orientation to zoom.
  34734. */
  34735. useAltToZoom: boolean;
  34736. /**
  34737. * Rotation speed of the camera
  34738. */
  34739. angularSpeed: number;
  34740. private _keys;
  34741. private _ctrlPressed;
  34742. private _altPressed;
  34743. private _onCanvasBlurObserver;
  34744. private _onKeyboardObserver;
  34745. private _engine;
  34746. private _scene;
  34747. /**
  34748. * Attach the input controls to a specific dom element to get the input from.
  34749. * @param element Defines the element the controls should be listened from
  34750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34751. */
  34752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34753. /**
  34754. * Detach the current controls from the specified dom element.
  34755. * @param element Defines the element to stop listening the inputs from
  34756. */
  34757. detachControl(element: Nullable<HTMLElement>): void;
  34758. /**
  34759. * Update the current camera state depending on the inputs that have been used this frame.
  34760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34761. */
  34762. checkInputs(): void;
  34763. /**
  34764. * Gets the class name of the current intput.
  34765. * @returns the class name
  34766. */
  34767. getClassName(): string;
  34768. /**
  34769. * Get the friendly name associated with the input class.
  34770. * @returns the input friendly name
  34771. */
  34772. getSimpleName(): string;
  34773. }
  34774. }
  34775. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34776. import { Nullable } from "babylonjs/types";
  34777. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34778. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34779. /**
  34780. * Manage the mouse wheel inputs to control an arc rotate camera.
  34781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34782. */
  34783. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34784. /**
  34785. * Defines the camera the input is attached to.
  34786. */
  34787. camera: ArcRotateCamera;
  34788. /**
  34789. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34790. */
  34791. wheelPrecision: number;
  34792. /**
  34793. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34794. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34795. */
  34796. wheelDeltaPercentage: number;
  34797. private _wheel;
  34798. private _observer;
  34799. /**
  34800. * Attach the input controls to a specific dom element to get the input from.
  34801. * @param element Defines the element the controls should be listened from
  34802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34803. */
  34804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34805. /**
  34806. * Detach the current controls from the specified dom element.
  34807. * @param element Defines the element to stop listening the inputs from
  34808. */
  34809. detachControl(element: Nullable<HTMLElement>): void;
  34810. /**
  34811. * Gets the class name of the current intput.
  34812. * @returns the class name
  34813. */
  34814. getClassName(): string;
  34815. /**
  34816. * Get the friendly name associated with the input class.
  34817. * @returns the input friendly name
  34818. */
  34819. getSimpleName(): string;
  34820. }
  34821. }
  34822. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34824. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34825. /**
  34826. * Default Inputs manager for the ArcRotateCamera.
  34827. * It groups all the default supported inputs for ease of use.
  34828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34829. */
  34830. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34831. /**
  34832. * Instantiates a new ArcRotateCameraInputsManager.
  34833. * @param camera Defines the camera the inputs belong to
  34834. */
  34835. constructor(camera: ArcRotateCamera);
  34836. /**
  34837. * Add mouse wheel input support to the input manager.
  34838. * @returns the current input manager
  34839. */
  34840. addMouseWheel(): ArcRotateCameraInputsManager;
  34841. /**
  34842. * Add pointers input support to the input manager.
  34843. * @returns the current input manager
  34844. */
  34845. addPointers(): ArcRotateCameraInputsManager;
  34846. /**
  34847. * Add keyboard input support to the input manager.
  34848. * @returns the current input manager
  34849. */
  34850. addKeyboard(): ArcRotateCameraInputsManager;
  34851. }
  34852. }
  34853. declare module "babylonjs/Cameras/arcRotateCamera" {
  34854. import { Observable } from "babylonjs/Misc/observable";
  34855. import { Nullable } from "babylonjs/types";
  34856. import { Scene } from "babylonjs/scene";
  34857. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34859. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34860. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34861. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34862. import { Camera } from "babylonjs/Cameras/camera";
  34863. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34864. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34865. import { Collider } from "babylonjs/Collisions/collider";
  34866. /**
  34867. * This represents an orbital type of camera.
  34868. *
  34869. * 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.
  34870. * 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.
  34871. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34872. */
  34873. export class ArcRotateCamera extends TargetCamera {
  34874. /**
  34875. * Defines the rotation angle of the camera along the longitudinal axis.
  34876. */
  34877. alpha: number;
  34878. /**
  34879. * Defines the rotation angle of the camera along the latitudinal axis.
  34880. */
  34881. beta: number;
  34882. /**
  34883. * Defines the radius of the camera from it s target point.
  34884. */
  34885. radius: number;
  34886. protected _target: Vector3;
  34887. protected _targetHost: Nullable<AbstractMesh>;
  34888. /**
  34889. * Defines the target point of the camera.
  34890. * The camera looks towards it form the radius distance.
  34891. */
  34892. target: Vector3;
  34893. /**
  34894. * Current inertia value on the longitudinal axis.
  34895. * The bigger this number the longer it will take for the camera to stop.
  34896. */
  34897. inertialAlphaOffset: number;
  34898. /**
  34899. * Current inertia value on the latitudinal axis.
  34900. * The bigger this number the longer it will take for the camera to stop.
  34901. */
  34902. inertialBetaOffset: number;
  34903. /**
  34904. * Current inertia value on the radius axis.
  34905. * The bigger this number the longer it will take for the camera to stop.
  34906. */
  34907. inertialRadiusOffset: number;
  34908. /**
  34909. * Minimum allowed angle on the longitudinal axis.
  34910. * This can help limiting how the Camera is able to move in the scene.
  34911. */
  34912. lowerAlphaLimit: Nullable<number>;
  34913. /**
  34914. * Maximum allowed angle on the longitudinal axis.
  34915. * This can help limiting how the Camera is able to move in the scene.
  34916. */
  34917. upperAlphaLimit: Nullable<number>;
  34918. /**
  34919. * Minimum allowed angle on the latitudinal axis.
  34920. * This can help limiting how the Camera is able to move in the scene.
  34921. */
  34922. lowerBetaLimit: number;
  34923. /**
  34924. * Maximum allowed angle on the latitudinal axis.
  34925. * This can help limiting how the Camera is able to move in the scene.
  34926. */
  34927. upperBetaLimit: number;
  34928. /**
  34929. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34930. * This can help limiting how the Camera is able to move in the scene.
  34931. */
  34932. lowerRadiusLimit: Nullable<number>;
  34933. /**
  34934. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34935. * This can help limiting how the Camera is able to move in the scene.
  34936. */
  34937. upperRadiusLimit: Nullable<number>;
  34938. /**
  34939. * Defines the current inertia value used during panning of the camera along the X axis.
  34940. */
  34941. inertialPanningX: number;
  34942. /**
  34943. * Defines the current inertia value used during panning of the camera along the Y axis.
  34944. */
  34945. inertialPanningY: number;
  34946. /**
  34947. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34948. * Basically if your fingers moves away from more than this distance you will be considered
  34949. * in pinch mode.
  34950. */
  34951. pinchToPanMaxDistance: number;
  34952. /**
  34953. * Defines the maximum distance the camera can pan.
  34954. * This could help keeping the cammera always in your scene.
  34955. */
  34956. panningDistanceLimit: Nullable<number>;
  34957. /**
  34958. * Defines the target of the camera before paning.
  34959. */
  34960. panningOriginTarget: Vector3;
  34961. /**
  34962. * Defines the value of the inertia used during panning.
  34963. * 0 would mean stop inertia and one would mean no decelleration at all.
  34964. */
  34965. panningInertia: number;
  34966. /**
  34967. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34968. */
  34969. angularSensibilityX: number;
  34970. /**
  34971. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34972. */
  34973. angularSensibilityY: number;
  34974. /**
  34975. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34976. */
  34977. pinchPrecision: number;
  34978. /**
  34979. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34980. * It will be used instead of pinchDeltaPrecision if different from 0.
  34981. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34982. */
  34983. pinchDeltaPercentage: number;
  34984. /**
  34985. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34986. */
  34987. panningSensibility: number;
  34988. /**
  34989. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34990. */
  34991. keysUp: number[];
  34992. /**
  34993. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34994. */
  34995. keysDown: number[];
  34996. /**
  34997. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34998. */
  34999. keysLeft: number[];
  35000. /**
  35001. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35002. */
  35003. keysRight: number[];
  35004. /**
  35005. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35006. */
  35007. wheelPrecision: number;
  35008. /**
  35009. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35010. * It will be used instead of pinchDeltaPrecision if different from 0.
  35011. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35012. */
  35013. wheelDeltaPercentage: number;
  35014. /**
  35015. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35016. */
  35017. zoomOnFactor: number;
  35018. /**
  35019. * Defines a screen offset for the camera position.
  35020. */
  35021. targetScreenOffset: Vector2;
  35022. /**
  35023. * Allows the camera to be completely reversed.
  35024. * If false the camera can not arrive upside down.
  35025. */
  35026. allowUpsideDown: boolean;
  35027. /**
  35028. * Define if double tap/click is used to restore the previously saved state of the camera.
  35029. */
  35030. useInputToRestoreState: boolean;
  35031. /** @hidden */
  35032. _viewMatrix: Matrix;
  35033. /** @hidden */
  35034. _useCtrlForPanning: boolean;
  35035. /** @hidden */
  35036. _panningMouseButton: number;
  35037. /**
  35038. * Defines the input associated to the camera.
  35039. */
  35040. inputs: ArcRotateCameraInputsManager;
  35041. /** @hidden */
  35042. _reset: () => void;
  35043. /**
  35044. * Defines the allowed panning axis.
  35045. */
  35046. panningAxis: Vector3;
  35047. protected _localDirection: Vector3;
  35048. protected _transformedDirection: Vector3;
  35049. private _bouncingBehavior;
  35050. /**
  35051. * Gets the bouncing behavior of the camera if it has been enabled.
  35052. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35053. */
  35054. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35055. /**
  35056. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35057. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35058. */
  35059. useBouncingBehavior: boolean;
  35060. private _framingBehavior;
  35061. /**
  35062. * Gets the framing behavior of the camera if it has been enabled.
  35063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35064. */
  35065. readonly framingBehavior: Nullable<FramingBehavior>;
  35066. /**
  35067. * Defines if the framing behavior of the camera is enabled on the camera.
  35068. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35069. */
  35070. useFramingBehavior: boolean;
  35071. private _autoRotationBehavior;
  35072. /**
  35073. * Gets the auto rotation behavior of the camera if it has been enabled.
  35074. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35075. */
  35076. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35077. /**
  35078. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35080. */
  35081. useAutoRotationBehavior: boolean;
  35082. /**
  35083. * Observable triggered when the mesh target has been changed on the camera.
  35084. */
  35085. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35086. /**
  35087. * Event raised when the camera is colliding with a mesh.
  35088. */
  35089. onCollide: (collidedMesh: AbstractMesh) => void;
  35090. /**
  35091. * Defines whether the camera should check collision with the objects oh the scene.
  35092. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35093. */
  35094. checkCollisions: boolean;
  35095. /**
  35096. * Defines the collision radius of the camera.
  35097. * This simulates a sphere around the camera.
  35098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35099. */
  35100. collisionRadius: Vector3;
  35101. protected _collider: Collider;
  35102. protected _previousPosition: Vector3;
  35103. protected _collisionVelocity: Vector3;
  35104. protected _newPosition: Vector3;
  35105. protected _previousAlpha: number;
  35106. protected _previousBeta: number;
  35107. protected _previousRadius: number;
  35108. protected _collisionTriggered: boolean;
  35109. protected _targetBoundingCenter: Nullable<Vector3>;
  35110. private _computationVector;
  35111. private _tempAxisVector;
  35112. private _tempAxisRotationMatrix;
  35113. /**
  35114. * Instantiates a new ArcRotateCamera in a given scene
  35115. * @param name Defines the name of the camera
  35116. * @param alpha Defines the camera rotation along the logitudinal axis
  35117. * @param beta Defines the camera rotation along the latitudinal axis
  35118. * @param radius Defines the camera distance from its target
  35119. * @param target Defines the camera target
  35120. * @param scene Defines the scene the camera belongs to
  35121. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35122. */
  35123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35124. /** @hidden */
  35125. _initCache(): void;
  35126. /** @hidden */
  35127. _updateCache(ignoreParentClass?: boolean): void;
  35128. protected _getTargetPosition(): Vector3;
  35129. private _storedAlpha;
  35130. private _storedBeta;
  35131. private _storedRadius;
  35132. private _storedTarget;
  35133. /**
  35134. * Stores the current state of the camera (alpha, beta, radius and target)
  35135. * @returns the camera itself
  35136. */
  35137. storeState(): Camera;
  35138. /**
  35139. * @hidden
  35140. * Restored camera state. You must call storeState() first
  35141. */
  35142. _restoreStateValues(): boolean;
  35143. /** @hidden */
  35144. _isSynchronizedViewMatrix(): boolean;
  35145. /**
  35146. * Attached controls to the current camera.
  35147. * @param element Defines the element the controls should be listened from
  35148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35149. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35150. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35151. */
  35152. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35153. /**
  35154. * Detach the current controls from the camera.
  35155. * The camera will stop reacting to inputs.
  35156. * @param element Defines the element to stop listening the inputs from
  35157. */
  35158. detachControl(element: HTMLElement): void;
  35159. /** @hidden */
  35160. _checkInputs(): void;
  35161. protected _checkLimits(): void;
  35162. /**
  35163. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35164. */
  35165. rebuildAnglesAndRadius(): void;
  35166. /**
  35167. * Use a position to define the current camera related information like aplha, beta and radius
  35168. * @param position Defines the position to set the camera at
  35169. */
  35170. setPosition(position: Vector3): void;
  35171. /**
  35172. * Defines the target the camera should look at.
  35173. * This will automatically adapt alpha beta and radius to fit within the new target.
  35174. * @param target Defines the new target as a Vector or a mesh
  35175. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35176. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35177. */
  35178. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35179. /** @hidden */
  35180. _getViewMatrix(): Matrix;
  35181. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35182. /**
  35183. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35184. * @param meshes Defines the mesh to zoom on
  35185. * @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)
  35186. */
  35187. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35188. /**
  35189. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35190. * The target will be changed but the radius
  35191. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35192. * @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)
  35193. */
  35194. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35195. min: Vector3;
  35196. max: Vector3;
  35197. distance: number;
  35198. }, doNotUpdateMaxZ?: boolean): void;
  35199. /**
  35200. * @override
  35201. * Override Camera.createRigCamera
  35202. */
  35203. createRigCamera(name: string, cameraIndex: number): Camera;
  35204. /**
  35205. * @hidden
  35206. * @override
  35207. * Override Camera._updateRigCameras
  35208. */
  35209. _updateRigCameras(): void;
  35210. /**
  35211. * Destroy the camera and release the current resources hold by it.
  35212. */
  35213. dispose(): void;
  35214. /**
  35215. * Gets the current object class name.
  35216. * @return the class name
  35217. */
  35218. getClassName(): string;
  35219. }
  35220. }
  35221. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35222. import { Behavior } from "babylonjs/Behaviors/behavior";
  35223. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35224. /**
  35225. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35227. */
  35228. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35229. /**
  35230. * Gets the name of the behavior.
  35231. */
  35232. readonly name: string;
  35233. private _zoomStopsAnimation;
  35234. private _idleRotationSpeed;
  35235. private _idleRotationWaitTime;
  35236. private _idleRotationSpinupTime;
  35237. /**
  35238. * Sets the flag that indicates if user zooming should stop animation.
  35239. */
  35240. /**
  35241. * Gets the flag that indicates if user zooming should stop animation.
  35242. */
  35243. zoomStopsAnimation: boolean;
  35244. /**
  35245. * Sets the default speed at which the camera rotates around the model.
  35246. */
  35247. /**
  35248. * Gets the default speed at which the camera rotates around the model.
  35249. */
  35250. idleRotationSpeed: number;
  35251. /**
  35252. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35253. */
  35254. /**
  35255. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35256. */
  35257. idleRotationWaitTime: number;
  35258. /**
  35259. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35260. */
  35261. /**
  35262. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35263. */
  35264. idleRotationSpinupTime: number;
  35265. /**
  35266. * Gets a value indicating if the camera is currently rotating because of this behavior
  35267. */
  35268. readonly rotationInProgress: boolean;
  35269. private _onPrePointerObservableObserver;
  35270. private _onAfterCheckInputsObserver;
  35271. private _attachedCamera;
  35272. private _isPointerDown;
  35273. private _lastFrameTime;
  35274. private _lastInteractionTime;
  35275. private _cameraRotationSpeed;
  35276. /**
  35277. * Initializes the behavior.
  35278. */
  35279. init(): void;
  35280. /**
  35281. * Attaches the behavior to its arc rotate camera.
  35282. * @param camera Defines the camera to attach the behavior to
  35283. */
  35284. attach(camera: ArcRotateCamera): void;
  35285. /**
  35286. * Detaches the behavior from its current arc rotate camera.
  35287. */
  35288. detach(): void;
  35289. /**
  35290. * Returns true if user is scrolling.
  35291. * @return true if user is scrolling.
  35292. */
  35293. private _userIsZooming;
  35294. private _lastFrameRadius;
  35295. private _shouldAnimationStopForInteraction;
  35296. /**
  35297. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35298. */
  35299. private _applyUserInteraction;
  35300. private _userIsMoving;
  35301. }
  35302. }
  35303. declare module "babylonjs/Behaviors/Cameras/index" {
  35304. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35305. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35306. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35307. }
  35308. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35309. import { Mesh } from "babylonjs/Meshes/mesh";
  35310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35311. import { Behavior } from "babylonjs/Behaviors/behavior";
  35312. /**
  35313. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35314. */
  35315. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35316. private ui;
  35317. /**
  35318. * The name of the behavior
  35319. */
  35320. name: string;
  35321. /**
  35322. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35323. */
  35324. distanceAwayFromFace: number;
  35325. /**
  35326. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35327. */
  35328. distanceAwayFromBottomOfFace: number;
  35329. private _faceVectors;
  35330. private _target;
  35331. private _scene;
  35332. private _onRenderObserver;
  35333. private _tmpMatrix;
  35334. private _tmpVector;
  35335. /**
  35336. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35337. * @param ui The transform node that should be attched to the mesh
  35338. */
  35339. constructor(ui: TransformNode);
  35340. /**
  35341. * Initializes the behavior
  35342. */
  35343. init(): void;
  35344. private _closestFace;
  35345. private _zeroVector;
  35346. private _lookAtTmpMatrix;
  35347. private _lookAtToRef;
  35348. /**
  35349. * Attaches the AttachToBoxBehavior to the passed in mesh
  35350. * @param target The mesh that the specified node will be attached to
  35351. */
  35352. attach(target: Mesh): void;
  35353. /**
  35354. * Detaches the behavior from the mesh
  35355. */
  35356. detach(): void;
  35357. }
  35358. }
  35359. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35360. import { Behavior } from "babylonjs/Behaviors/behavior";
  35361. import { Mesh } from "babylonjs/Meshes/mesh";
  35362. /**
  35363. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35364. */
  35365. export class FadeInOutBehavior implements Behavior<Mesh> {
  35366. /**
  35367. * Time in milliseconds to delay before fading in (Default: 0)
  35368. */
  35369. delay: number;
  35370. /**
  35371. * Time in milliseconds for the mesh to fade in (Default: 300)
  35372. */
  35373. fadeInTime: number;
  35374. private _millisecondsPerFrame;
  35375. private _hovered;
  35376. private _hoverValue;
  35377. private _ownerNode;
  35378. /**
  35379. * Instatiates the FadeInOutBehavior
  35380. */
  35381. constructor();
  35382. /**
  35383. * The name of the behavior
  35384. */
  35385. readonly name: string;
  35386. /**
  35387. * Initializes the behavior
  35388. */
  35389. init(): void;
  35390. /**
  35391. * Attaches the fade behavior on the passed in mesh
  35392. * @param ownerNode The mesh that will be faded in/out once attached
  35393. */
  35394. attach(ownerNode: Mesh): void;
  35395. /**
  35396. * Detaches the behavior from the mesh
  35397. */
  35398. detach(): void;
  35399. /**
  35400. * Triggers the mesh to begin fading in or out
  35401. * @param value if the object should fade in or out (true to fade in)
  35402. */
  35403. fadeIn(value: boolean): void;
  35404. private _update;
  35405. private _setAllVisibility;
  35406. }
  35407. }
  35408. declare module "babylonjs/Misc/pivotTools" {
  35409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35410. /**
  35411. * Class containing a set of static utilities functions for managing Pivots
  35412. * @hidden
  35413. */
  35414. export class PivotTools {
  35415. private static _PivotCached;
  35416. private static _OldPivotPoint;
  35417. private static _PivotTranslation;
  35418. private static _PivotTmpVector;
  35419. /** @hidden */
  35420. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35421. /** @hidden */
  35422. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35423. }
  35424. }
  35425. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35426. import { Scene } from "babylonjs/scene";
  35427. import { Vector4, Plane } from "babylonjs/Maths/math";
  35428. import { Mesh } from "babylonjs/Meshes/mesh";
  35429. /**
  35430. * Class containing static functions to help procedurally build meshes
  35431. */
  35432. export class PlaneBuilder {
  35433. /**
  35434. * Creates a plane mesh
  35435. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35436. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35437. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35441. * @param name defines the name of the mesh
  35442. * @param options defines the options used to create the mesh
  35443. * @param scene defines the hosting scene
  35444. * @returns the plane mesh
  35445. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35446. */
  35447. static CreatePlane(name: string, options: {
  35448. size?: number;
  35449. width?: number;
  35450. height?: number;
  35451. sideOrientation?: number;
  35452. frontUVs?: Vector4;
  35453. backUVs?: Vector4;
  35454. updatable?: boolean;
  35455. sourcePlane?: Plane;
  35456. }, scene: Scene): Mesh;
  35457. }
  35458. }
  35459. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35460. import { Behavior } from "babylonjs/Behaviors/behavior";
  35461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35462. import { Observable } from "babylonjs/Misc/observable";
  35463. import { Vector3 } from "babylonjs/Maths/math";
  35464. import { Ray } from "babylonjs/Culling/ray";
  35465. import "babylonjs/Meshes/Builders/planeBuilder";
  35466. /**
  35467. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35468. */
  35469. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35470. private static _AnyMouseID;
  35471. private _attachedNode;
  35472. private _dragPlane;
  35473. private _scene;
  35474. private _pointerObserver;
  35475. private _beforeRenderObserver;
  35476. private static _planeScene;
  35477. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35478. /**
  35479. * 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)
  35480. */
  35481. maxDragAngle: number;
  35482. /**
  35483. * @hidden
  35484. */
  35485. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35486. /**
  35487. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35488. */
  35489. currentDraggingPointerID: number;
  35490. /**
  35491. * The last position where the pointer hit the drag plane in world space
  35492. */
  35493. lastDragPosition: Vector3;
  35494. /**
  35495. * If the behavior is currently in a dragging state
  35496. */
  35497. dragging: boolean;
  35498. /**
  35499. * 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)
  35500. */
  35501. dragDeltaRatio: number;
  35502. /**
  35503. * If the drag plane orientation should be updated during the dragging (Default: true)
  35504. */
  35505. updateDragPlane: boolean;
  35506. private _debugMode;
  35507. private _moving;
  35508. /**
  35509. * Fires each time the attached mesh is dragged with the pointer
  35510. * * delta between last drag position and current drag position in world space
  35511. * * dragDistance along the drag axis
  35512. * * dragPlaneNormal normal of the current drag plane used during the drag
  35513. * * dragPlanePoint in world space where the drag intersects the drag plane
  35514. */
  35515. onDragObservable: Observable<{
  35516. delta: Vector3;
  35517. dragPlanePoint: Vector3;
  35518. dragPlaneNormal: Vector3;
  35519. dragDistance: number;
  35520. pointerId: number;
  35521. }>;
  35522. /**
  35523. * Fires each time a drag begins (eg. mouse down on mesh)
  35524. */
  35525. onDragStartObservable: Observable<{
  35526. dragPlanePoint: Vector3;
  35527. pointerId: number;
  35528. }>;
  35529. /**
  35530. * Fires each time a drag ends (eg. mouse release after drag)
  35531. */
  35532. onDragEndObservable: Observable<{
  35533. dragPlanePoint: Vector3;
  35534. pointerId: number;
  35535. }>;
  35536. /**
  35537. * If the attached mesh should be moved when dragged
  35538. */
  35539. moveAttached: boolean;
  35540. /**
  35541. * If the drag behavior will react to drag events (Default: true)
  35542. */
  35543. enabled: boolean;
  35544. /**
  35545. * If camera controls should be detached during the drag
  35546. */
  35547. detachCameraControls: boolean;
  35548. /**
  35549. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35550. */
  35551. useObjectOrienationForDragging: boolean;
  35552. private _options;
  35553. /**
  35554. * Creates a pointer drag behavior that can be attached to a mesh
  35555. * @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)
  35556. */
  35557. constructor(options?: {
  35558. dragAxis?: Vector3;
  35559. dragPlaneNormal?: Vector3;
  35560. });
  35561. /**
  35562. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35563. */
  35564. validateDrag: (targetPosition: Vector3) => boolean;
  35565. /**
  35566. * The name of the behavior
  35567. */
  35568. readonly name: string;
  35569. /**
  35570. * Initializes the behavior
  35571. */
  35572. init(): void;
  35573. private _tmpVector;
  35574. private _alternatePickedPoint;
  35575. private _worldDragAxis;
  35576. private _targetPosition;
  35577. private _attachedElement;
  35578. /**
  35579. * Attaches the drag behavior the passed in mesh
  35580. * @param ownerNode The mesh that will be dragged around once attached
  35581. */
  35582. attach(ownerNode: AbstractMesh): void;
  35583. /**
  35584. * Force relase the drag action by code.
  35585. */
  35586. releaseDrag(): void;
  35587. private _startDragRay;
  35588. private _lastPointerRay;
  35589. /**
  35590. * Simulates the start of a pointer drag event on the behavior
  35591. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35592. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35593. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35594. */
  35595. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35596. private _startDrag;
  35597. private _dragDelta;
  35598. private _moveDrag;
  35599. private _pickWithRayOnDragPlane;
  35600. private _pointA;
  35601. private _pointB;
  35602. private _pointC;
  35603. private _lineA;
  35604. private _lineB;
  35605. private _localAxis;
  35606. private _lookAt;
  35607. private _updateDragPlanePosition;
  35608. /**
  35609. * Detaches the behavior from the mesh
  35610. */
  35611. detach(): void;
  35612. }
  35613. }
  35614. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35615. import { Mesh } from "babylonjs/Meshes/mesh";
  35616. import { Behavior } from "babylonjs/Behaviors/behavior";
  35617. /**
  35618. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35619. */
  35620. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35621. private _dragBehaviorA;
  35622. private _dragBehaviorB;
  35623. private _startDistance;
  35624. private _initialScale;
  35625. private _targetScale;
  35626. private _ownerNode;
  35627. private _sceneRenderObserver;
  35628. /**
  35629. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35630. */
  35631. constructor();
  35632. /**
  35633. * The name of the behavior
  35634. */
  35635. readonly name: string;
  35636. /**
  35637. * Initializes the behavior
  35638. */
  35639. init(): void;
  35640. private _getCurrentDistance;
  35641. /**
  35642. * Attaches the scale behavior the passed in mesh
  35643. * @param ownerNode The mesh that will be scaled around once attached
  35644. */
  35645. attach(ownerNode: Mesh): void;
  35646. /**
  35647. * Detaches the behavior from the mesh
  35648. */
  35649. detach(): void;
  35650. }
  35651. }
  35652. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35653. import { Behavior } from "babylonjs/Behaviors/behavior";
  35654. import { Mesh } from "babylonjs/Meshes/mesh";
  35655. import { Observable } from "babylonjs/Misc/observable";
  35656. /**
  35657. * 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
  35658. */
  35659. export class SixDofDragBehavior implements Behavior<Mesh> {
  35660. private static _virtualScene;
  35661. private _ownerNode;
  35662. private _sceneRenderObserver;
  35663. private _scene;
  35664. private _targetPosition;
  35665. private _virtualOriginMesh;
  35666. private _virtualDragMesh;
  35667. private _pointerObserver;
  35668. private _moving;
  35669. private _startingOrientation;
  35670. /**
  35671. * 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)
  35672. */
  35673. private zDragFactor;
  35674. /**
  35675. * If the object should rotate to face the drag origin
  35676. */
  35677. rotateDraggedObject: boolean;
  35678. /**
  35679. * If the behavior is currently in a dragging state
  35680. */
  35681. dragging: boolean;
  35682. /**
  35683. * 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)
  35684. */
  35685. dragDeltaRatio: number;
  35686. /**
  35687. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35688. */
  35689. currentDraggingPointerID: number;
  35690. /**
  35691. * If camera controls should be detached during the drag
  35692. */
  35693. detachCameraControls: boolean;
  35694. /**
  35695. * Fires each time a drag starts
  35696. */
  35697. onDragStartObservable: Observable<{}>;
  35698. /**
  35699. * Fires each time a drag ends (eg. mouse release after drag)
  35700. */
  35701. onDragEndObservable: Observable<{}>;
  35702. /**
  35703. * 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
  35704. */
  35705. constructor();
  35706. /**
  35707. * The name of the behavior
  35708. */
  35709. readonly name: string;
  35710. /**
  35711. * Initializes the behavior
  35712. */
  35713. init(): void;
  35714. /**
  35715. * Attaches the scale behavior the passed in mesh
  35716. * @param ownerNode The mesh that will be scaled around once attached
  35717. */
  35718. attach(ownerNode: Mesh): void;
  35719. /**
  35720. * Detaches the behavior from the mesh
  35721. */
  35722. detach(): void;
  35723. }
  35724. }
  35725. declare module "babylonjs/Behaviors/Meshes/index" {
  35726. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35727. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35728. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35729. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35730. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35731. }
  35732. declare module "babylonjs/Behaviors/index" {
  35733. export * from "babylonjs/Behaviors/behavior";
  35734. export * from "babylonjs/Behaviors/Cameras/index";
  35735. export * from "babylonjs/Behaviors/Meshes/index";
  35736. }
  35737. declare module "babylonjs/Bones/boneIKController" {
  35738. import { Bone } from "babylonjs/Bones/bone";
  35739. import { Vector3 } from "babylonjs/Maths/math";
  35740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35741. import { Nullable } from "babylonjs/types";
  35742. /**
  35743. * Class used to apply inverse kinematics to bones
  35744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35745. */
  35746. export class BoneIKController {
  35747. private static _tmpVecs;
  35748. private static _tmpQuat;
  35749. private static _tmpMats;
  35750. /**
  35751. * Gets or sets the target mesh
  35752. */
  35753. targetMesh: AbstractMesh;
  35754. /** Gets or sets the mesh used as pole */
  35755. poleTargetMesh: AbstractMesh;
  35756. /**
  35757. * Gets or sets the bone used as pole
  35758. */
  35759. poleTargetBone: Nullable<Bone>;
  35760. /**
  35761. * Gets or sets the target position
  35762. */
  35763. targetPosition: Vector3;
  35764. /**
  35765. * Gets or sets the pole target position
  35766. */
  35767. poleTargetPosition: Vector3;
  35768. /**
  35769. * Gets or sets the pole target local offset
  35770. */
  35771. poleTargetLocalOffset: Vector3;
  35772. /**
  35773. * Gets or sets the pole angle
  35774. */
  35775. poleAngle: number;
  35776. /**
  35777. * Gets or sets the mesh associated with the controller
  35778. */
  35779. mesh: AbstractMesh;
  35780. /**
  35781. * 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)
  35782. */
  35783. slerpAmount: number;
  35784. private _bone1Quat;
  35785. private _bone1Mat;
  35786. private _bone2Ang;
  35787. private _bone1;
  35788. private _bone2;
  35789. private _bone1Length;
  35790. private _bone2Length;
  35791. private _maxAngle;
  35792. private _maxReach;
  35793. private _rightHandedSystem;
  35794. private _bendAxis;
  35795. private _slerping;
  35796. private _adjustRoll;
  35797. /**
  35798. * Gets or sets maximum allowed angle
  35799. */
  35800. maxAngle: number;
  35801. /**
  35802. * Creates a new BoneIKController
  35803. * @param mesh defines the mesh to control
  35804. * @param bone defines the bone to control
  35805. * @param options defines options to set up the controller
  35806. */
  35807. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35808. targetMesh?: AbstractMesh;
  35809. poleTargetMesh?: AbstractMesh;
  35810. poleTargetBone?: Bone;
  35811. poleTargetLocalOffset?: Vector3;
  35812. poleAngle?: number;
  35813. bendAxis?: Vector3;
  35814. maxAngle?: number;
  35815. slerpAmount?: number;
  35816. });
  35817. private _setMaxAngle;
  35818. /**
  35819. * Force the controller to update the bones
  35820. */
  35821. update(): void;
  35822. }
  35823. }
  35824. declare module "babylonjs/Bones/boneLookController" {
  35825. import { Vector3, Space } from "babylonjs/Maths/math";
  35826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35827. import { Bone } from "babylonjs/Bones/bone";
  35828. /**
  35829. * Class used to make a bone look toward a point in space
  35830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35831. */
  35832. export class BoneLookController {
  35833. private static _tmpVecs;
  35834. private static _tmpQuat;
  35835. private static _tmpMats;
  35836. /**
  35837. * The target Vector3 that the bone will look at
  35838. */
  35839. target: Vector3;
  35840. /**
  35841. * The mesh that the bone is attached to
  35842. */
  35843. mesh: AbstractMesh;
  35844. /**
  35845. * The bone that will be looking to the target
  35846. */
  35847. bone: Bone;
  35848. /**
  35849. * The up axis of the coordinate system that is used when the bone is rotated
  35850. */
  35851. upAxis: Vector3;
  35852. /**
  35853. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35854. */
  35855. upAxisSpace: Space;
  35856. /**
  35857. * Used to make an adjustment to the yaw of the bone
  35858. */
  35859. adjustYaw: number;
  35860. /**
  35861. * Used to make an adjustment to the pitch of the bone
  35862. */
  35863. adjustPitch: number;
  35864. /**
  35865. * Used to make an adjustment to the roll of the bone
  35866. */
  35867. adjustRoll: number;
  35868. /**
  35869. * 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)
  35870. */
  35871. slerpAmount: number;
  35872. private _minYaw;
  35873. private _maxYaw;
  35874. private _minPitch;
  35875. private _maxPitch;
  35876. private _minYawSin;
  35877. private _minYawCos;
  35878. private _maxYawSin;
  35879. private _maxYawCos;
  35880. private _midYawConstraint;
  35881. private _minPitchTan;
  35882. private _maxPitchTan;
  35883. private _boneQuat;
  35884. private _slerping;
  35885. private _transformYawPitch;
  35886. private _transformYawPitchInv;
  35887. private _firstFrameSkipped;
  35888. private _yawRange;
  35889. private _fowardAxis;
  35890. /**
  35891. * Gets or sets the minimum yaw angle that the bone can look to
  35892. */
  35893. minYaw: number;
  35894. /**
  35895. * Gets or sets the maximum yaw angle that the bone can look to
  35896. */
  35897. maxYaw: number;
  35898. /**
  35899. * Gets or sets the minimum pitch angle that the bone can look to
  35900. */
  35901. minPitch: number;
  35902. /**
  35903. * Gets or sets the maximum pitch angle that the bone can look to
  35904. */
  35905. maxPitch: number;
  35906. /**
  35907. * Create a BoneLookController
  35908. * @param mesh the mesh that the bone belongs to
  35909. * @param bone the bone that will be looking to the target
  35910. * @param target the target Vector3 to look at
  35911. * @param options optional settings:
  35912. * * maxYaw: the maximum angle the bone will yaw to
  35913. * * minYaw: the minimum angle the bone will yaw to
  35914. * * maxPitch: the maximum angle the bone will pitch to
  35915. * * minPitch: the minimum angle the bone will yaw to
  35916. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35917. * * upAxis: the up axis of the coordinate system
  35918. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35919. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35920. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35921. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35922. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35923. * * adjustRoll: used to make an adjustment to the roll of the bone
  35924. **/
  35925. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35926. maxYaw?: number;
  35927. minYaw?: number;
  35928. maxPitch?: number;
  35929. minPitch?: number;
  35930. slerpAmount?: number;
  35931. upAxis?: Vector3;
  35932. upAxisSpace?: Space;
  35933. yawAxis?: Vector3;
  35934. pitchAxis?: Vector3;
  35935. adjustYaw?: number;
  35936. adjustPitch?: number;
  35937. adjustRoll?: number;
  35938. });
  35939. /**
  35940. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35941. */
  35942. update(): void;
  35943. private _getAngleDiff;
  35944. private _getAngleBetween;
  35945. private _isAngleBetween;
  35946. }
  35947. }
  35948. declare module "babylonjs/Bones/index" {
  35949. export * from "babylonjs/Bones/bone";
  35950. export * from "babylonjs/Bones/boneIKController";
  35951. export * from "babylonjs/Bones/boneLookController";
  35952. export * from "babylonjs/Bones/skeleton";
  35953. }
  35954. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35955. import { Nullable } from "babylonjs/types";
  35956. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35957. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35959. /**
  35960. * Manage the gamepad inputs to control an arc rotate camera.
  35961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35962. */
  35963. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35964. /**
  35965. * Defines the camera the input is attached to.
  35966. */
  35967. camera: ArcRotateCamera;
  35968. /**
  35969. * Defines the gamepad the input is gathering event from.
  35970. */
  35971. gamepad: Nullable<Gamepad>;
  35972. /**
  35973. * Defines the gamepad rotation sensiblity.
  35974. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35975. */
  35976. gamepadRotationSensibility: number;
  35977. /**
  35978. * Defines the gamepad move sensiblity.
  35979. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35980. */
  35981. gamepadMoveSensibility: number;
  35982. private _onGamepadConnectedObserver;
  35983. private _onGamepadDisconnectedObserver;
  35984. /**
  35985. * Attach the input controls to a specific dom element to get the input from.
  35986. * @param element Defines the element the controls should be listened from
  35987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35988. */
  35989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35990. /**
  35991. * Detach the current controls from the specified dom element.
  35992. * @param element Defines the element to stop listening the inputs from
  35993. */
  35994. detachControl(element: Nullable<HTMLElement>): void;
  35995. /**
  35996. * Update the current camera state depending on the inputs that have been used this frame.
  35997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35998. */
  35999. checkInputs(): void;
  36000. /**
  36001. * Gets the class name of the current intput.
  36002. * @returns the class name
  36003. */
  36004. getClassName(): string;
  36005. /**
  36006. * Get the friendly name associated with the input class.
  36007. * @returns the input friendly name
  36008. */
  36009. getSimpleName(): string;
  36010. }
  36011. }
  36012. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36013. import { Nullable } from "babylonjs/types";
  36014. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36016. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36017. interface ArcRotateCameraInputsManager {
  36018. /**
  36019. * Add orientation input support to the input manager.
  36020. * @returns the current input manager
  36021. */
  36022. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36023. }
  36024. }
  36025. /**
  36026. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36028. */
  36029. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36030. /**
  36031. * Defines the camera the input is attached to.
  36032. */
  36033. camera: ArcRotateCamera;
  36034. /**
  36035. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36036. */
  36037. alphaCorrection: number;
  36038. /**
  36039. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36040. */
  36041. gammaCorrection: number;
  36042. private _alpha;
  36043. private _gamma;
  36044. private _dirty;
  36045. private _deviceOrientationHandler;
  36046. /**
  36047. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36048. */
  36049. constructor();
  36050. /**
  36051. * Attach the input controls to a specific dom element to get the input from.
  36052. * @param element Defines the element the controls should be listened from
  36053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36054. */
  36055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36056. /** @hidden */
  36057. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36058. /**
  36059. * Update the current camera state depending on the inputs that have been used this frame.
  36060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36061. */
  36062. checkInputs(): void;
  36063. /**
  36064. * Detach the current controls from the specified dom element.
  36065. * @param element Defines the element to stop listening the inputs from
  36066. */
  36067. detachControl(element: Nullable<HTMLElement>): void;
  36068. /**
  36069. * Gets the class name of the current intput.
  36070. * @returns the class name
  36071. */
  36072. getClassName(): string;
  36073. /**
  36074. * Get the friendly name associated with the input class.
  36075. * @returns the input friendly name
  36076. */
  36077. getSimpleName(): string;
  36078. }
  36079. }
  36080. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36081. import { Nullable } from "babylonjs/types";
  36082. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36083. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36084. /**
  36085. * Listen to mouse events to control the camera.
  36086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36087. */
  36088. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36089. /**
  36090. * Defines the camera the input is attached to.
  36091. */
  36092. camera: FlyCamera;
  36093. /**
  36094. * Defines if touch is enabled. (Default is true.)
  36095. */
  36096. touchEnabled: boolean;
  36097. /**
  36098. * Defines the buttons associated with the input to handle camera rotation.
  36099. */
  36100. buttons: number[];
  36101. /**
  36102. * Assign buttons for Yaw control.
  36103. */
  36104. buttonsYaw: number[];
  36105. /**
  36106. * Assign buttons for Pitch control.
  36107. */
  36108. buttonsPitch: number[];
  36109. /**
  36110. * Assign buttons for Roll control.
  36111. */
  36112. buttonsRoll: number[];
  36113. /**
  36114. * Detect if any button is being pressed while mouse is moved.
  36115. * -1 = Mouse locked.
  36116. * 0 = Left button.
  36117. * 1 = Middle Button.
  36118. * 2 = Right Button.
  36119. */
  36120. activeButton: number;
  36121. /**
  36122. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36123. * Higher values reduce its sensitivity.
  36124. */
  36125. angularSensibility: number;
  36126. private _mousemoveCallback;
  36127. private _observer;
  36128. private _rollObserver;
  36129. private previousPosition;
  36130. private noPreventDefault;
  36131. private element;
  36132. /**
  36133. * Listen to mouse events to control the camera.
  36134. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36136. */
  36137. constructor(touchEnabled?: boolean);
  36138. /**
  36139. * Attach the mouse control to the HTML DOM element.
  36140. * @param element Defines the element that listens to the input events.
  36141. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36142. */
  36143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36144. /**
  36145. * Detach the current controls from the specified dom element.
  36146. * @param element Defines the element to stop listening the inputs from
  36147. */
  36148. detachControl(element: Nullable<HTMLElement>): void;
  36149. /**
  36150. * Gets the class name of the current input.
  36151. * @returns the class name.
  36152. */
  36153. getClassName(): string;
  36154. /**
  36155. * Get the friendly name associated with the input class.
  36156. * @returns the input's friendly name.
  36157. */
  36158. getSimpleName(): string;
  36159. private _pointerInput;
  36160. private _onMouseMove;
  36161. /**
  36162. * Rotate camera by mouse offset.
  36163. */
  36164. private rotateCamera;
  36165. }
  36166. }
  36167. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36168. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36170. /**
  36171. * Default Inputs manager for the FlyCamera.
  36172. * It groups all the default supported inputs for ease of use.
  36173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36174. */
  36175. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36176. /**
  36177. * Instantiates a new FlyCameraInputsManager.
  36178. * @param camera Defines the camera the inputs belong to.
  36179. */
  36180. constructor(camera: FlyCamera);
  36181. /**
  36182. * Add keyboard input support to the input manager.
  36183. * @returns the new FlyCameraKeyboardMoveInput().
  36184. */
  36185. addKeyboard(): FlyCameraInputsManager;
  36186. /**
  36187. * Add mouse input support to the input manager.
  36188. * @param touchEnabled Enable touch screen support.
  36189. * @returns the new FlyCameraMouseInput().
  36190. */
  36191. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36192. }
  36193. }
  36194. declare module "babylonjs/Cameras/flyCamera" {
  36195. import { Scene } from "babylonjs/scene";
  36196. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36198. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36199. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36200. /**
  36201. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36202. * such as in a 3D Space Shooter or a Flight Simulator.
  36203. */
  36204. export class FlyCamera extends TargetCamera {
  36205. /**
  36206. * Define the collision ellipsoid of the camera.
  36207. * This is helpful for simulating a camera body, like a player's body.
  36208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36209. */
  36210. ellipsoid: Vector3;
  36211. /**
  36212. * Define an offset for the position of the ellipsoid around the camera.
  36213. * This can be helpful if the camera is attached away from the player's body center,
  36214. * such as at its head.
  36215. */
  36216. ellipsoidOffset: Vector3;
  36217. /**
  36218. * Enable or disable collisions of the camera with the rest of the scene objects.
  36219. */
  36220. checkCollisions: boolean;
  36221. /**
  36222. * Enable or disable gravity on the camera.
  36223. */
  36224. applyGravity: boolean;
  36225. /**
  36226. * Define the current direction the camera is moving to.
  36227. */
  36228. cameraDirection: Vector3;
  36229. /**
  36230. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36231. * This overrides and empties cameraRotation.
  36232. */
  36233. rotationQuaternion: Quaternion;
  36234. /**
  36235. * Track Roll to maintain the wanted Rolling when looking around.
  36236. */
  36237. _trackRoll: number;
  36238. /**
  36239. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36240. */
  36241. rollCorrect: number;
  36242. /**
  36243. * Mimic a banked turn, Rolling the camera when Yawing.
  36244. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36245. */
  36246. bankedTurn: boolean;
  36247. /**
  36248. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36249. */
  36250. bankedTurnLimit: number;
  36251. /**
  36252. * Value of 0 disables the banked Roll.
  36253. * Value of 1 is equal to the Yaw angle in radians.
  36254. */
  36255. bankedTurnMultiplier: number;
  36256. /**
  36257. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36258. */
  36259. inputs: FlyCameraInputsManager;
  36260. /**
  36261. * Gets the input sensibility for mouse input.
  36262. * Higher values reduce sensitivity.
  36263. */
  36264. /**
  36265. * Sets the input sensibility for a mouse input.
  36266. * Higher values reduce sensitivity.
  36267. */
  36268. angularSensibility: number;
  36269. /**
  36270. * Get the keys for camera movement forward.
  36271. */
  36272. /**
  36273. * Set the keys for camera movement forward.
  36274. */
  36275. keysForward: number[];
  36276. /**
  36277. * Get the keys for camera movement backward.
  36278. */
  36279. keysBackward: number[];
  36280. /**
  36281. * Get the keys for camera movement up.
  36282. */
  36283. /**
  36284. * Set the keys for camera movement up.
  36285. */
  36286. keysUp: number[];
  36287. /**
  36288. * Get the keys for camera movement down.
  36289. */
  36290. /**
  36291. * Set the keys for camera movement down.
  36292. */
  36293. keysDown: number[];
  36294. /**
  36295. * Get the keys for camera movement left.
  36296. */
  36297. /**
  36298. * Set the keys for camera movement left.
  36299. */
  36300. keysLeft: number[];
  36301. /**
  36302. * Set the keys for camera movement right.
  36303. */
  36304. /**
  36305. * Set the keys for camera movement right.
  36306. */
  36307. keysRight: number[];
  36308. /**
  36309. * Event raised when the camera collides with a mesh in the scene.
  36310. */
  36311. onCollide: (collidedMesh: AbstractMesh) => void;
  36312. private _collider;
  36313. private _needMoveForGravity;
  36314. private _oldPosition;
  36315. private _diffPosition;
  36316. private _newPosition;
  36317. /** @hidden */
  36318. _localDirection: Vector3;
  36319. /** @hidden */
  36320. _transformedDirection: Vector3;
  36321. /**
  36322. * Instantiates a FlyCamera.
  36323. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36324. * such as in a 3D Space Shooter or a Flight Simulator.
  36325. * @param name Define the name of the camera in the scene.
  36326. * @param position Define the starting position of the camera in the scene.
  36327. * @param scene Define the scene the camera belongs to.
  36328. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36329. */
  36330. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36331. /**
  36332. * Attach a control to the HTML DOM element.
  36333. * @param element Defines the element that listens to the input events.
  36334. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36335. */
  36336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36337. /**
  36338. * Detach a control from the HTML DOM element.
  36339. * The camera will stop reacting to that input.
  36340. * @param element Defines the element that listens to the input events.
  36341. */
  36342. detachControl(element: HTMLElement): void;
  36343. private _collisionMask;
  36344. /**
  36345. * Get the mask that the camera ignores in collision events.
  36346. */
  36347. /**
  36348. * Set the mask that the camera ignores in collision events.
  36349. */
  36350. collisionMask: number;
  36351. /** @hidden */
  36352. _collideWithWorld(displacement: Vector3): void;
  36353. /** @hidden */
  36354. private _onCollisionPositionChange;
  36355. /** @hidden */
  36356. _checkInputs(): void;
  36357. /** @hidden */
  36358. _decideIfNeedsToMove(): boolean;
  36359. /** @hidden */
  36360. _updatePosition(): void;
  36361. /**
  36362. * Restore the Roll to its target value at the rate specified.
  36363. * @param rate - Higher means slower restoring.
  36364. * @hidden
  36365. */
  36366. restoreRoll(rate: number): void;
  36367. /**
  36368. * Destroy the camera and release the current resources held by it.
  36369. */
  36370. dispose(): void;
  36371. /**
  36372. * Get the current object class name.
  36373. * @returns the class name.
  36374. */
  36375. getClassName(): string;
  36376. }
  36377. }
  36378. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36379. import { Nullable } from "babylonjs/types";
  36380. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36381. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36382. /**
  36383. * Listen to keyboard events to control the camera.
  36384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36385. */
  36386. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36387. /**
  36388. * Defines the camera the input is attached to.
  36389. */
  36390. camera: FlyCamera;
  36391. /**
  36392. * The list of keyboard keys used to control the forward move of the camera.
  36393. */
  36394. keysForward: number[];
  36395. /**
  36396. * The list of keyboard keys used to control the backward move of the camera.
  36397. */
  36398. keysBackward: number[];
  36399. /**
  36400. * The list of keyboard keys used to control the forward move of the camera.
  36401. */
  36402. keysUp: number[];
  36403. /**
  36404. * The list of keyboard keys used to control the backward move of the camera.
  36405. */
  36406. keysDown: number[];
  36407. /**
  36408. * The list of keyboard keys used to control the right strafe move of the camera.
  36409. */
  36410. keysRight: number[];
  36411. /**
  36412. * The list of keyboard keys used to control the left strafe move of the camera.
  36413. */
  36414. keysLeft: number[];
  36415. private _keys;
  36416. private _onCanvasBlurObserver;
  36417. private _onKeyboardObserver;
  36418. private _engine;
  36419. private _scene;
  36420. /**
  36421. * Attach the input controls to a specific dom element to get the input from.
  36422. * @param element Defines the element the controls should be listened from
  36423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36424. */
  36425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36426. /**
  36427. * Detach the current controls from the specified dom element.
  36428. * @param element Defines the element to stop listening the inputs from
  36429. */
  36430. detachControl(element: Nullable<HTMLElement>): void;
  36431. /**
  36432. * Gets the class name of the current intput.
  36433. * @returns the class name
  36434. */
  36435. getClassName(): string;
  36436. /** @hidden */
  36437. _onLostFocus(e: FocusEvent): void;
  36438. /**
  36439. * Get the friendly name associated with the input class.
  36440. * @returns the input friendly name
  36441. */
  36442. getSimpleName(): string;
  36443. /**
  36444. * Update the current camera state depending on the inputs that have been used this frame.
  36445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36446. */
  36447. checkInputs(): void;
  36448. }
  36449. }
  36450. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36451. import { Nullable } from "babylonjs/types";
  36452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36454. module "babylonjs/Cameras/freeCameraInputsManager" {
  36455. interface FreeCameraInputsManager {
  36456. /**
  36457. * Add orientation input support to the input manager.
  36458. * @returns the current input manager
  36459. */
  36460. addDeviceOrientation(): FreeCameraInputsManager;
  36461. }
  36462. }
  36463. /**
  36464. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36465. * Screen rotation is taken into account.
  36466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36467. */
  36468. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36469. private _camera;
  36470. private _screenOrientationAngle;
  36471. private _constantTranform;
  36472. private _screenQuaternion;
  36473. private _alpha;
  36474. private _beta;
  36475. private _gamma;
  36476. /**
  36477. * Instantiates a new input
  36478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36479. */
  36480. constructor();
  36481. /**
  36482. * Define the camera controlled by the input.
  36483. */
  36484. camera: FreeCamera;
  36485. /**
  36486. * Attach the input controls to a specific dom element to get the input from.
  36487. * @param element Defines the element the controls should be listened from
  36488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36489. */
  36490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36491. private _orientationChanged;
  36492. private _deviceOrientation;
  36493. /**
  36494. * Detach the current controls from the specified dom element.
  36495. * @param element Defines the element to stop listening the inputs from
  36496. */
  36497. detachControl(element: Nullable<HTMLElement>): void;
  36498. /**
  36499. * Update the current camera state depending on the inputs that have been used this frame.
  36500. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36501. */
  36502. checkInputs(): void;
  36503. /**
  36504. * Gets the class name of the current intput.
  36505. * @returns the class name
  36506. */
  36507. getClassName(): string;
  36508. /**
  36509. * Get the friendly name associated with the input class.
  36510. * @returns the input friendly name
  36511. */
  36512. getSimpleName(): string;
  36513. }
  36514. }
  36515. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36516. import { Nullable } from "babylonjs/types";
  36517. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36519. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36520. /**
  36521. * Manage the gamepad inputs to control a free camera.
  36522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36523. */
  36524. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36525. /**
  36526. * Define the camera the input is attached to.
  36527. */
  36528. camera: FreeCamera;
  36529. /**
  36530. * Define the Gamepad controlling the input
  36531. */
  36532. gamepad: Nullable<Gamepad>;
  36533. /**
  36534. * Defines the gamepad rotation sensiblity.
  36535. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36536. */
  36537. gamepadAngularSensibility: number;
  36538. /**
  36539. * Defines the gamepad move sensiblity.
  36540. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36541. */
  36542. gamepadMoveSensibility: number;
  36543. private _onGamepadConnectedObserver;
  36544. private _onGamepadDisconnectedObserver;
  36545. private _cameraTransform;
  36546. private _deltaTransform;
  36547. private _vector3;
  36548. private _vector2;
  36549. /**
  36550. * Attach the input controls to a specific dom element to get the input from.
  36551. * @param element Defines the element the controls should be listened from
  36552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36553. */
  36554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36555. /**
  36556. * Detach the current controls from the specified dom element.
  36557. * @param element Defines the element to stop listening the inputs from
  36558. */
  36559. detachControl(element: Nullable<HTMLElement>): void;
  36560. /**
  36561. * Update the current camera state depending on the inputs that have been used this frame.
  36562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36563. */
  36564. checkInputs(): void;
  36565. /**
  36566. * Gets the class name of the current intput.
  36567. * @returns the class name
  36568. */
  36569. getClassName(): string;
  36570. /**
  36571. * Get the friendly name associated with the input class.
  36572. * @returns the input friendly name
  36573. */
  36574. getSimpleName(): string;
  36575. }
  36576. }
  36577. declare module "babylonjs/Misc/virtualJoystick" {
  36578. import { Nullable } from "babylonjs/types";
  36579. import { Vector3 } from "babylonjs/Maths/math";
  36580. /**
  36581. * Defines the potential axis of a Joystick
  36582. */
  36583. export enum JoystickAxis {
  36584. /** X axis */
  36585. X = 0,
  36586. /** Y axis */
  36587. Y = 1,
  36588. /** Z axis */
  36589. Z = 2
  36590. }
  36591. /**
  36592. * Class used to define virtual joystick (used in touch mode)
  36593. */
  36594. export class VirtualJoystick {
  36595. /**
  36596. * Gets or sets a boolean indicating that left and right values must be inverted
  36597. */
  36598. reverseLeftRight: boolean;
  36599. /**
  36600. * Gets or sets a boolean indicating that up and down values must be inverted
  36601. */
  36602. reverseUpDown: boolean;
  36603. /**
  36604. * Gets the offset value for the position (ie. the change of the position value)
  36605. */
  36606. deltaPosition: Vector3;
  36607. /**
  36608. * Gets a boolean indicating if the virtual joystick was pressed
  36609. */
  36610. pressed: boolean;
  36611. /**
  36612. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36613. */
  36614. static Canvas: Nullable<HTMLCanvasElement>;
  36615. private static _globalJoystickIndex;
  36616. private static vjCanvasContext;
  36617. private static vjCanvasWidth;
  36618. private static vjCanvasHeight;
  36619. private static halfWidth;
  36620. private _action;
  36621. private _axisTargetedByLeftAndRight;
  36622. private _axisTargetedByUpAndDown;
  36623. private _joystickSensibility;
  36624. private _inversedSensibility;
  36625. private _joystickPointerID;
  36626. private _joystickColor;
  36627. private _joystickPointerPos;
  36628. private _joystickPreviousPointerPos;
  36629. private _joystickPointerStartPos;
  36630. private _deltaJoystickVector;
  36631. private _leftJoystick;
  36632. private _touches;
  36633. private _onPointerDownHandlerRef;
  36634. private _onPointerMoveHandlerRef;
  36635. private _onPointerUpHandlerRef;
  36636. private _onResize;
  36637. /**
  36638. * Creates a new virtual joystick
  36639. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36640. */
  36641. constructor(leftJoystick?: boolean);
  36642. /**
  36643. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36644. * @param newJoystickSensibility defines the new sensibility
  36645. */
  36646. setJoystickSensibility(newJoystickSensibility: number): void;
  36647. private _onPointerDown;
  36648. private _onPointerMove;
  36649. private _onPointerUp;
  36650. /**
  36651. * Change the color of the virtual joystick
  36652. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36653. */
  36654. setJoystickColor(newColor: string): void;
  36655. /**
  36656. * Defines a callback to call when the joystick is touched
  36657. * @param action defines the callback
  36658. */
  36659. setActionOnTouch(action: () => any): void;
  36660. /**
  36661. * Defines which axis you'd like to control for left & right
  36662. * @param axis defines the axis to use
  36663. */
  36664. setAxisForLeftRight(axis: JoystickAxis): void;
  36665. /**
  36666. * Defines which axis you'd like to control for up & down
  36667. * @param axis defines the axis to use
  36668. */
  36669. setAxisForUpDown(axis: JoystickAxis): void;
  36670. private _drawVirtualJoystick;
  36671. /**
  36672. * Release internal HTML canvas
  36673. */
  36674. releaseCanvas(): void;
  36675. }
  36676. }
  36677. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36678. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36679. import { Nullable } from "babylonjs/types";
  36680. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36681. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36682. module "babylonjs/Cameras/freeCameraInputsManager" {
  36683. interface FreeCameraInputsManager {
  36684. /**
  36685. * Add virtual joystick input support to the input manager.
  36686. * @returns the current input manager
  36687. */
  36688. addVirtualJoystick(): FreeCameraInputsManager;
  36689. }
  36690. }
  36691. /**
  36692. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36694. */
  36695. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36696. /**
  36697. * Defines the camera the input is attached to.
  36698. */
  36699. camera: FreeCamera;
  36700. private _leftjoystick;
  36701. private _rightjoystick;
  36702. /**
  36703. * Gets the left stick of the virtual joystick.
  36704. * @returns The virtual Joystick
  36705. */
  36706. getLeftJoystick(): VirtualJoystick;
  36707. /**
  36708. * Gets the right stick of the virtual joystick.
  36709. * @returns The virtual Joystick
  36710. */
  36711. getRightJoystick(): VirtualJoystick;
  36712. /**
  36713. * Update the current camera state depending on the inputs that have been used this frame.
  36714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36715. */
  36716. checkInputs(): void;
  36717. /**
  36718. * Attach the input controls to a specific dom element to get the input from.
  36719. * @param element Defines the element the controls should be listened from
  36720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36721. */
  36722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36723. /**
  36724. * Detach the current controls from the specified dom element.
  36725. * @param element Defines the element to stop listening the inputs from
  36726. */
  36727. detachControl(element: Nullable<HTMLElement>): void;
  36728. /**
  36729. * Gets the class name of the current intput.
  36730. * @returns the class name
  36731. */
  36732. getClassName(): string;
  36733. /**
  36734. * Get the friendly name associated with the input class.
  36735. * @returns the input friendly name
  36736. */
  36737. getSimpleName(): string;
  36738. }
  36739. }
  36740. declare module "babylonjs/Cameras/Inputs/index" {
  36741. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36742. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36743. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36744. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36745. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36746. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36747. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36748. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36749. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36750. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36751. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36752. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36753. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36754. }
  36755. declare module "babylonjs/Cameras/touchCamera" {
  36756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36757. import { Scene } from "babylonjs/scene";
  36758. import { Vector3 } from "babylonjs/Maths/math";
  36759. /**
  36760. * This represents a FPS type of camera controlled by touch.
  36761. * This is like a universal camera minus the Gamepad controls.
  36762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36763. */
  36764. export class TouchCamera extends FreeCamera {
  36765. /**
  36766. * Defines the touch sensibility for rotation.
  36767. * The higher the faster.
  36768. */
  36769. touchAngularSensibility: number;
  36770. /**
  36771. * Defines the touch sensibility for move.
  36772. * The higher the faster.
  36773. */
  36774. touchMoveSensibility: number;
  36775. /**
  36776. * Instantiates a new touch camera.
  36777. * This represents a FPS type of camera controlled by touch.
  36778. * This is like a universal camera minus the Gamepad controls.
  36779. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36780. * @param name Define the name of the camera in the scene
  36781. * @param position Define the start position of the camera in the scene
  36782. * @param scene Define the scene the camera belongs to
  36783. */
  36784. constructor(name: string, position: Vector3, scene: Scene);
  36785. /**
  36786. * Gets the current object class name.
  36787. * @return the class name
  36788. */
  36789. getClassName(): string;
  36790. /** @hidden */
  36791. _setupInputs(): void;
  36792. }
  36793. }
  36794. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36796. import { Scene } from "babylonjs/scene";
  36797. import { Vector3, Axis } from "babylonjs/Maths/math";
  36798. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36799. /**
  36800. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36801. * being tilted forward or back and left or right.
  36802. */
  36803. export class DeviceOrientationCamera extends FreeCamera {
  36804. private _initialQuaternion;
  36805. private _quaternionCache;
  36806. /**
  36807. * Creates a new device orientation camera
  36808. * @param name The name of the camera
  36809. * @param position The start position camera
  36810. * @param scene The scene the camera belongs to
  36811. */
  36812. constructor(name: string, position: Vector3, scene: Scene);
  36813. /**
  36814. * Gets the current instance class name ("DeviceOrientationCamera").
  36815. * This helps avoiding instanceof at run time.
  36816. * @returns the class name
  36817. */
  36818. getClassName(): string;
  36819. /**
  36820. * @hidden
  36821. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36822. */
  36823. _checkInputs(): void;
  36824. /**
  36825. * Reset the camera to its default orientation on the specified axis only.
  36826. * @param axis The axis to reset
  36827. */
  36828. resetToCurrentRotation(axis?: Axis): void;
  36829. }
  36830. }
  36831. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36832. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36833. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36834. import { Nullable } from "babylonjs/types";
  36835. /**
  36836. * Manage the keyboard inputs to control the movement of a follow camera.
  36837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36838. */
  36839. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36840. /**
  36841. * Defines the camera the input is attached to.
  36842. */
  36843. camera: FollowCamera;
  36844. /**
  36845. * Defines the list of key codes associated with the up action (increase heightOffset)
  36846. */
  36847. keysHeightOffsetIncr: number[];
  36848. /**
  36849. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36850. */
  36851. keysHeightOffsetDecr: number[];
  36852. /**
  36853. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36854. */
  36855. keysHeightOffsetModifierAlt: boolean;
  36856. /**
  36857. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36858. */
  36859. keysHeightOffsetModifierCtrl: boolean;
  36860. /**
  36861. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36862. */
  36863. keysHeightOffsetModifierShift: boolean;
  36864. /**
  36865. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36866. */
  36867. keysRotationOffsetIncr: number[];
  36868. /**
  36869. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36870. */
  36871. keysRotationOffsetDecr: number[];
  36872. /**
  36873. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36874. */
  36875. keysRotationOffsetModifierAlt: boolean;
  36876. /**
  36877. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36878. */
  36879. keysRotationOffsetModifierCtrl: boolean;
  36880. /**
  36881. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36882. */
  36883. keysRotationOffsetModifierShift: boolean;
  36884. /**
  36885. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36886. */
  36887. keysRadiusIncr: number[];
  36888. /**
  36889. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36890. */
  36891. keysRadiusDecr: number[];
  36892. /**
  36893. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36894. */
  36895. keysRadiusModifierAlt: boolean;
  36896. /**
  36897. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36898. */
  36899. keysRadiusModifierCtrl: boolean;
  36900. /**
  36901. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36902. */
  36903. keysRadiusModifierShift: boolean;
  36904. /**
  36905. * Defines the rate of change of heightOffset.
  36906. */
  36907. heightSensibility: number;
  36908. /**
  36909. * Defines the rate of change of rotationOffset.
  36910. */
  36911. rotationSensibility: number;
  36912. /**
  36913. * Defines the rate of change of radius.
  36914. */
  36915. radiusSensibility: number;
  36916. private _keys;
  36917. private _ctrlPressed;
  36918. private _altPressed;
  36919. private _shiftPressed;
  36920. private _onCanvasBlurObserver;
  36921. private _onKeyboardObserver;
  36922. private _engine;
  36923. private _scene;
  36924. /**
  36925. * Attach the input controls to a specific dom element to get the input from.
  36926. * @param element Defines the element the controls should be listened from
  36927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36928. */
  36929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36930. /**
  36931. * Detach the current controls from the specified dom element.
  36932. * @param element Defines the element to stop listening the inputs from
  36933. */
  36934. detachControl(element: Nullable<HTMLElement>): void;
  36935. /**
  36936. * Update the current camera state depending on the inputs that have been used this frame.
  36937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36938. */
  36939. checkInputs(): void;
  36940. /**
  36941. * Gets the class name of the current input.
  36942. * @returns the class name
  36943. */
  36944. getClassName(): string;
  36945. /**
  36946. * Get the friendly name associated with the input class.
  36947. * @returns the input friendly name
  36948. */
  36949. getSimpleName(): string;
  36950. /**
  36951. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36952. * allow modification of the heightOffset value.
  36953. */
  36954. private _modifierHeightOffset;
  36955. /**
  36956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36957. * allow modification of the rotationOffset value.
  36958. */
  36959. private _modifierRotationOffset;
  36960. /**
  36961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36962. * allow modification of the radius value.
  36963. */
  36964. private _modifierRadius;
  36965. }
  36966. }
  36967. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36968. import { Nullable } from "babylonjs/types";
  36969. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36970. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36971. /**
  36972. * Manage the mouse wheel inputs to control a follow camera.
  36973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36974. */
  36975. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36976. /**
  36977. * Defines the camera the input is attached to.
  36978. */
  36979. camera: FollowCamera;
  36980. /**
  36981. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36982. */
  36983. axisControlRadius: boolean;
  36984. /**
  36985. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36986. */
  36987. axisControlHeight: boolean;
  36988. /**
  36989. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36990. */
  36991. axisControlRotation: boolean;
  36992. /**
  36993. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36994. * relation to mouseWheel events.
  36995. */
  36996. wheelPrecision: number;
  36997. /**
  36998. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36999. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37000. */
  37001. wheelDeltaPercentage: number;
  37002. private _wheel;
  37003. private _observer;
  37004. /**
  37005. * Attach the input controls to a specific dom element to get the input from.
  37006. * @param element Defines the element the controls should be listened from
  37007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37008. */
  37009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37010. /**
  37011. * Detach the current controls from the specified dom element.
  37012. * @param element Defines the element to stop listening the inputs from
  37013. */
  37014. detachControl(element: Nullable<HTMLElement>): void;
  37015. /**
  37016. * Gets the class name of the current intput.
  37017. * @returns the class name
  37018. */
  37019. getClassName(): string;
  37020. /**
  37021. * Get the friendly name associated with the input class.
  37022. * @returns the input friendly name
  37023. */
  37024. getSimpleName(): string;
  37025. }
  37026. }
  37027. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37028. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37029. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37030. /**
  37031. * Default Inputs manager for the FollowCamera.
  37032. * It groups all the default supported inputs for ease of use.
  37033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37034. */
  37035. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37036. /**
  37037. * Instantiates a new FollowCameraInputsManager.
  37038. * @param camera Defines the camera the inputs belong to
  37039. */
  37040. constructor(camera: FollowCamera);
  37041. /**
  37042. * Add keyboard input support to the input manager.
  37043. * @returns the current input manager
  37044. */
  37045. addKeyboard(): FollowCameraInputsManager;
  37046. /**
  37047. * Add mouse wheel input support to the input manager.
  37048. * @returns the current input manager
  37049. */
  37050. addMouseWheel(): FollowCameraInputsManager;
  37051. /**
  37052. * Add pointers input support to the input manager.
  37053. * @returns the current input manager
  37054. */
  37055. addPointers(): FollowCameraInputsManager;
  37056. /**
  37057. * Add orientation input support to the input manager.
  37058. * @returns the current input manager
  37059. */
  37060. addVRDeviceOrientation(): FollowCameraInputsManager;
  37061. }
  37062. }
  37063. declare module "babylonjs/Cameras/followCamera" {
  37064. import { Nullable } from "babylonjs/types";
  37065. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37066. import { Scene } from "babylonjs/scene";
  37067. import { Vector3 } from "babylonjs/Maths/math";
  37068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37069. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37070. /**
  37071. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37072. * an arc rotate version arcFollowCamera are available.
  37073. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37074. */
  37075. export class FollowCamera extends TargetCamera {
  37076. /**
  37077. * Distance the follow camera should follow an object at
  37078. */
  37079. radius: number;
  37080. /**
  37081. * Minimum allowed distance of the camera to the axis of rotation
  37082. * (The camera can not get closer).
  37083. * This can help limiting how the Camera is able to move in the scene.
  37084. */
  37085. lowerRadiusLimit: Nullable<number>;
  37086. /**
  37087. * Maximum allowed distance of the camera to the axis of rotation
  37088. * (The camera can not get further).
  37089. * This can help limiting how the Camera is able to move in the scene.
  37090. */
  37091. upperRadiusLimit: Nullable<number>;
  37092. /**
  37093. * Define a rotation offset between the camera and the object it follows
  37094. */
  37095. rotationOffset: number;
  37096. /**
  37097. * Minimum allowed angle to camera position relative to target object.
  37098. * This can help limiting how the Camera is able to move in the scene.
  37099. */
  37100. lowerRotationOffsetLimit: Nullable<number>;
  37101. /**
  37102. * Maximum allowed angle to camera position relative to target object.
  37103. * This can help limiting how the Camera is able to move in the scene.
  37104. */
  37105. upperRotationOffsetLimit: Nullable<number>;
  37106. /**
  37107. * Define a height offset between the camera and the object it follows.
  37108. * It can help following an object from the top (like a car chaing a plane)
  37109. */
  37110. heightOffset: number;
  37111. /**
  37112. * Minimum allowed height of camera position relative to target object.
  37113. * This can help limiting how the Camera is able to move in the scene.
  37114. */
  37115. lowerHeightOffsetLimit: Nullable<number>;
  37116. /**
  37117. * Maximum allowed height of camera position relative to target object.
  37118. * This can help limiting how the Camera is able to move in the scene.
  37119. */
  37120. upperHeightOffsetLimit: Nullable<number>;
  37121. /**
  37122. * Define how fast the camera can accelerate to follow it s target.
  37123. */
  37124. cameraAcceleration: number;
  37125. /**
  37126. * Define the speed limit of the camera following an object.
  37127. */
  37128. maxCameraSpeed: number;
  37129. /**
  37130. * Define the target of the camera.
  37131. */
  37132. lockedTarget: Nullable<AbstractMesh>;
  37133. /**
  37134. * Defines the input associated with the camera.
  37135. */
  37136. inputs: FollowCameraInputsManager;
  37137. /**
  37138. * Instantiates the follow camera.
  37139. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37140. * @param name Define the name of the camera in the scene
  37141. * @param position Define the position of the camera
  37142. * @param scene Define the scene the camera belong to
  37143. * @param lockedTarget Define the target of the camera
  37144. */
  37145. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37146. private _follow;
  37147. /**
  37148. * Attached controls to the current camera.
  37149. * @param element Defines the element the controls should be listened from
  37150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37151. */
  37152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37153. /**
  37154. * Detach the current controls from the camera.
  37155. * The camera will stop reacting to inputs.
  37156. * @param element Defines the element to stop listening the inputs from
  37157. */
  37158. detachControl(element: HTMLElement): void;
  37159. /** @hidden */
  37160. _checkInputs(): void;
  37161. private _checkLimits;
  37162. /**
  37163. * Gets the camera class name.
  37164. * @returns the class name
  37165. */
  37166. getClassName(): string;
  37167. }
  37168. /**
  37169. * Arc Rotate version of the follow camera.
  37170. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37171. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37172. */
  37173. export class ArcFollowCamera extends TargetCamera {
  37174. /** The longitudinal angle of the camera */
  37175. alpha: number;
  37176. /** The latitudinal angle of the camera */
  37177. beta: number;
  37178. /** The radius of the camera from its target */
  37179. radius: number;
  37180. /** Define the camera target (the messh it should follow) */
  37181. target: Nullable<AbstractMesh>;
  37182. private _cartesianCoordinates;
  37183. /**
  37184. * Instantiates a new ArcFollowCamera
  37185. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37186. * @param name Define the name of the camera
  37187. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37188. * @param beta Define the rotation angle of the camera around the elevation axis
  37189. * @param radius Define the radius of the camera from its target point
  37190. * @param target Define the target of the camera
  37191. * @param scene Define the scene the camera belongs to
  37192. */
  37193. constructor(name: string,
  37194. /** The longitudinal angle of the camera */
  37195. alpha: number,
  37196. /** The latitudinal angle of the camera */
  37197. beta: number,
  37198. /** The radius of the camera from its target */
  37199. radius: number,
  37200. /** Define the camera target (the messh it should follow) */
  37201. target: Nullable<AbstractMesh>, scene: Scene);
  37202. private _follow;
  37203. /** @hidden */
  37204. _checkInputs(): void;
  37205. /**
  37206. * Returns the class name of the object.
  37207. * It is mostly used internally for serialization purposes.
  37208. */
  37209. getClassName(): string;
  37210. }
  37211. }
  37212. declare module "babylonjs/Cameras/universalCamera" {
  37213. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37214. import { Scene } from "babylonjs/scene";
  37215. import { Vector3 } from "babylonjs/Maths/math";
  37216. /**
  37217. * 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,
  37218. * which still works and will still be found in many Playgrounds.
  37219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37220. */
  37221. export class UniversalCamera extends TouchCamera {
  37222. /**
  37223. * Defines the gamepad rotation sensiblity.
  37224. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37225. */
  37226. gamepadAngularSensibility: number;
  37227. /**
  37228. * Defines the gamepad move sensiblity.
  37229. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37230. */
  37231. gamepadMoveSensibility: number;
  37232. /**
  37233. * 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,
  37234. * which still works and will still be found in many Playgrounds.
  37235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37236. * @param name Define the name of the camera in the scene
  37237. * @param position Define the start position of the camera in the scene
  37238. * @param scene Define the scene the camera belongs to
  37239. */
  37240. constructor(name: string, position: Vector3, scene: Scene);
  37241. /**
  37242. * Gets the current object class name.
  37243. * @return the class name
  37244. */
  37245. getClassName(): string;
  37246. }
  37247. }
  37248. declare module "babylonjs/Cameras/gamepadCamera" {
  37249. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37250. import { Scene } from "babylonjs/scene";
  37251. import { Vector3 } from "babylonjs/Maths/math";
  37252. /**
  37253. * This represents a FPS type of camera. This is only here for back compat purpose.
  37254. * Please use the UniversalCamera instead as both are identical.
  37255. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37256. */
  37257. export class GamepadCamera extends UniversalCamera {
  37258. /**
  37259. * Instantiates a new Gamepad Camera
  37260. * This represents a FPS type of camera. This is only here for back compat purpose.
  37261. * Please use the UniversalCamera instead as both are identical.
  37262. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37263. * @param name Define the name of the camera in the scene
  37264. * @param position Define the start position of the camera in the scene
  37265. * @param scene Define the scene the camera belongs to
  37266. */
  37267. constructor(name: string, position: Vector3, scene: Scene);
  37268. /**
  37269. * Gets the current object class name.
  37270. * @return the class name
  37271. */
  37272. getClassName(): string;
  37273. }
  37274. }
  37275. declare module "babylonjs/Shaders/pass.fragment" {
  37276. /** @hidden */
  37277. export var passPixelShader: {
  37278. name: string;
  37279. shader: string;
  37280. };
  37281. }
  37282. declare module "babylonjs/Shaders/passCube.fragment" {
  37283. /** @hidden */
  37284. export var passCubePixelShader: {
  37285. name: string;
  37286. shader: string;
  37287. };
  37288. }
  37289. declare module "babylonjs/PostProcesses/passPostProcess" {
  37290. import { Nullable } from "babylonjs/types";
  37291. import { Camera } from "babylonjs/Cameras/camera";
  37292. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37293. import { Engine } from "babylonjs/Engines/engine";
  37294. import "babylonjs/Shaders/pass.fragment";
  37295. import "babylonjs/Shaders/passCube.fragment";
  37296. /**
  37297. * PassPostProcess which produces an output the same as it's input
  37298. */
  37299. export class PassPostProcess extends PostProcess {
  37300. /**
  37301. * Creates the PassPostProcess
  37302. * @param name The name of the effect.
  37303. * @param options The required width/height ratio to downsize to before computing the render pass.
  37304. * @param camera The camera to apply the render pass to.
  37305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37306. * @param engine The engine which the post process will be applied. (default: current engine)
  37307. * @param reusable If the post process can be reused on the same frame. (default: false)
  37308. * @param textureType The type of texture to be used when performing the post processing.
  37309. * @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)
  37310. */
  37311. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37312. }
  37313. /**
  37314. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37315. */
  37316. export class PassCubePostProcess extends PostProcess {
  37317. private _face;
  37318. /**
  37319. * Gets or sets the cube face to display.
  37320. * * 0 is +X
  37321. * * 1 is -X
  37322. * * 2 is +Y
  37323. * * 3 is -Y
  37324. * * 4 is +Z
  37325. * * 5 is -Z
  37326. */
  37327. face: number;
  37328. /**
  37329. * Creates the PassCubePostProcess
  37330. * @param name The name of the effect.
  37331. * @param options The required width/height ratio to downsize to before computing the render pass.
  37332. * @param camera The camera to apply the render pass to.
  37333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37334. * @param engine The engine which the post process will be applied. (default: current engine)
  37335. * @param reusable If the post process can be reused on the same frame. (default: false)
  37336. * @param textureType The type of texture to be used when performing the post processing.
  37337. * @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)
  37338. */
  37339. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37340. }
  37341. }
  37342. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37343. /** @hidden */
  37344. export var anaglyphPixelShader: {
  37345. name: string;
  37346. shader: string;
  37347. };
  37348. }
  37349. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37350. import { Engine } from "babylonjs/Engines/engine";
  37351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37352. import { Camera } from "babylonjs/Cameras/camera";
  37353. import "babylonjs/Shaders/anaglyph.fragment";
  37354. /**
  37355. * Postprocess used to generate anaglyphic rendering
  37356. */
  37357. export class AnaglyphPostProcess extends PostProcess {
  37358. private _passedProcess;
  37359. /**
  37360. * Creates a new AnaglyphPostProcess
  37361. * @param name defines postprocess name
  37362. * @param options defines creation options or target ratio scale
  37363. * @param rigCameras defines cameras using this postprocess
  37364. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37365. * @param engine defines hosting engine
  37366. * @param reusable defines if the postprocess will be reused multiple times per frame
  37367. */
  37368. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37369. }
  37370. }
  37371. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37372. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37374. import { Scene } from "babylonjs/scene";
  37375. import { Vector3 } from "babylonjs/Maths/math";
  37376. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37377. /**
  37378. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37380. */
  37381. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37382. /**
  37383. * Creates a new AnaglyphArcRotateCamera
  37384. * @param name defines camera name
  37385. * @param alpha defines alpha angle (in radians)
  37386. * @param beta defines beta angle (in radians)
  37387. * @param radius defines radius
  37388. * @param target defines camera target
  37389. * @param interaxialDistance defines distance between each color axis
  37390. * @param scene defines the hosting scene
  37391. */
  37392. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37393. /**
  37394. * Gets camera class name
  37395. * @returns AnaglyphArcRotateCamera
  37396. */
  37397. getClassName(): string;
  37398. }
  37399. }
  37400. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37402. import { Scene } from "babylonjs/scene";
  37403. import { Vector3 } from "babylonjs/Maths/math";
  37404. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37405. /**
  37406. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37407. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37408. */
  37409. export class AnaglyphFreeCamera extends FreeCamera {
  37410. /**
  37411. * Creates a new AnaglyphFreeCamera
  37412. * @param name defines camera name
  37413. * @param position defines initial position
  37414. * @param interaxialDistance defines distance between each color axis
  37415. * @param scene defines the hosting scene
  37416. */
  37417. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37418. /**
  37419. * Gets camera class name
  37420. * @returns AnaglyphFreeCamera
  37421. */
  37422. getClassName(): string;
  37423. }
  37424. }
  37425. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37426. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37427. import { Scene } from "babylonjs/scene";
  37428. import { Vector3 } from "babylonjs/Maths/math";
  37429. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37430. /**
  37431. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37432. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37433. */
  37434. export class AnaglyphGamepadCamera extends GamepadCamera {
  37435. /**
  37436. * Creates a new AnaglyphGamepadCamera
  37437. * @param name defines camera name
  37438. * @param position defines initial position
  37439. * @param interaxialDistance defines distance between each color axis
  37440. * @param scene defines the hosting scene
  37441. */
  37442. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37443. /**
  37444. * Gets camera class name
  37445. * @returns AnaglyphGamepadCamera
  37446. */
  37447. getClassName(): string;
  37448. }
  37449. }
  37450. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37451. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37452. import { Scene } from "babylonjs/scene";
  37453. import { Vector3 } from "babylonjs/Maths/math";
  37454. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37455. /**
  37456. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37458. */
  37459. export class AnaglyphUniversalCamera extends UniversalCamera {
  37460. /**
  37461. * Creates a new AnaglyphUniversalCamera
  37462. * @param name defines camera name
  37463. * @param position defines initial position
  37464. * @param interaxialDistance defines distance between each color axis
  37465. * @param scene defines the hosting scene
  37466. */
  37467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37468. /**
  37469. * Gets camera class name
  37470. * @returns AnaglyphUniversalCamera
  37471. */
  37472. getClassName(): string;
  37473. }
  37474. }
  37475. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37476. /** @hidden */
  37477. export var stereoscopicInterlacePixelShader: {
  37478. name: string;
  37479. shader: string;
  37480. };
  37481. }
  37482. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37483. import { Camera } from "babylonjs/Cameras/camera";
  37484. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37485. import { Engine } from "babylonjs/Engines/engine";
  37486. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37487. /**
  37488. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37489. */
  37490. export class StereoscopicInterlacePostProcess extends PostProcess {
  37491. private _stepSize;
  37492. private _passedProcess;
  37493. /**
  37494. * Initializes a StereoscopicInterlacePostProcess
  37495. * @param name The name of the effect.
  37496. * @param rigCameras The rig cameras to be appled to the post process
  37497. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37499. * @param engine The engine which the post process will be applied. (default: current engine)
  37500. * @param reusable If the post process can be reused on the same frame. (default: false)
  37501. */
  37502. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37506. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37507. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37508. import { Scene } from "babylonjs/scene";
  37509. import { Vector3 } from "babylonjs/Maths/math";
  37510. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37511. /**
  37512. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37513. * @see http://doc.babylonjs.com/features/cameras
  37514. */
  37515. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37516. /**
  37517. * Creates a new StereoscopicArcRotateCamera
  37518. * @param name defines camera name
  37519. * @param alpha defines alpha angle (in radians)
  37520. * @param beta defines beta angle (in radians)
  37521. * @param radius defines radius
  37522. * @param target defines camera target
  37523. * @param interaxialDistance defines distance between each color axis
  37524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37525. * @param scene defines the hosting scene
  37526. */
  37527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37528. /**
  37529. * Gets camera class name
  37530. * @returns StereoscopicArcRotateCamera
  37531. */
  37532. getClassName(): string;
  37533. }
  37534. }
  37535. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37537. import { Scene } from "babylonjs/scene";
  37538. import { Vector3 } from "babylonjs/Maths/math";
  37539. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37540. /**
  37541. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37542. * @see http://doc.babylonjs.com/features/cameras
  37543. */
  37544. export class StereoscopicFreeCamera extends FreeCamera {
  37545. /**
  37546. * Creates a new StereoscopicFreeCamera
  37547. * @param name defines camera name
  37548. * @param position defines initial position
  37549. * @param interaxialDistance defines distance between each color axis
  37550. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37551. * @param scene defines the hosting scene
  37552. */
  37553. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37554. /**
  37555. * Gets camera class name
  37556. * @returns StereoscopicFreeCamera
  37557. */
  37558. getClassName(): string;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37562. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37566. /**
  37567. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37568. * @see http://doc.babylonjs.com/features/cameras
  37569. */
  37570. export class StereoscopicGamepadCamera extends GamepadCamera {
  37571. /**
  37572. * Creates a new StereoscopicGamepadCamera
  37573. * @param name defines camera name
  37574. * @param position defines initial position
  37575. * @param interaxialDistance defines distance between each color axis
  37576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37577. * @param scene defines the hosting scene
  37578. */
  37579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37580. /**
  37581. * Gets camera class name
  37582. * @returns StereoscopicGamepadCamera
  37583. */
  37584. getClassName(): string;
  37585. }
  37586. }
  37587. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37588. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37589. import { Scene } from "babylonjs/scene";
  37590. import { Vector3 } from "babylonjs/Maths/math";
  37591. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37592. /**
  37593. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37594. * @see http://doc.babylonjs.com/features/cameras
  37595. */
  37596. export class StereoscopicUniversalCamera extends UniversalCamera {
  37597. /**
  37598. * Creates a new StereoscopicUniversalCamera
  37599. * @param name defines camera name
  37600. * @param position defines initial position
  37601. * @param interaxialDistance defines distance between each color axis
  37602. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37603. * @param scene defines the hosting scene
  37604. */
  37605. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37606. /**
  37607. * Gets camera class name
  37608. * @returns StereoscopicUniversalCamera
  37609. */
  37610. getClassName(): string;
  37611. }
  37612. }
  37613. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37614. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37615. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37616. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37617. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37618. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37619. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37620. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37621. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37622. }
  37623. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37625. import { Scene } from "babylonjs/scene";
  37626. import { Vector3 } from "babylonjs/Maths/math";
  37627. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37628. /**
  37629. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37630. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37631. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37632. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37633. */
  37634. export class VirtualJoysticksCamera extends FreeCamera {
  37635. /**
  37636. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37637. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37638. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37639. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37640. * @param name Define the name of the camera in the scene
  37641. * @param position Define the start position of the camera in the scene
  37642. * @param scene Define the scene the camera belongs to
  37643. */
  37644. constructor(name: string, position: Vector3, scene: Scene);
  37645. /**
  37646. * Gets the current object class name.
  37647. * @return the class name
  37648. */
  37649. getClassName(): string;
  37650. }
  37651. }
  37652. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37653. import { Matrix } from "babylonjs/Maths/math";
  37654. /**
  37655. * This represents all the required metrics to create a VR camera.
  37656. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37657. */
  37658. export class VRCameraMetrics {
  37659. /**
  37660. * Define the horizontal resolution off the screen.
  37661. */
  37662. hResolution: number;
  37663. /**
  37664. * Define the vertical resolution off the screen.
  37665. */
  37666. vResolution: number;
  37667. /**
  37668. * Define the horizontal screen size.
  37669. */
  37670. hScreenSize: number;
  37671. /**
  37672. * Define the vertical screen size.
  37673. */
  37674. vScreenSize: number;
  37675. /**
  37676. * Define the vertical screen center position.
  37677. */
  37678. vScreenCenter: number;
  37679. /**
  37680. * Define the distance of the eyes to the screen.
  37681. */
  37682. eyeToScreenDistance: number;
  37683. /**
  37684. * Define the distance between both lenses
  37685. */
  37686. lensSeparationDistance: number;
  37687. /**
  37688. * Define the distance between both viewer's eyes.
  37689. */
  37690. interpupillaryDistance: number;
  37691. /**
  37692. * Define the distortion factor of the VR postprocess.
  37693. * Please, touch with care.
  37694. */
  37695. distortionK: number[];
  37696. /**
  37697. * Define the chromatic aberration correction factors for the VR post process.
  37698. */
  37699. chromaAbCorrection: number[];
  37700. /**
  37701. * Define the scale factor of the post process.
  37702. * The smaller the better but the slower.
  37703. */
  37704. postProcessScaleFactor: number;
  37705. /**
  37706. * Define an offset for the lens center.
  37707. */
  37708. lensCenterOffset: number;
  37709. /**
  37710. * Define if the current vr camera should compensate the distortion of the lense or not.
  37711. */
  37712. compensateDistortion: boolean;
  37713. /**
  37714. * Gets the rendering aspect ratio based on the provided resolutions.
  37715. */
  37716. readonly aspectRatio: number;
  37717. /**
  37718. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37719. */
  37720. readonly aspectRatioFov: number;
  37721. /**
  37722. * @hidden
  37723. */
  37724. readonly leftHMatrix: Matrix;
  37725. /**
  37726. * @hidden
  37727. */
  37728. readonly rightHMatrix: Matrix;
  37729. /**
  37730. * @hidden
  37731. */
  37732. readonly leftPreViewMatrix: Matrix;
  37733. /**
  37734. * @hidden
  37735. */
  37736. readonly rightPreViewMatrix: Matrix;
  37737. /**
  37738. * Get the default VRMetrics based on the most generic setup.
  37739. * @returns the default vr metrics
  37740. */
  37741. static GetDefault(): VRCameraMetrics;
  37742. }
  37743. }
  37744. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37745. /** @hidden */
  37746. export var vrDistortionCorrectionPixelShader: {
  37747. name: string;
  37748. shader: string;
  37749. };
  37750. }
  37751. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37752. import { Camera } from "babylonjs/Cameras/camera";
  37753. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37755. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37756. /**
  37757. * VRDistortionCorrectionPostProcess used for mobile VR
  37758. */
  37759. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37760. private _isRightEye;
  37761. private _distortionFactors;
  37762. private _postProcessScaleFactor;
  37763. private _lensCenterOffset;
  37764. private _scaleIn;
  37765. private _scaleFactor;
  37766. private _lensCenter;
  37767. /**
  37768. * Initializes the VRDistortionCorrectionPostProcess
  37769. * @param name The name of the effect.
  37770. * @param camera The camera to apply the render pass to.
  37771. * @param isRightEye If this is for the right eye distortion
  37772. * @param vrMetrics All the required metrics for the VR camera
  37773. */
  37774. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37775. }
  37776. }
  37777. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37778. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37779. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37780. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37781. import { Scene } from "babylonjs/scene";
  37782. import { Vector3 } from "babylonjs/Maths/math";
  37783. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37784. import "babylonjs/Cameras/RigModes/vrRigMode";
  37785. /**
  37786. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37787. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37788. */
  37789. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37790. /**
  37791. * Creates a new VRDeviceOrientationArcRotateCamera
  37792. * @param name defines camera name
  37793. * @param alpha defines the camera rotation along the logitudinal axis
  37794. * @param beta defines the camera rotation along the latitudinal axis
  37795. * @param radius defines the camera distance from its target
  37796. * @param target defines the camera target
  37797. * @param scene defines the scene the camera belongs to
  37798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37800. */
  37801. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37802. /**
  37803. * Gets camera class name
  37804. * @returns VRDeviceOrientationArcRotateCamera
  37805. */
  37806. getClassName(): string;
  37807. }
  37808. }
  37809. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37810. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37811. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37812. import { Scene } from "babylonjs/scene";
  37813. import { Vector3 } from "babylonjs/Maths/math";
  37814. import "babylonjs/Cameras/RigModes/vrRigMode";
  37815. /**
  37816. * Camera used to simulate VR rendering (based on FreeCamera)
  37817. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37818. */
  37819. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37820. /**
  37821. * Creates a new VRDeviceOrientationFreeCamera
  37822. * @param name defines camera name
  37823. * @param position defines the start position of the camera
  37824. * @param scene defines the scene the camera belongs to
  37825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37827. */
  37828. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37829. /**
  37830. * Gets camera class name
  37831. * @returns VRDeviceOrientationFreeCamera
  37832. */
  37833. getClassName(): string;
  37834. }
  37835. }
  37836. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37837. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37838. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37839. import { Scene } from "babylonjs/scene";
  37840. import { Vector3 } from "babylonjs/Maths/math";
  37841. /**
  37842. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37843. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37844. */
  37845. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37846. /**
  37847. * Creates a new VRDeviceOrientationGamepadCamera
  37848. * @param name defines camera name
  37849. * @param position defines the start position of the camera
  37850. * @param scene defines the scene the camera belongs to
  37851. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37852. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37853. */
  37854. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37855. /**
  37856. * Gets camera class name
  37857. * @returns VRDeviceOrientationGamepadCamera
  37858. */
  37859. getClassName(): string;
  37860. }
  37861. }
  37862. declare module "babylonjs/Gamepads/xboxGamepad" {
  37863. import { Observable } from "babylonjs/Misc/observable";
  37864. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37865. /**
  37866. * Defines supported buttons for XBox360 compatible gamepads
  37867. */
  37868. export enum Xbox360Button {
  37869. /** A */
  37870. A = 0,
  37871. /** B */
  37872. B = 1,
  37873. /** X */
  37874. X = 2,
  37875. /** Y */
  37876. Y = 3,
  37877. /** Start */
  37878. Start = 4,
  37879. /** Back */
  37880. Back = 5,
  37881. /** Left button */
  37882. LB = 6,
  37883. /** Right button */
  37884. RB = 7,
  37885. /** Left stick */
  37886. LeftStick = 8,
  37887. /** Right stick */
  37888. RightStick = 9
  37889. }
  37890. /** Defines values for XBox360 DPad */
  37891. export enum Xbox360Dpad {
  37892. /** Up */
  37893. Up = 0,
  37894. /** Down */
  37895. Down = 1,
  37896. /** Left */
  37897. Left = 2,
  37898. /** Right */
  37899. Right = 3
  37900. }
  37901. /**
  37902. * Defines a XBox360 gamepad
  37903. */
  37904. export class Xbox360Pad extends Gamepad {
  37905. private _leftTrigger;
  37906. private _rightTrigger;
  37907. private _onlefttriggerchanged;
  37908. private _onrighttriggerchanged;
  37909. private _onbuttondown;
  37910. private _onbuttonup;
  37911. private _ondpaddown;
  37912. private _ondpadup;
  37913. /** Observable raised when a button is pressed */
  37914. onButtonDownObservable: Observable<Xbox360Button>;
  37915. /** Observable raised when a button is released */
  37916. onButtonUpObservable: Observable<Xbox360Button>;
  37917. /** Observable raised when a pad is pressed */
  37918. onPadDownObservable: Observable<Xbox360Dpad>;
  37919. /** Observable raised when a pad is released */
  37920. onPadUpObservable: Observable<Xbox360Dpad>;
  37921. private _buttonA;
  37922. private _buttonB;
  37923. private _buttonX;
  37924. private _buttonY;
  37925. private _buttonBack;
  37926. private _buttonStart;
  37927. private _buttonLB;
  37928. private _buttonRB;
  37929. private _buttonLeftStick;
  37930. private _buttonRightStick;
  37931. private _dPadUp;
  37932. private _dPadDown;
  37933. private _dPadLeft;
  37934. private _dPadRight;
  37935. private _isXboxOnePad;
  37936. /**
  37937. * Creates a new XBox360 gamepad object
  37938. * @param id defines the id of this gamepad
  37939. * @param index defines its index
  37940. * @param gamepad defines the internal HTML gamepad object
  37941. * @param xboxOne defines if it is a XBox One gamepad
  37942. */
  37943. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37944. /**
  37945. * Defines the callback to call when left trigger is pressed
  37946. * @param callback defines the callback to use
  37947. */
  37948. onlefttriggerchanged(callback: (value: number) => void): void;
  37949. /**
  37950. * Defines the callback to call when right trigger is pressed
  37951. * @param callback defines the callback to use
  37952. */
  37953. onrighttriggerchanged(callback: (value: number) => void): void;
  37954. /**
  37955. * Gets the left trigger value
  37956. */
  37957. /**
  37958. * Sets the left trigger value
  37959. */
  37960. leftTrigger: number;
  37961. /**
  37962. * Gets the right trigger value
  37963. */
  37964. /**
  37965. * Sets the right trigger value
  37966. */
  37967. rightTrigger: number;
  37968. /**
  37969. * Defines the callback to call when a button is pressed
  37970. * @param callback defines the callback to use
  37971. */
  37972. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37973. /**
  37974. * Defines the callback to call when a button is released
  37975. * @param callback defines the callback to use
  37976. */
  37977. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37978. /**
  37979. * Defines the callback to call when a pad is pressed
  37980. * @param callback defines the callback to use
  37981. */
  37982. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37983. /**
  37984. * Defines the callback to call when a pad is released
  37985. * @param callback defines the callback to use
  37986. */
  37987. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37988. private _setButtonValue;
  37989. private _setDPadValue;
  37990. /**
  37991. * Gets the value of the `A` button
  37992. */
  37993. /**
  37994. * Sets the value of the `A` button
  37995. */
  37996. buttonA: number;
  37997. /**
  37998. * Gets the value of the `B` button
  37999. */
  38000. /**
  38001. * Sets the value of the `B` button
  38002. */
  38003. buttonB: number;
  38004. /**
  38005. * Gets the value of the `X` button
  38006. */
  38007. /**
  38008. * Sets the value of the `X` button
  38009. */
  38010. buttonX: number;
  38011. /**
  38012. * Gets the value of the `Y` button
  38013. */
  38014. /**
  38015. * Sets the value of the `Y` button
  38016. */
  38017. buttonY: number;
  38018. /**
  38019. * Gets the value of the `Start` button
  38020. */
  38021. /**
  38022. * Sets the value of the `Start` button
  38023. */
  38024. buttonStart: number;
  38025. /**
  38026. * Gets the value of the `Back` button
  38027. */
  38028. /**
  38029. * Sets the value of the `Back` button
  38030. */
  38031. buttonBack: number;
  38032. /**
  38033. * Gets the value of the `Left` button
  38034. */
  38035. /**
  38036. * Sets the value of the `Left` button
  38037. */
  38038. buttonLB: number;
  38039. /**
  38040. * Gets the value of the `Right` button
  38041. */
  38042. /**
  38043. * Sets the value of the `Right` button
  38044. */
  38045. buttonRB: number;
  38046. /**
  38047. * Gets the value of the Left joystick
  38048. */
  38049. /**
  38050. * Sets the value of the Left joystick
  38051. */
  38052. buttonLeftStick: number;
  38053. /**
  38054. * Gets the value of the Right joystick
  38055. */
  38056. /**
  38057. * Sets the value of the Right joystick
  38058. */
  38059. buttonRightStick: number;
  38060. /**
  38061. * Gets the value of D-pad up
  38062. */
  38063. /**
  38064. * Sets the value of D-pad up
  38065. */
  38066. dPadUp: number;
  38067. /**
  38068. * Gets the value of D-pad down
  38069. */
  38070. /**
  38071. * Sets the value of D-pad down
  38072. */
  38073. dPadDown: number;
  38074. /**
  38075. * Gets the value of D-pad left
  38076. */
  38077. /**
  38078. * Sets the value of D-pad left
  38079. */
  38080. dPadLeft: number;
  38081. /**
  38082. * Gets the value of D-pad right
  38083. */
  38084. /**
  38085. * Sets the value of D-pad right
  38086. */
  38087. dPadRight: number;
  38088. /**
  38089. * Force the gamepad to synchronize with device values
  38090. */
  38091. update(): void;
  38092. /**
  38093. * Disposes the gamepad
  38094. */
  38095. dispose(): void;
  38096. }
  38097. }
  38098. declare module "babylonjs/Materials/pushMaterial" {
  38099. import { Nullable } from "babylonjs/types";
  38100. import { Scene } from "babylonjs/scene";
  38101. import { Matrix } from "babylonjs/Maths/math";
  38102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38103. import { Mesh } from "babylonjs/Meshes/mesh";
  38104. import { Material } from "babylonjs/Materials/material";
  38105. import { Effect } from "babylonjs/Materials/effect";
  38106. /**
  38107. * Base class of materials working in push mode in babylon JS
  38108. * @hidden
  38109. */
  38110. export class PushMaterial extends Material {
  38111. protected _activeEffect: Effect;
  38112. protected _normalMatrix: Matrix;
  38113. /**
  38114. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38115. * This means that the material can keep using a previous shader while a new one is being compiled.
  38116. * This is mostly used when shader parallel compilation is supported (true by default)
  38117. */
  38118. allowShaderHotSwapping: boolean;
  38119. constructor(name: string, scene: Scene);
  38120. getEffect(): Effect;
  38121. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38122. /**
  38123. * Binds the given world matrix to the active effect
  38124. *
  38125. * @param world the matrix to bind
  38126. */
  38127. bindOnlyWorldMatrix(world: Matrix): void;
  38128. /**
  38129. * Binds the given normal matrix to the active effect
  38130. *
  38131. * @param normalMatrix the matrix to bind
  38132. */
  38133. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38134. bind(world: Matrix, mesh?: Mesh): void;
  38135. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38136. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38137. }
  38138. }
  38139. declare module "babylonjs/Materials/materialFlags" {
  38140. /**
  38141. * This groups all the flags used to control the materials channel.
  38142. */
  38143. export class MaterialFlags {
  38144. private static _DiffuseTextureEnabled;
  38145. /**
  38146. * Are diffuse textures enabled in the application.
  38147. */
  38148. static DiffuseTextureEnabled: boolean;
  38149. private static _AmbientTextureEnabled;
  38150. /**
  38151. * Are ambient textures enabled in the application.
  38152. */
  38153. static AmbientTextureEnabled: boolean;
  38154. private static _OpacityTextureEnabled;
  38155. /**
  38156. * Are opacity textures enabled in the application.
  38157. */
  38158. static OpacityTextureEnabled: boolean;
  38159. private static _ReflectionTextureEnabled;
  38160. /**
  38161. * Are reflection textures enabled in the application.
  38162. */
  38163. static ReflectionTextureEnabled: boolean;
  38164. private static _EmissiveTextureEnabled;
  38165. /**
  38166. * Are emissive textures enabled in the application.
  38167. */
  38168. static EmissiveTextureEnabled: boolean;
  38169. private static _SpecularTextureEnabled;
  38170. /**
  38171. * Are specular textures enabled in the application.
  38172. */
  38173. static SpecularTextureEnabled: boolean;
  38174. private static _BumpTextureEnabled;
  38175. /**
  38176. * Are bump textures enabled in the application.
  38177. */
  38178. static BumpTextureEnabled: boolean;
  38179. private static _LightmapTextureEnabled;
  38180. /**
  38181. * Are lightmap textures enabled in the application.
  38182. */
  38183. static LightmapTextureEnabled: boolean;
  38184. private static _RefractionTextureEnabled;
  38185. /**
  38186. * Are refraction textures enabled in the application.
  38187. */
  38188. static RefractionTextureEnabled: boolean;
  38189. private static _ColorGradingTextureEnabled;
  38190. /**
  38191. * Are color grading textures enabled in the application.
  38192. */
  38193. static ColorGradingTextureEnabled: boolean;
  38194. private static _FresnelEnabled;
  38195. /**
  38196. * Are fresnels enabled in the application.
  38197. */
  38198. static FresnelEnabled: boolean;
  38199. private static _ClearCoatTextureEnabled;
  38200. /**
  38201. * Are clear coat textures enabled in the application.
  38202. */
  38203. static ClearCoatTextureEnabled: boolean;
  38204. private static _ClearCoatBumpTextureEnabled;
  38205. /**
  38206. * Are clear coat bump textures enabled in the application.
  38207. */
  38208. static ClearCoatBumpTextureEnabled: boolean;
  38209. }
  38210. }
  38211. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38212. /** @hidden */
  38213. export var defaultFragmentDeclaration: {
  38214. name: string;
  38215. shader: string;
  38216. };
  38217. }
  38218. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38219. /** @hidden */
  38220. export var defaultUboDeclaration: {
  38221. name: string;
  38222. shader: string;
  38223. };
  38224. }
  38225. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38226. /** @hidden */
  38227. export var lightFragmentDeclaration: {
  38228. name: string;
  38229. shader: string;
  38230. };
  38231. }
  38232. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38233. /** @hidden */
  38234. export var lightUboDeclaration: {
  38235. name: string;
  38236. shader: string;
  38237. };
  38238. }
  38239. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38240. /** @hidden */
  38241. export var lightsFragmentFunctions: {
  38242. name: string;
  38243. shader: string;
  38244. };
  38245. }
  38246. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38247. /** @hidden */
  38248. export var shadowsFragmentFunctions: {
  38249. name: string;
  38250. shader: string;
  38251. };
  38252. }
  38253. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38254. /** @hidden */
  38255. export var fresnelFunction: {
  38256. name: string;
  38257. shader: string;
  38258. };
  38259. }
  38260. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38261. /** @hidden */
  38262. export var reflectionFunction: {
  38263. name: string;
  38264. shader: string;
  38265. };
  38266. }
  38267. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38268. /** @hidden */
  38269. export var bumpFragmentFunctions: {
  38270. name: string;
  38271. shader: string;
  38272. };
  38273. }
  38274. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38275. /** @hidden */
  38276. export var logDepthDeclaration: {
  38277. name: string;
  38278. shader: string;
  38279. };
  38280. }
  38281. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38282. /** @hidden */
  38283. export var bumpFragment: {
  38284. name: string;
  38285. shader: string;
  38286. };
  38287. }
  38288. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38289. /** @hidden */
  38290. export var depthPrePass: {
  38291. name: string;
  38292. shader: string;
  38293. };
  38294. }
  38295. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38296. /** @hidden */
  38297. export var lightFragment: {
  38298. name: string;
  38299. shader: string;
  38300. };
  38301. }
  38302. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38303. /** @hidden */
  38304. export var logDepthFragment: {
  38305. name: string;
  38306. shader: string;
  38307. };
  38308. }
  38309. declare module "babylonjs/Shaders/default.fragment" {
  38310. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38311. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38312. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38315. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38316. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38317. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38318. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38319. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38320. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38321. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38323. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38324. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38326. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38327. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38328. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38329. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38330. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38331. /** @hidden */
  38332. export var defaultPixelShader: {
  38333. name: string;
  38334. shader: string;
  38335. };
  38336. }
  38337. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38338. /** @hidden */
  38339. export var defaultVertexDeclaration: {
  38340. name: string;
  38341. shader: string;
  38342. };
  38343. }
  38344. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38345. /** @hidden */
  38346. export var bumpVertexDeclaration: {
  38347. name: string;
  38348. shader: string;
  38349. };
  38350. }
  38351. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38352. /** @hidden */
  38353. export var bumpVertex: {
  38354. name: string;
  38355. shader: string;
  38356. };
  38357. }
  38358. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38359. /** @hidden */
  38360. export var fogVertex: {
  38361. name: string;
  38362. shader: string;
  38363. };
  38364. }
  38365. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38366. /** @hidden */
  38367. export var shadowsVertex: {
  38368. name: string;
  38369. shader: string;
  38370. };
  38371. }
  38372. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38373. /** @hidden */
  38374. export var pointCloudVertex: {
  38375. name: string;
  38376. shader: string;
  38377. };
  38378. }
  38379. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38380. /** @hidden */
  38381. export var logDepthVertex: {
  38382. name: string;
  38383. shader: string;
  38384. };
  38385. }
  38386. declare module "babylonjs/Shaders/default.vertex" {
  38387. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38388. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38390. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38391. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38392. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38393. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38394. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38395. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38396. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38399. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38403. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38404. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38405. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38406. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38407. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38408. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38409. /** @hidden */
  38410. export var defaultVertexShader: {
  38411. name: string;
  38412. shader: string;
  38413. };
  38414. }
  38415. declare module "babylonjs/Materials/standardMaterial" {
  38416. import { SmartArray } from "babylonjs/Misc/smartArray";
  38417. import { IAnimatable } from "babylonjs/Misc/tools";
  38418. import { Nullable } from "babylonjs/types";
  38419. import { Scene } from "babylonjs/scene";
  38420. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38423. import { Mesh } from "babylonjs/Meshes/mesh";
  38424. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38425. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38426. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38427. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38428. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38431. import "babylonjs/Shaders/default.fragment";
  38432. import "babylonjs/Shaders/default.vertex";
  38433. /** @hidden */
  38434. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38435. MAINUV1: boolean;
  38436. MAINUV2: boolean;
  38437. DIFFUSE: boolean;
  38438. DIFFUSEDIRECTUV: number;
  38439. AMBIENT: boolean;
  38440. AMBIENTDIRECTUV: number;
  38441. OPACITY: boolean;
  38442. OPACITYDIRECTUV: number;
  38443. OPACITYRGB: boolean;
  38444. REFLECTION: boolean;
  38445. EMISSIVE: boolean;
  38446. EMISSIVEDIRECTUV: number;
  38447. SPECULAR: boolean;
  38448. SPECULARDIRECTUV: number;
  38449. BUMP: boolean;
  38450. BUMPDIRECTUV: number;
  38451. PARALLAX: boolean;
  38452. PARALLAXOCCLUSION: boolean;
  38453. SPECULAROVERALPHA: boolean;
  38454. CLIPPLANE: boolean;
  38455. CLIPPLANE2: boolean;
  38456. CLIPPLANE3: boolean;
  38457. CLIPPLANE4: boolean;
  38458. ALPHATEST: boolean;
  38459. DEPTHPREPASS: boolean;
  38460. ALPHAFROMDIFFUSE: boolean;
  38461. POINTSIZE: boolean;
  38462. FOG: boolean;
  38463. SPECULARTERM: boolean;
  38464. DIFFUSEFRESNEL: boolean;
  38465. OPACITYFRESNEL: boolean;
  38466. REFLECTIONFRESNEL: boolean;
  38467. REFRACTIONFRESNEL: boolean;
  38468. EMISSIVEFRESNEL: boolean;
  38469. FRESNEL: boolean;
  38470. NORMAL: boolean;
  38471. UV1: boolean;
  38472. UV2: boolean;
  38473. VERTEXCOLOR: boolean;
  38474. VERTEXALPHA: boolean;
  38475. NUM_BONE_INFLUENCERS: number;
  38476. BonesPerMesh: number;
  38477. BONETEXTURE: boolean;
  38478. INSTANCES: boolean;
  38479. GLOSSINESS: boolean;
  38480. ROUGHNESS: boolean;
  38481. EMISSIVEASILLUMINATION: boolean;
  38482. LINKEMISSIVEWITHDIFFUSE: boolean;
  38483. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38484. LIGHTMAP: boolean;
  38485. LIGHTMAPDIRECTUV: number;
  38486. OBJECTSPACE_NORMALMAP: boolean;
  38487. USELIGHTMAPASSHADOWMAP: boolean;
  38488. REFLECTIONMAP_3D: boolean;
  38489. REFLECTIONMAP_SPHERICAL: boolean;
  38490. REFLECTIONMAP_PLANAR: boolean;
  38491. REFLECTIONMAP_CUBIC: boolean;
  38492. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38493. REFLECTIONMAP_PROJECTION: boolean;
  38494. REFLECTIONMAP_SKYBOX: boolean;
  38495. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38496. REFLECTIONMAP_EXPLICIT: boolean;
  38497. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38498. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38499. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38500. INVERTCUBICMAP: boolean;
  38501. LOGARITHMICDEPTH: boolean;
  38502. REFRACTION: boolean;
  38503. REFRACTIONMAP_3D: boolean;
  38504. REFLECTIONOVERALPHA: boolean;
  38505. TWOSIDEDLIGHTING: boolean;
  38506. SHADOWFLOAT: boolean;
  38507. MORPHTARGETS: boolean;
  38508. MORPHTARGETS_NORMAL: boolean;
  38509. MORPHTARGETS_TANGENT: boolean;
  38510. NUM_MORPH_INFLUENCERS: number;
  38511. NONUNIFORMSCALING: boolean;
  38512. PREMULTIPLYALPHA: boolean;
  38513. IMAGEPROCESSING: boolean;
  38514. VIGNETTE: boolean;
  38515. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38516. VIGNETTEBLENDMODEOPAQUE: boolean;
  38517. TONEMAPPING: boolean;
  38518. TONEMAPPING_ACES: boolean;
  38519. CONTRAST: boolean;
  38520. COLORCURVES: boolean;
  38521. COLORGRADING: boolean;
  38522. COLORGRADING3D: boolean;
  38523. SAMPLER3DGREENDEPTH: boolean;
  38524. SAMPLER3DBGRMAP: boolean;
  38525. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38526. /**
  38527. * If the reflection texture on this material is in linear color space
  38528. * @hidden
  38529. */
  38530. IS_REFLECTION_LINEAR: boolean;
  38531. /**
  38532. * If the refraction texture on this material is in linear color space
  38533. * @hidden
  38534. */
  38535. IS_REFRACTION_LINEAR: boolean;
  38536. EXPOSURE: boolean;
  38537. constructor();
  38538. setReflectionMode(modeToEnable: string): void;
  38539. }
  38540. /**
  38541. * This is the default material used in Babylon. It is the best trade off between quality
  38542. * and performances.
  38543. * @see http://doc.babylonjs.com/babylon101/materials
  38544. */
  38545. export class StandardMaterial extends PushMaterial {
  38546. private _diffuseTexture;
  38547. /**
  38548. * The basic texture of the material as viewed under a light.
  38549. */
  38550. diffuseTexture: Nullable<BaseTexture>;
  38551. private _ambientTexture;
  38552. /**
  38553. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38554. */
  38555. ambientTexture: Nullable<BaseTexture>;
  38556. private _opacityTexture;
  38557. /**
  38558. * Define the transparency of the material from a texture.
  38559. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38560. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38561. */
  38562. opacityTexture: Nullable<BaseTexture>;
  38563. private _reflectionTexture;
  38564. /**
  38565. * Define the texture used to display the reflection.
  38566. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38567. */
  38568. reflectionTexture: Nullable<BaseTexture>;
  38569. private _emissiveTexture;
  38570. /**
  38571. * Define texture of the material as if self lit.
  38572. * This will be mixed in the final result even in the absence of light.
  38573. */
  38574. emissiveTexture: Nullable<BaseTexture>;
  38575. private _specularTexture;
  38576. /**
  38577. * Define how the color and intensity of the highlight given by the light in the material.
  38578. */
  38579. specularTexture: Nullable<BaseTexture>;
  38580. private _bumpTexture;
  38581. /**
  38582. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38583. * 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.
  38584. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38585. */
  38586. bumpTexture: Nullable<BaseTexture>;
  38587. private _lightmapTexture;
  38588. /**
  38589. * Complex lighting can be computationally expensive to compute at runtime.
  38590. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38591. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38592. */
  38593. lightmapTexture: Nullable<BaseTexture>;
  38594. private _refractionTexture;
  38595. /**
  38596. * Define the texture used to display the refraction.
  38597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38598. */
  38599. refractionTexture: Nullable<BaseTexture>;
  38600. /**
  38601. * The color of the material lit by the environmental background lighting.
  38602. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38603. */
  38604. ambientColor: Color3;
  38605. /**
  38606. * The basic color of the material as viewed under a light.
  38607. */
  38608. diffuseColor: Color3;
  38609. /**
  38610. * Define how the color and intensity of the highlight given by the light in the material.
  38611. */
  38612. specularColor: Color3;
  38613. /**
  38614. * Define the color of the material as if self lit.
  38615. * This will be mixed in the final result even in the absence of light.
  38616. */
  38617. emissiveColor: Color3;
  38618. /**
  38619. * Defines how sharp are the highlights in the material.
  38620. * The bigger the value the sharper giving a more glossy feeling to the result.
  38621. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38622. */
  38623. specularPower: number;
  38624. private _useAlphaFromDiffuseTexture;
  38625. /**
  38626. * Does the transparency come from the diffuse texture alpha channel.
  38627. */
  38628. useAlphaFromDiffuseTexture: boolean;
  38629. private _useEmissiveAsIllumination;
  38630. /**
  38631. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38632. */
  38633. useEmissiveAsIllumination: boolean;
  38634. private _linkEmissiveWithDiffuse;
  38635. /**
  38636. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38637. * the emissive level when the final color is close to one.
  38638. */
  38639. linkEmissiveWithDiffuse: boolean;
  38640. private _useSpecularOverAlpha;
  38641. /**
  38642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38644. */
  38645. useSpecularOverAlpha: boolean;
  38646. private _useReflectionOverAlpha;
  38647. /**
  38648. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38649. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38650. */
  38651. useReflectionOverAlpha: boolean;
  38652. private _disableLighting;
  38653. /**
  38654. * Does lights from the scene impacts this material.
  38655. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38656. */
  38657. disableLighting: boolean;
  38658. private _useObjectSpaceNormalMap;
  38659. /**
  38660. * Allows using an object space normal map (instead of tangent space).
  38661. */
  38662. useObjectSpaceNormalMap: boolean;
  38663. private _useParallax;
  38664. /**
  38665. * Is parallax enabled or not.
  38666. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38667. */
  38668. useParallax: boolean;
  38669. private _useParallaxOcclusion;
  38670. /**
  38671. * Is parallax occlusion enabled or not.
  38672. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38673. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38674. */
  38675. useParallaxOcclusion: boolean;
  38676. /**
  38677. * 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.
  38678. */
  38679. parallaxScaleBias: number;
  38680. private _roughness;
  38681. /**
  38682. * Helps to define how blurry the reflections should appears in the material.
  38683. */
  38684. roughness: number;
  38685. /**
  38686. * In case of refraction, define the value of the indice of refraction.
  38687. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38688. */
  38689. indexOfRefraction: number;
  38690. /**
  38691. * Invert the refraction texture alongside the y axis.
  38692. * It can be useful with procedural textures or probe for instance.
  38693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38694. */
  38695. invertRefractionY: boolean;
  38696. /**
  38697. * Defines the alpha limits in alpha test mode.
  38698. */
  38699. alphaCutOff: number;
  38700. private _useLightmapAsShadowmap;
  38701. /**
  38702. * In case of light mapping, define whether the map contains light or shadow informations.
  38703. */
  38704. useLightmapAsShadowmap: boolean;
  38705. private _diffuseFresnelParameters;
  38706. /**
  38707. * Define the diffuse fresnel parameters of the material.
  38708. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38709. */
  38710. diffuseFresnelParameters: FresnelParameters;
  38711. private _opacityFresnelParameters;
  38712. /**
  38713. * Define the opacity fresnel parameters of the material.
  38714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38715. */
  38716. opacityFresnelParameters: FresnelParameters;
  38717. private _reflectionFresnelParameters;
  38718. /**
  38719. * Define the reflection fresnel parameters of the material.
  38720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38721. */
  38722. reflectionFresnelParameters: FresnelParameters;
  38723. private _refractionFresnelParameters;
  38724. /**
  38725. * Define the refraction fresnel parameters of the material.
  38726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38727. */
  38728. refractionFresnelParameters: FresnelParameters;
  38729. private _emissiveFresnelParameters;
  38730. /**
  38731. * Define the emissive fresnel parameters of the material.
  38732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38733. */
  38734. emissiveFresnelParameters: FresnelParameters;
  38735. private _useReflectionFresnelFromSpecular;
  38736. /**
  38737. * If true automatically deducts the fresnels values from the material specularity.
  38738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38739. */
  38740. useReflectionFresnelFromSpecular: boolean;
  38741. private _useGlossinessFromSpecularMapAlpha;
  38742. /**
  38743. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38744. */
  38745. useGlossinessFromSpecularMapAlpha: boolean;
  38746. private _maxSimultaneousLights;
  38747. /**
  38748. * Defines the maximum number of lights that can be used in the material
  38749. */
  38750. maxSimultaneousLights: number;
  38751. private _invertNormalMapX;
  38752. /**
  38753. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38754. */
  38755. invertNormalMapX: boolean;
  38756. private _invertNormalMapY;
  38757. /**
  38758. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38759. */
  38760. invertNormalMapY: boolean;
  38761. private _twoSidedLighting;
  38762. /**
  38763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38764. */
  38765. twoSidedLighting: boolean;
  38766. /**
  38767. * Default configuration related to image processing available in the standard Material.
  38768. */
  38769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38770. /**
  38771. * Gets the image processing configuration used either in this material.
  38772. */
  38773. /**
  38774. * Sets the Default image processing configuration used either in the this material.
  38775. *
  38776. * If sets to null, the scene one is in use.
  38777. */
  38778. imageProcessingConfiguration: ImageProcessingConfiguration;
  38779. /**
  38780. * Keep track of the image processing observer to allow dispose and replace.
  38781. */
  38782. private _imageProcessingObserver;
  38783. /**
  38784. * Attaches a new image processing configuration to the Standard Material.
  38785. * @param configuration
  38786. */
  38787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38788. /**
  38789. * Gets wether the color curves effect is enabled.
  38790. */
  38791. /**
  38792. * Sets wether the color curves effect is enabled.
  38793. */
  38794. cameraColorCurvesEnabled: boolean;
  38795. /**
  38796. * Gets wether the color grading effect is enabled.
  38797. */
  38798. /**
  38799. * Gets wether the color grading effect is enabled.
  38800. */
  38801. cameraColorGradingEnabled: boolean;
  38802. /**
  38803. * Gets wether tonemapping is enabled or not.
  38804. */
  38805. /**
  38806. * Sets wether tonemapping is enabled or not
  38807. */
  38808. cameraToneMappingEnabled: boolean;
  38809. /**
  38810. * The camera exposure used on this material.
  38811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38812. * This corresponds to a photographic exposure.
  38813. */
  38814. /**
  38815. * The camera exposure used on this material.
  38816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38817. * This corresponds to a photographic exposure.
  38818. */
  38819. cameraExposure: number;
  38820. /**
  38821. * Gets The camera contrast used on this material.
  38822. */
  38823. /**
  38824. * Sets The camera contrast used on this material.
  38825. */
  38826. cameraContrast: number;
  38827. /**
  38828. * Gets the Color Grading 2D Lookup Texture.
  38829. */
  38830. /**
  38831. * Sets the Color Grading 2D Lookup Texture.
  38832. */
  38833. cameraColorGradingTexture: Nullable<BaseTexture>;
  38834. /**
  38835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38837. * 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;
  38838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38839. */
  38840. /**
  38841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38843. * 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;
  38844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38845. */
  38846. cameraColorCurves: Nullable<ColorCurves>;
  38847. /**
  38848. * Custom callback helping to override the default shader used in the material.
  38849. */
  38850. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38851. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38852. protected _worldViewProjectionMatrix: Matrix;
  38853. protected _globalAmbientColor: Color3;
  38854. protected _useLogarithmicDepth: boolean;
  38855. /**
  38856. * Instantiates a new standard material.
  38857. * This is the default material used in Babylon. It is the best trade off between quality
  38858. * and performances.
  38859. * @see http://doc.babylonjs.com/babylon101/materials
  38860. * @param name Define the name of the material in the scene
  38861. * @param scene Define the scene the material belong to
  38862. */
  38863. constructor(name: string, scene: Scene);
  38864. /**
  38865. * Gets a boolean indicating that current material needs to register RTT
  38866. */
  38867. readonly hasRenderTargetTextures: boolean;
  38868. /**
  38869. * Gets the current class name of the material e.g. "StandardMaterial"
  38870. * Mainly use in serialization.
  38871. * @returns the class name
  38872. */
  38873. getClassName(): string;
  38874. /**
  38875. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38876. * You can try switching to logarithmic depth.
  38877. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38878. */
  38879. useLogarithmicDepth: boolean;
  38880. /**
  38881. * Specifies if the material will require alpha blending
  38882. * @returns a boolean specifying if alpha blending is needed
  38883. */
  38884. needAlphaBlending(): boolean;
  38885. /**
  38886. * Specifies if this material should be rendered in alpha test mode
  38887. * @returns a boolean specifying if an alpha test is needed.
  38888. */
  38889. needAlphaTesting(): boolean;
  38890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38891. /**
  38892. * Get the texture used for alpha test purpose.
  38893. * @returns the diffuse texture in case of the standard material.
  38894. */
  38895. getAlphaTestTexture(): Nullable<BaseTexture>;
  38896. /**
  38897. * Get if the submesh is ready to be used and all its information available.
  38898. * Child classes can use it to update shaders
  38899. * @param mesh defines the mesh to check
  38900. * @param subMesh defines which submesh to check
  38901. * @param useInstances specifies that instances should be used
  38902. * @returns a boolean indicating that the submesh is ready or not
  38903. */
  38904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38905. /**
  38906. * Builds the material UBO layouts.
  38907. * Used internally during the effect preparation.
  38908. */
  38909. buildUniformLayout(): void;
  38910. /**
  38911. * Unbinds the material from the mesh
  38912. */
  38913. unbind(): void;
  38914. /**
  38915. * Binds the submesh to this material by preparing the effect and shader to draw
  38916. * @param world defines the world transformation matrix
  38917. * @param mesh defines the mesh containing the submesh
  38918. * @param subMesh defines the submesh to bind the material to
  38919. */
  38920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38921. /**
  38922. * Get the list of animatables in the material.
  38923. * @returns the list of animatables object used in the material
  38924. */
  38925. getAnimatables(): IAnimatable[];
  38926. /**
  38927. * Gets the active textures from the material
  38928. * @returns an array of textures
  38929. */
  38930. getActiveTextures(): BaseTexture[];
  38931. /**
  38932. * Specifies if the material uses a texture
  38933. * @param texture defines the texture to check against the material
  38934. * @returns a boolean specifying if the material uses the texture
  38935. */
  38936. hasTexture(texture: BaseTexture): boolean;
  38937. /**
  38938. * Disposes the material
  38939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38941. */
  38942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38943. /**
  38944. * Makes a duplicate of the material, and gives it a new name
  38945. * @param name defines the new name for the duplicated material
  38946. * @returns the cloned material
  38947. */
  38948. clone(name: string): StandardMaterial;
  38949. /**
  38950. * Serializes this material in a JSON representation
  38951. * @returns the serialized material object
  38952. */
  38953. serialize(): any;
  38954. /**
  38955. * Creates a standard material from parsed material data
  38956. * @param source defines the JSON representation of the material
  38957. * @param scene defines the hosting scene
  38958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38959. * @returns a new standard material
  38960. */
  38961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38962. /**
  38963. * Are diffuse textures enabled in the application.
  38964. */
  38965. static DiffuseTextureEnabled: boolean;
  38966. /**
  38967. * Are ambient textures enabled in the application.
  38968. */
  38969. static AmbientTextureEnabled: boolean;
  38970. /**
  38971. * Are opacity textures enabled in the application.
  38972. */
  38973. static OpacityTextureEnabled: boolean;
  38974. /**
  38975. * Are reflection textures enabled in the application.
  38976. */
  38977. static ReflectionTextureEnabled: boolean;
  38978. /**
  38979. * Are emissive textures enabled in the application.
  38980. */
  38981. static EmissiveTextureEnabled: boolean;
  38982. /**
  38983. * Are specular textures enabled in the application.
  38984. */
  38985. static SpecularTextureEnabled: boolean;
  38986. /**
  38987. * Are bump textures enabled in the application.
  38988. */
  38989. static BumpTextureEnabled: boolean;
  38990. /**
  38991. * Are lightmap textures enabled in the application.
  38992. */
  38993. static LightmapTextureEnabled: boolean;
  38994. /**
  38995. * Are refraction textures enabled in the application.
  38996. */
  38997. static RefractionTextureEnabled: boolean;
  38998. /**
  38999. * Are color grading textures enabled in the application.
  39000. */
  39001. static ColorGradingTextureEnabled: boolean;
  39002. /**
  39003. * Are fresnels enabled in the application.
  39004. */
  39005. static FresnelEnabled: boolean;
  39006. }
  39007. }
  39008. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39009. import { Scene } from "babylonjs/scene";
  39010. import { Texture } from "babylonjs/Materials/Textures/texture";
  39011. /**
  39012. * A class extending Texture allowing drawing on a texture
  39013. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39014. */
  39015. export class DynamicTexture extends Texture {
  39016. private _generateMipMaps;
  39017. private _canvas;
  39018. private _context;
  39019. private _engine;
  39020. /**
  39021. * Creates a DynamicTexture
  39022. * @param name defines the name of the texture
  39023. * @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
  39024. * @param scene defines the scene where you want the texture
  39025. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39026. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39027. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39028. */
  39029. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39030. /**
  39031. * Get the current class name of the texture useful for serialization or dynamic coding.
  39032. * @returns "DynamicTexture"
  39033. */
  39034. getClassName(): string;
  39035. /**
  39036. * Gets the current state of canRescale
  39037. */
  39038. readonly canRescale: boolean;
  39039. private _recreate;
  39040. /**
  39041. * Scales the texture
  39042. * @param ratio the scale factor to apply to both width and height
  39043. */
  39044. scale(ratio: number): void;
  39045. /**
  39046. * Resizes the texture
  39047. * @param width the new width
  39048. * @param height the new height
  39049. */
  39050. scaleTo(width: number, height: number): void;
  39051. /**
  39052. * Gets the context of the canvas used by the texture
  39053. * @returns the canvas context of the dynamic texture
  39054. */
  39055. getContext(): CanvasRenderingContext2D;
  39056. /**
  39057. * Clears the texture
  39058. */
  39059. clear(): void;
  39060. /**
  39061. * Updates the texture
  39062. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39063. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39064. */
  39065. update(invertY?: boolean, premulAlpha?: boolean): void;
  39066. /**
  39067. * Draws text onto the texture
  39068. * @param text defines the text to be drawn
  39069. * @param x defines the placement of the text from the left
  39070. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39071. * @param font defines the font to be used with font-style, font-size, font-name
  39072. * @param color defines the color used for the text
  39073. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39074. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39075. * @param update defines whether texture is immediately update (default is true)
  39076. */
  39077. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39078. /**
  39079. * Clones the texture
  39080. * @returns the clone of the texture.
  39081. */
  39082. clone(): DynamicTexture;
  39083. /**
  39084. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39085. * @returns a serialized dynamic texture object
  39086. */
  39087. serialize(): any;
  39088. /** @hidden */
  39089. _rebuild(): void;
  39090. }
  39091. }
  39092. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39093. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39094. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39095. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39096. /** @hidden */
  39097. export var imageProcessingPixelShader: {
  39098. name: string;
  39099. shader: string;
  39100. };
  39101. }
  39102. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39103. import { Nullable } from "babylonjs/types";
  39104. import { Color4 } from "babylonjs/Maths/math";
  39105. import { Camera } from "babylonjs/Cameras/camera";
  39106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39107. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39110. import { Engine } from "babylonjs/Engines/engine";
  39111. import "babylonjs/Shaders/imageProcessing.fragment";
  39112. import "babylonjs/Shaders/postprocess.vertex";
  39113. /**
  39114. * ImageProcessingPostProcess
  39115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39116. */
  39117. export class ImageProcessingPostProcess extends PostProcess {
  39118. /**
  39119. * Default configuration related to image processing available in the PBR Material.
  39120. */
  39121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39122. /**
  39123. * Gets the image processing configuration used either in this material.
  39124. */
  39125. /**
  39126. * Sets the Default image processing configuration used either in the this material.
  39127. *
  39128. * If sets to null, the scene one is in use.
  39129. */
  39130. imageProcessingConfiguration: ImageProcessingConfiguration;
  39131. /**
  39132. * Keep track of the image processing observer to allow dispose and replace.
  39133. */
  39134. private _imageProcessingObserver;
  39135. /**
  39136. * Attaches a new image processing configuration to the PBR Material.
  39137. * @param configuration
  39138. */
  39139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39140. /**
  39141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39142. */
  39143. /**
  39144. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39145. */
  39146. colorCurves: Nullable<ColorCurves>;
  39147. /**
  39148. * Gets wether the color curves effect is enabled.
  39149. */
  39150. /**
  39151. * Sets wether the color curves effect is enabled.
  39152. */
  39153. colorCurvesEnabled: boolean;
  39154. /**
  39155. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39156. */
  39157. /**
  39158. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39159. */
  39160. colorGradingTexture: Nullable<BaseTexture>;
  39161. /**
  39162. * Gets wether the color grading effect is enabled.
  39163. */
  39164. /**
  39165. * Gets wether the color grading effect is enabled.
  39166. */
  39167. colorGradingEnabled: boolean;
  39168. /**
  39169. * Gets exposure used in the effect.
  39170. */
  39171. /**
  39172. * Sets exposure used in the effect.
  39173. */
  39174. exposure: number;
  39175. /**
  39176. * Gets wether tonemapping is enabled or not.
  39177. */
  39178. /**
  39179. * Sets wether tonemapping is enabled or not
  39180. */
  39181. toneMappingEnabled: boolean;
  39182. /**
  39183. * Gets contrast used in the effect.
  39184. */
  39185. /**
  39186. * Sets contrast used in the effect.
  39187. */
  39188. contrast: number;
  39189. /**
  39190. * Gets Vignette stretch size.
  39191. */
  39192. /**
  39193. * Sets Vignette stretch size.
  39194. */
  39195. vignetteStretch: number;
  39196. /**
  39197. * Gets Vignette centre X Offset.
  39198. */
  39199. /**
  39200. * Sets Vignette centre X Offset.
  39201. */
  39202. vignetteCentreX: number;
  39203. /**
  39204. * Gets Vignette centre Y Offset.
  39205. */
  39206. /**
  39207. * Sets Vignette centre Y Offset.
  39208. */
  39209. vignetteCentreY: number;
  39210. /**
  39211. * Gets Vignette weight or intensity of the vignette effect.
  39212. */
  39213. /**
  39214. * Sets Vignette weight or intensity of the vignette effect.
  39215. */
  39216. vignetteWeight: number;
  39217. /**
  39218. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39219. * if vignetteEnabled is set to true.
  39220. */
  39221. /**
  39222. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39223. * if vignetteEnabled is set to true.
  39224. */
  39225. vignetteColor: Color4;
  39226. /**
  39227. * Gets Camera field of view used by the Vignette effect.
  39228. */
  39229. /**
  39230. * Sets Camera field of view used by the Vignette effect.
  39231. */
  39232. vignetteCameraFov: number;
  39233. /**
  39234. * Gets the vignette blend mode allowing different kind of effect.
  39235. */
  39236. /**
  39237. * Sets the vignette blend mode allowing different kind of effect.
  39238. */
  39239. vignetteBlendMode: number;
  39240. /**
  39241. * Gets wether the vignette effect is enabled.
  39242. */
  39243. /**
  39244. * Sets wether the vignette effect is enabled.
  39245. */
  39246. vignetteEnabled: boolean;
  39247. private _fromLinearSpace;
  39248. /**
  39249. * Gets wether the input of the processing is in Gamma or Linear Space.
  39250. */
  39251. /**
  39252. * Sets wether the input of the processing is in Gamma or Linear Space.
  39253. */
  39254. fromLinearSpace: boolean;
  39255. /**
  39256. * Defines cache preventing GC.
  39257. */
  39258. private _defines;
  39259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39260. /**
  39261. * "ImageProcessingPostProcess"
  39262. * @returns "ImageProcessingPostProcess"
  39263. */
  39264. getClassName(): string;
  39265. protected _updateParameters(): void;
  39266. dispose(camera?: Camera): void;
  39267. }
  39268. }
  39269. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39270. import { Scene } from "babylonjs/scene";
  39271. import { Color3 } from "babylonjs/Maths/math";
  39272. import { Mesh } from "babylonjs/Meshes/mesh";
  39273. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39274. /**
  39275. * Class containing static functions to help procedurally build meshes
  39276. */
  39277. export class GroundBuilder {
  39278. /**
  39279. * Creates a ground mesh
  39280. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39281. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39283. * @param name defines the name of the mesh
  39284. * @param options defines the options used to create the mesh
  39285. * @param scene defines the hosting scene
  39286. * @returns the ground mesh
  39287. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39288. */
  39289. static CreateGround(name: string, options: {
  39290. width?: number;
  39291. height?: number;
  39292. subdivisions?: number;
  39293. subdivisionsX?: number;
  39294. subdivisionsY?: number;
  39295. updatable?: boolean;
  39296. }, scene: any): Mesh;
  39297. /**
  39298. * Creates a tiled ground mesh
  39299. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39300. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39301. * * 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
  39302. * * 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
  39303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39304. * @param name defines the name of the mesh
  39305. * @param options defines the options used to create the mesh
  39306. * @param scene defines the hosting scene
  39307. * @returns the tiled ground mesh
  39308. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39309. */
  39310. static CreateTiledGround(name: string, options: {
  39311. xmin: number;
  39312. zmin: number;
  39313. xmax: number;
  39314. zmax: number;
  39315. subdivisions?: {
  39316. w: number;
  39317. h: number;
  39318. };
  39319. precision?: {
  39320. w: number;
  39321. h: number;
  39322. };
  39323. updatable?: boolean;
  39324. }, scene: Scene): Mesh;
  39325. /**
  39326. * Creates a ground mesh from a height map
  39327. * * The parameter `url` sets the URL of the height map image resource.
  39328. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39329. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39330. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39331. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39332. * * 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.
  39333. * * 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).
  39334. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39336. * @param name defines the name of the mesh
  39337. * @param url defines the url to the height map
  39338. * @param options defines the options used to create the mesh
  39339. * @param scene defines the hosting scene
  39340. * @returns the ground mesh
  39341. * @see https://doc.babylonjs.com/babylon101/height_map
  39342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39343. */
  39344. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39345. width?: number;
  39346. height?: number;
  39347. subdivisions?: number;
  39348. minHeight?: number;
  39349. maxHeight?: number;
  39350. colorFilter?: Color3;
  39351. alphaFilter?: number;
  39352. updatable?: boolean;
  39353. onReady?: (mesh: GroundMesh) => void;
  39354. }, scene: Scene): GroundMesh;
  39355. }
  39356. }
  39357. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39358. import { Vector4 } from "babylonjs/Maths/math";
  39359. import { Mesh } from "babylonjs/Meshes/mesh";
  39360. /**
  39361. * Class containing static functions to help procedurally build meshes
  39362. */
  39363. export class TorusBuilder {
  39364. /**
  39365. * Creates a torus mesh
  39366. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39367. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39368. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39372. * @param name defines the name of the mesh
  39373. * @param options defines the options used to create the mesh
  39374. * @param scene defines the hosting scene
  39375. * @returns the torus mesh
  39376. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39377. */
  39378. static CreateTorus(name: string, options: {
  39379. diameter?: number;
  39380. thickness?: number;
  39381. tessellation?: number;
  39382. updatable?: boolean;
  39383. sideOrientation?: number;
  39384. frontUVs?: Vector4;
  39385. backUVs?: Vector4;
  39386. }, scene: any): Mesh;
  39387. }
  39388. }
  39389. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39390. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39391. import { Mesh } from "babylonjs/Meshes/mesh";
  39392. /**
  39393. * Class containing static functions to help procedurally build meshes
  39394. */
  39395. export class CylinderBuilder {
  39396. /**
  39397. * Creates a cylinder or a cone mesh
  39398. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39399. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39400. * * 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.
  39401. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39402. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39403. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39404. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39405. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39406. * * 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).
  39407. * * 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
  39408. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39409. * * 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
  39410. * * 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.
  39411. * * If `enclose` is false, a ring surface is one element.
  39412. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39413. * * 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
  39414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39417. * @param name defines the name of the mesh
  39418. * @param options defines the options used to create the mesh
  39419. * @param scene defines the hosting scene
  39420. * @returns the cylinder mesh
  39421. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39422. */
  39423. static CreateCylinder(name: string, options: {
  39424. height?: number;
  39425. diameterTop?: number;
  39426. diameterBottom?: number;
  39427. diameter?: number;
  39428. tessellation?: number;
  39429. subdivisions?: number;
  39430. arc?: number;
  39431. faceColors?: Color4[];
  39432. faceUV?: Vector4[];
  39433. updatable?: boolean;
  39434. hasRings?: boolean;
  39435. enclose?: boolean;
  39436. sideOrientation?: number;
  39437. frontUVs?: Vector4;
  39438. backUVs?: Vector4;
  39439. }, scene: any): Mesh;
  39440. }
  39441. }
  39442. declare module "babylonjs/Gamepads/gamepadManager" {
  39443. import { Observable } from "babylonjs/Misc/observable";
  39444. import { Nullable } from "babylonjs/types";
  39445. import { Scene } from "babylonjs/scene";
  39446. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39447. /**
  39448. * Manager for handling gamepads
  39449. */
  39450. export class GamepadManager {
  39451. private _scene?;
  39452. private _babylonGamepads;
  39453. private _oneGamepadConnected;
  39454. /** @hidden */
  39455. _isMonitoring: boolean;
  39456. private _gamepadEventSupported;
  39457. private _gamepadSupport;
  39458. /**
  39459. * observable to be triggered when the gamepad controller has been connected
  39460. */
  39461. onGamepadConnectedObservable: Observable<Gamepad>;
  39462. /**
  39463. * observable to be triggered when the gamepad controller has been disconnected
  39464. */
  39465. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39466. private _onGamepadConnectedEvent;
  39467. private _onGamepadDisconnectedEvent;
  39468. /**
  39469. * Initializes the gamepad manager
  39470. * @param _scene BabylonJS scene
  39471. */
  39472. constructor(_scene?: Scene | undefined);
  39473. /**
  39474. * The gamepads in the game pad manager
  39475. */
  39476. readonly gamepads: Gamepad[];
  39477. /**
  39478. * Get the gamepad controllers based on type
  39479. * @param type The type of gamepad controller
  39480. * @returns Nullable gamepad
  39481. */
  39482. getGamepadByType(type?: number): Nullable<Gamepad>;
  39483. /**
  39484. * Disposes the gamepad manager
  39485. */
  39486. dispose(): void;
  39487. private _addNewGamepad;
  39488. private _startMonitoringGamepads;
  39489. private _stopMonitoringGamepads;
  39490. /** @hidden */
  39491. _checkGamepadsStatus(): void;
  39492. private _updateGamepadObjects;
  39493. }
  39494. }
  39495. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39496. import { Nullable } from "babylonjs/types";
  39497. import { Scene } from "babylonjs/scene";
  39498. import { ISceneComponent } from "babylonjs/sceneComponent";
  39499. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39500. module "babylonjs/scene" {
  39501. interface Scene {
  39502. /** @hidden */
  39503. _gamepadManager: Nullable<GamepadManager>;
  39504. /**
  39505. * Gets the gamepad manager associated with the scene
  39506. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39507. */
  39508. gamepadManager: GamepadManager;
  39509. }
  39510. }
  39511. module "babylonjs/Cameras/freeCameraInputsManager" {
  39512. /**
  39513. * Interface representing a free camera inputs manager
  39514. */
  39515. interface FreeCameraInputsManager {
  39516. /**
  39517. * Adds gamepad input support to the FreeCameraInputsManager.
  39518. * @returns the FreeCameraInputsManager
  39519. */
  39520. addGamepad(): FreeCameraInputsManager;
  39521. }
  39522. }
  39523. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39524. /**
  39525. * Interface representing an arc rotate camera inputs manager
  39526. */
  39527. interface ArcRotateCameraInputsManager {
  39528. /**
  39529. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39530. * @returns the camera inputs manager
  39531. */
  39532. addGamepad(): ArcRotateCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39537. */
  39538. export class GamepadSystemSceneComponent implements ISceneComponent {
  39539. /**
  39540. * The component name helpfull to identify the component in the list of scene components.
  39541. */
  39542. readonly name: string;
  39543. /**
  39544. * The scene the component belongs to.
  39545. */
  39546. scene: Scene;
  39547. /**
  39548. * Creates a new instance of the component for the given scene
  39549. * @param scene Defines the scene to register the component in
  39550. */
  39551. constructor(scene: Scene);
  39552. /**
  39553. * Registers the component in a given scene
  39554. */
  39555. register(): void;
  39556. /**
  39557. * Rebuilds the elements related to this component in case of
  39558. * context lost for instance.
  39559. */
  39560. rebuild(): void;
  39561. /**
  39562. * Disposes the component and the associated ressources
  39563. */
  39564. dispose(): void;
  39565. private _beforeCameraUpdate;
  39566. }
  39567. }
  39568. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39569. import { Observable } from "babylonjs/Misc/observable";
  39570. import { Nullable } from "babylonjs/types";
  39571. import { Camera } from "babylonjs/Cameras/camera";
  39572. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39573. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39574. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39575. import { Scene } from "babylonjs/scene";
  39576. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39579. import { Mesh } from "babylonjs/Meshes/mesh";
  39580. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39581. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39582. import "babylonjs/Meshes/Builders/groundBuilder";
  39583. import "babylonjs/Meshes/Builders/torusBuilder";
  39584. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39585. import "babylonjs/Gamepads/gamepadSceneComponent";
  39586. import "babylonjs/Animations/animatable";
  39587. /**
  39588. * Options to modify the vr teleportation behavior.
  39589. */
  39590. export interface VRTeleportationOptions {
  39591. /**
  39592. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39593. */
  39594. floorMeshName?: string;
  39595. /**
  39596. * A list of meshes to be used as the teleportation floor. (default: empty)
  39597. */
  39598. floorMeshes?: Mesh[];
  39599. }
  39600. /**
  39601. * Options to modify the vr experience helper's behavior.
  39602. */
  39603. export interface VRExperienceHelperOptions extends WebVROptions {
  39604. /**
  39605. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39606. */
  39607. createDeviceOrientationCamera?: boolean;
  39608. /**
  39609. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39610. */
  39611. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39612. /**
  39613. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39614. */
  39615. laserToggle?: boolean;
  39616. /**
  39617. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39618. */
  39619. floorMeshes?: Mesh[];
  39620. /**
  39621. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39622. */
  39623. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39624. }
  39625. /**
  39626. * Helps to quickly add VR support to an existing scene.
  39627. * See http://doc.babylonjs.com/how_to/webvr_helper
  39628. */
  39629. export class VRExperienceHelper {
  39630. /** Options to modify the vr experience helper's behavior. */
  39631. webVROptions: VRExperienceHelperOptions;
  39632. private _scene;
  39633. private _position;
  39634. private _btnVR;
  39635. private _btnVRDisplayed;
  39636. private _webVRsupported;
  39637. private _webVRready;
  39638. private _webVRrequesting;
  39639. private _webVRpresenting;
  39640. private _hasEnteredVR;
  39641. private _fullscreenVRpresenting;
  39642. private _canvas;
  39643. private _webVRCamera;
  39644. private _vrDeviceOrientationCamera;
  39645. private _deviceOrientationCamera;
  39646. private _existingCamera;
  39647. private _onKeyDown;
  39648. private _onVrDisplayPresentChange;
  39649. private _onVRDisplayChanged;
  39650. private _onVRRequestPresentStart;
  39651. private _onVRRequestPresentComplete;
  39652. /**
  39653. * Observable raised when entering VR.
  39654. */
  39655. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39656. /**
  39657. * Observable raised when exiting VR.
  39658. */
  39659. onExitingVRObservable: Observable<VRExperienceHelper>;
  39660. /**
  39661. * Observable raised when controller mesh is loaded.
  39662. */
  39663. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39664. /** Return this.onEnteringVRObservable
  39665. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39666. */
  39667. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39668. /** Return this.onExitingVRObservable
  39669. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39670. */
  39671. readonly onExitingVR: Observable<VRExperienceHelper>;
  39672. /** Return this.onControllerMeshLoadedObservable
  39673. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39674. */
  39675. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39676. private _rayLength;
  39677. private _useCustomVRButton;
  39678. private _teleportationRequested;
  39679. private _teleportActive;
  39680. private _floorMeshName;
  39681. private _floorMeshesCollection;
  39682. private _rotationAllowed;
  39683. private _teleportBackwardsVector;
  39684. private _teleportationTarget;
  39685. private _isDefaultTeleportationTarget;
  39686. private _postProcessMove;
  39687. private _teleportationFillColor;
  39688. private _teleportationBorderColor;
  39689. private _rotationAngle;
  39690. private _haloCenter;
  39691. private _cameraGazer;
  39692. private _padSensibilityUp;
  39693. private _padSensibilityDown;
  39694. private _leftController;
  39695. private _rightController;
  39696. /**
  39697. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39698. */
  39699. onNewMeshSelected: Observable<AbstractMesh>;
  39700. /**
  39701. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39702. */
  39703. onNewMeshPicked: Observable<PickingInfo>;
  39704. private _circleEase;
  39705. /**
  39706. * Observable raised before camera teleportation
  39707. */
  39708. onBeforeCameraTeleport: Observable<Vector3>;
  39709. /**
  39710. * Observable raised after camera teleportation
  39711. */
  39712. onAfterCameraTeleport: Observable<Vector3>;
  39713. /**
  39714. * Observable raised when current selected mesh gets unselected
  39715. */
  39716. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39717. private _raySelectionPredicate;
  39718. /**
  39719. * To be optionaly changed by user to define custom ray selection
  39720. */
  39721. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39722. /**
  39723. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39724. */
  39725. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39726. /**
  39727. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39728. */
  39729. teleportationEnabled: boolean;
  39730. private _defaultHeight;
  39731. private _teleportationInitialized;
  39732. private _interactionsEnabled;
  39733. private _interactionsRequested;
  39734. private _displayGaze;
  39735. private _displayLaserPointer;
  39736. /**
  39737. * The mesh used to display where the user is going to teleport.
  39738. */
  39739. /**
  39740. * Sets the mesh to be used to display where the user is going to teleport.
  39741. */
  39742. teleportationTarget: Mesh;
  39743. /**
  39744. * 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
  39745. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39746. * See http://doc.babylonjs.com/resources/baking_transformations
  39747. */
  39748. gazeTrackerMesh: Mesh;
  39749. /**
  39750. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39751. */
  39752. updateGazeTrackerScale: boolean;
  39753. /**
  39754. * If the gaze trackers color should be updated when selecting meshes
  39755. */
  39756. updateGazeTrackerColor: boolean;
  39757. /**
  39758. * The gaze tracking mesh corresponding to the left controller
  39759. */
  39760. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39761. /**
  39762. * The gaze tracking mesh corresponding to the right controller
  39763. */
  39764. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39765. /**
  39766. * If the ray of the gaze should be displayed.
  39767. */
  39768. /**
  39769. * Sets if the ray of the gaze should be displayed.
  39770. */
  39771. displayGaze: boolean;
  39772. /**
  39773. * If the ray of the LaserPointer should be displayed.
  39774. */
  39775. /**
  39776. * Sets if the ray of the LaserPointer should be displayed.
  39777. */
  39778. displayLaserPointer: boolean;
  39779. /**
  39780. * The deviceOrientationCamera used as the camera when not in VR.
  39781. */
  39782. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39783. /**
  39784. * Based on the current WebVR support, returns the current VR camera used.
  39785. */
  39786. readonly currentVRCamera: Nullable<Camera>;
  39787. /**
  39788. * The webVRCamera which is used when in VR.
  39789. */
  39790. readonly webVRCamera: WebVRFreeCamera;
  39791. /**
  39792. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39793. */
  39794. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39795. private readonly _teleportationRequestInitiated;
  39796. /**
  39797. * Defines wether or not Pointer lock should be requested when switching to
  39798. * full screen.
  39799. */
  39800. requestPointerLockOnFullScreen: boolean;
  39801. /**
  39802. * Instantiates a VRExperienceHelper.
  39803. * Helps to quickly add VR support to an existing scene.
  39804. * @param scene The scene the VRExperienceHelper belongs to.
  39805. * @param webVROptions Options to modify the vr experience helper's behavior.
  39806. */
  39807. constructor(scene: Scene,
  39808. /** Options to modify the vr experience helper's behavior. */
  39809. webVROptions?: VRExperienceHelperOptions);
  39810. private _onDefaultMeshLoaded;
  39811. private _onResize;
  39812. private _onFullscreenChange;
  39813. /**
  39814. * Gets a value indicating if we are currently in VR mode.
  39815. */
  39816. readonly isInVRMode: boolean;
  39817. private onVrDisplayPresentChange;
  39818. private onVRDisplayChanged;
  39819. private moveButtonToBottomRight;
  39820. private displayVRButton;
  39821. private updateButtonVisibility;
  39822. private _cachedAngularSensibility;
  39823. /**
  39824. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39825. * Otherwise, will use the fullscreen API.
  39826. */
  39827. enterVR(): void;
  39828. /**
  39829. * Attempt to exit VR, or fullscreen.
  39830. */
  39831. exitVR(): void;
  39832. /**
  39833. * The position of the vr experience helper.
  39834. */
  39835. /**
  39836. * Sets the position of the vr experience helper.
  39837. */
  39838. position: Vector3;
  39839. /**
  39840. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39841. */
  39842. enableInteractions(): void;
  39843. private readonly _noControllerIsActive;
  39844. private beforeRender;
  39845. private _isTeleportationFloor;
  39846. /**
  39847. * Adds a floor mesh to be used for teleportation.
  39848. * @param floorMesh the mesh to be used for teleportation.
  39849. */
  39850. addFloorMesh(floorMesh: Mesh): void;
  39851. /**
  39852. * Removes a floor mesh from being used for teleportation.
  39853. * @param floorMesh the mesh to be removed.
  39854. */
  39855. removeFloorMesh(floorMesh: Mesh): void;
  39856. /**
  39857. * Enables interactions and teleportation using the VR controllers and gaze.
  39858. * @param vrTeleportationOptions options to modify teleportation behavior.
  39859. */
  39860. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39861. private _onNewGamepadConnected;
  39862. private _tryEnableInteractionOnController;
  39863. private _onNewGamepadDisconnected;
  39864. private _enableInteractionOnController;
  39865. private _checkTeleportWithRay;
  39866. private _checkRotate;
  39867. private _checkTeleportBackwards;
  39868. private _enableTeleportationOnController;
  39869. private _createTeleportationCircles;
  39870. private _displayTeleportationTarget;
  39871. private _hideTeleportationTarget;
  39872. private _rotateCamera;
  39873. private _moveTeleportationSelectorTo;
  39874. private _workingVector;
  39875. private _workingQuaternion;
  39876. private _workingMatrix;
  39877. /**
  39878. * Teleports the users feet to the desired location
  39879. * @param location The location where the user's feet should be placed
  39880. */
  39881. teleportCamera(location: Vector3): void;
  39882. private _convertNormalToDirectionOfRay;
  39883. private _castRayAndSelectObject;
  39884. private _notifySelectedMeshUnselected;
  39885. /**
  39886. * Sets the color of the laser ray from the vr controllers.
  39887. * @param color new color for the ray.
  39888. */
  39889. changeLaserColor(color: Color3): void;
  39890. /**
  39891. * Sets the color of the ray from the vr headsets gaze.
  39892. * @param color new color for the ray.
  39893. */
  39894. changeGazeColor(color: Color3): void;
  39895. /**
  39896. * Exits VR and disposes of the vr experience helper
  39897. */
  39898. dispose(): void;
  39899. /**
  39900. * Gets the name of the VRExperienceHelper class
  39901. * @returns "VRExperienceHelper"
  39902. */
  39903. getClassName(): string;
  39904. }
  39905. }
  39906. declare module "babylonjs/Cameras/VR/index" {
  39907. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39908. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39909. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39910. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39911. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39912. export * from "babylonjs/Cameras/VR/webVRCamera";
  39913. }
  39914. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39915. import { Observable } from "babylonjs/Misc/observable";
  39916. import { Nullable } from "babylonjs/types";
  39917. import { IDisposable, Scene } from "babylonjs/scene";
  39918. import { Vector3 } from "babylonjs/Maths/math";
  39919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39920. import { Ray } from "babylonjs/Culling/ray";
  39921. /**
  39922. * Manages an XRSession
  39923. * @see https://doc.babylonjs.com/how_to/webxr
  39924. */
  39925. export class WebXRSessionManager implements IDisposable {
  39926. private scene;
  39927. /**
  39928. * Fires every time a new xrFrame arrives which can be used to update the camera
  39929. */
  39930. onXRFrameObservable: Observable<any>;
  39931. /**
  39932. * Fires when the xr session is ended either by the device or manually done
  39933. */
  39934. onXRSessionEnded: Observable<any>;
  39935. /** @hidden */
  39936. _xrSession: XRSession;
  39937. /** @hidden */
  39938. _frameOfReference: XRFrameOfReference;
  39939. /** @hidden */
  39940. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39941. /** @hidden */
  39942. _currentXRFrame: Nullable<XRFrame>;
  39943. private _xrNavigator;
  39944. private _xrDevice;
  39945. private _tmpMatrix;
  39946. /**
  39947. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39948. * @param scene The scene which the session should be created for
  39949. */
  39950. constructor(scene: Scene);
  39951. /**
  39952. * Initializes the manager
  39953. * After initialization enterXR can be called to start an XR session
  39954. * @returns Promise which resolves after it is initialized
  39955. */
  39956. initializeAsync(): Promise<void>;
  39957. /**
  39958. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39959. * @param sessionCreationOptions xr options to create the session with
  39960. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39961. * @returns Promise which resolves after it enters XR
  39962. */
  39963. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39964. /**
  39965. * Stops the xrSession and restores the renderloop
  39966. * @returns Promise which resolves after it exits XR
  39967. */
  39968. exitXRAsync(): Promise<void>;
  39969. /**
  39970. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39971. * @param ray ray to cast into the environment
  39972. * @returns Promise which resolves with a collision point in the environment if it exists
  39973. */
  39974. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39975. /**
  39976. * Checks if a session would be supported for the creation options specified
  39977. * @param options creation options to check if they are supported
  39978. * @returns true if supported
  39979. */
  39980. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39981. /**
  39982. * @hidden
  39983. * Converts the render layer of xrSession to a render target
  39984. * @param session session to create render target for
  39985. * @param scene scene the new render target should be created for
  39986. */
  39987. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39988. /**
  39989. * Disposes of the session manager
  39990. */
  39991. dispose(): void;
  39992. }
  39993. }
  39994. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39995. import { Scene } from "babylonjs/scene";
  39996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39997. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39998. /**
  39999. * WebXR Camera which holds the views for the xrSession
  40000. * @see https://doc.babylonjs.com/how_to/webxr
  40001. */
  40002. export class WebXRCamera extends FreeCamera {
  40003. private static _TmpMatrix;
  40004. /**
  40005. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40006. * @param name the name of the camera
  40007. * @param scene the scene to add the camera to
  40008. */
  40009. constructor(name: string, scene: Scene);
  40010. private _updateNumberOfRigCameras;
  40011. /** @hidden */
  40012. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40013. /**
  40014. * Updates the cameras position from the current pose information of the XR session
  40015. * @param xrSessionManager the session containing pose information
  40016. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40017. */
  40018. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40019. }
  40020. }
  40021. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40022. import { Nullable } from "babylonjs/types";
  40023. import { Observable } from "babylonjs/Misc/observable";
  40024. import { IDisposable, Scene } from "babylonjs/scene";
  40025. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40027. import { Ray } from "babylonjs/Culling/ray";
  40028. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40029. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40030. /**
  40031. * States of the webXR experience
  40032. */
  40033. export enum WebXRState {
  40034. /**
  40035. * Transitioning to being in XR mode
  40036. */
  40037. ENTERING_XR = 0,
  40038. /**
  40039. * Transitioning to non XR mode
  40040. */
  40041. EXITING_XR = 1,
  40042. /**
  40043. * In XR mode and presenting
  40044. */
  40045. IN_XR = 2,
  40046. /**
  40047. * Not entered XR mode
  40048. */
  40049. NOT_IN_XR = 3
  40050. }
  40051. /**
  40052. * Helper class used to enable XR
  40053. * @see https://doc.babylonjs.com/how_to/webxr
  40054. */
  40055. export class WebXRExperienceHelper implements IDisposable {
  40056. private scene;
  40057. /**
  40058. * 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
  40059. */
  40060. container: AbstractMesh;
  40061. /**
  40062. * Camera used to render xr content
  40063. */
  40064. camera: WebXRCamera;
  40065. /**
  40066. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40067. */
  40068. state: WebXRState;
  40069. private _setState;
  40070. private static _TmpVector;
  40071. /**
  40072. * Fires when the state of the experience helper has changed
  40073. */
  40074. onStateChangedObservable: Observable<WebXRState>;
  40075. /** @hidden */
  40076. _sessionManager: WebXRSessionManager;
  40077. private _nonVRCamera;
  40078. private _originalSceneAutoClear;
  40079. private _supported;
  40080. /**
  40081. * Creates the experience helper
  40082. * @param scene the scene to attach the experience helper to
  40083. * @returns a promise for the experience helper
  40084. */
  40085. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40086. /**
  40087. * Creates a WebXRExperienceHelper
  40088. * @param scene The scene the helper should be created in
  40089. */
  40090. private constructor();
  40091. /**
  40092. * Exits XR mode and returns the scene to its original state
  40093. * @returns promise that resolves after xr mode has exited
  40094. */
  40095. exitXRAsync(): Promise<void>;
  40096. /**
  40097. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40098. * @param sessionCreationOptions options for the XR session
  40099. * @param frameOfReference frame of reference of the XR session
  40100. * @returns promise that resolves after xr mode has entered
  40101. */
  40102. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40103. /**
  40104. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40105. * @param ray ray to cast into the environment
  40106. * @returns Promise which resolves with a collision point in the environment if it exists
  40107. */
  40108. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40109. /**
  40110. * Updates the global position of the camera by moving the camera's container
  40111. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40112. * @param position The desired global position of the camera
  40113. */
  40114. setPositionOfCameraUsingContainer(position: Vector3): void;
  40115. /**
  40116. * Rotates the xr camera by rotating the camera's container around the camera's position
  40117. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40118. * @param rotation the desired quaternion rotation to apply to the camera
  40119. */
  40120. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40121. /**
  40122. * Checks if the creation options are supported by the xr session
  40123. * @param options creation options
  40124. * @returns true if supported
  40125. */
  40126. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40127. /**
  40128. * Disposes of the experience helper
  40129. */
  40130. dispose(): void;
  40131. }
  40132. }
  40133. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40134. import { Nullable } from "babylonjs/types";
  40135. import { Observable } from "babylonjs/Misc/observable";
  40136. import { IDisposable, Scene } from "babylonjs/scene";
  40137. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40138. /**
  40139. * Button which can be used to enter a different mode of XR
  40140. */
  40141. export class WebXREnterExitUIButton {
  40142. /** button element */
  40143. element: HTMLElement;
  40144. /** XR initialization options for the button */
  40145. initializationOptions: XRSessionCreationOptions;
  40146. /**
  40147. * Creates a WebXREnterExitUIButton
  40148. * @param element button element
  40149. * @param initializationOptions XR initialization options for the button
  40150. */
  40151. constructor(
  40152. /** button element */
  40153. element: HTMLElement,
  40154. /** XR initialization options for the button */
  40155. initializationOptions: XRSessionCreationOptions);
  40156. /**
  40157. * Overwritable function which can be used to update the button's visuals when the state changes
  40158. * @param activeButton the current active button in the UI
  40159. */
  40160. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40161. }
  40162. /**
  40163. * Options to create the webXR UI
  40164. */
  40165. export class WebXREnterExitUIOptions {
  40166. /**
  40167. * Context to enter xr with
  40168. */
  40169. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40170. /**
  40171. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40172. */
  40173. customButtons?: Array<WebXREnterExitUIButton>;
  40174. }
  40175. /**
  40176. * UI to allow the user to enter/exit XR mode
  40177. */
  40178. export class WebXREnterExitUI implements IDisposable {
  40179. private scene;
  40180. private _overlay;
  40181. private _buttons;
  40182. private _activeButton;
  40183. /**
  40184. * Fired every time the active button is changed.
  40185. *
  40186. * When xr is entered via a button that launches xr that button will be the callback parameter
  40187. *
  40188. * When exiting xr the callback parameter will be null)
  40189. */
  40190. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40191. /**
  40192. * Creates UI to allow the user to enter/exit XR mode
  40193. * @param scene the scene to add the ui to
  40194. * @param helper the xr experience helper to enter/exit xr with
  40195. * @param options options to configure the UI
  40196. * @returns the created ui
  40197. */
  40198. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40199. private constructor();
  40200. private _updateButtons;
  40201. /**
  40202. * Disposes of the object
  40203. */
  40204. dispose(): void;
  40205. }
  40206. }
  40207. declare module "babylonjs/Cameras/XR/webXRInput" {
  40208. import { IDisposable, Scene } from "babylonjs/scene";
  40209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40210. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40211. /**
  40212. * Represents an XR input
  40213. */
  40214. export class WebXRController {
  40215. /**
  40216. * 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
  40217. */
  40218. grip?: AbstractMesh;
  40219. /**
  40220. * Pointer which can be used to select objects or attach a visible laser to
  40221. */
  40222. pointer: AbstractMesh;
  40223. /**
  40224. * Creates the controller
  40225. * @see https://doc.babylonjs.com/how_to/webxr
  40226. * @param scene the scene which the controller should be associated to
  40227. */
  40228. constructor(scene: Scene);
  40229. /**
  40230. * Disposes of the object
  40231. */
  40232. dispose(): void;
  40233. }
  40234. /**
  40235. * XR input used to track XR inputs such as controllers/rays
  40236. */
  40237. export class WebXRInput implements IDisposable {
  40238. private helper;
  40239. /**
  40240. * XR controllers being tracked
  40241. */
  40242. controllers: Array<WebXRController>;
  40243. private _tmpMatrix;
  40244. private _frameObserver;
  40245. /**
  40246. * Initializes the WebXRInput
  40247. * @param helper experience helper which the input should be created for
  40248. */
  40249. constructor(helper: WebXRExperienceHelper);
  40250. /**
  40251. * Disposes of the object
  40252. */
  40253. dispose(): void;
  40254. }
  40255. }
  40256. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40257. import { Nullable } from "babylonjs/types";
  40258. import { IDisposable } from "babylonjs/scene";
  40259. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40260. /**
  40261. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40262. */
  40263. export class WebXRManagedOutputCanvas implements IDisposable {
  40264. private _canvas;
  40265. /**
  40266. * xrpresent context of the canvas which can be used to display/mirror xr content
  40267. */
  40268. canvasContext: Nullable<WebGLRenderingContext>;
  40269. /**
  40270. * Initializes the canvas to be added/removed upon entering/exiting xr
  40271. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40272. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40273. */
  40274. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40275. /**
  40276. * Disposes of the object
  40277. */
  40278. dispose(): void;
  40279. private _setManagedOutputCanvas;
  40280. private _addCanvas;
  40281. private _removeCanvas;
  40282. }
  40283. }
  40284. declare module "babylonjs/Cameras/XR/index" {
  40285. export * from "babylonjs/Cameras/XR/webXRCamera";
  40286. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40287. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40288. export * from "babylonjs/Cameras/XR/webXRInput";
  40289. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40290. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40291. }
  40292. declare module "babylonjs/Cameras/RigModes/index" {
  40293. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40294. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40295. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40296. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40297. }
  40298. declare module "babylonjs/Cameras/index" {
  40299. export * from "babylonjs/Cameras/Inputs/index";
  40300. export * from "babylonjs/Cameras/cameraInputsManager";
  40301. export * from "babylonjs/Cameras/camera";
  40302. export * from "babylonjs/Cameras/targetCamera";
  40303. export * from "babylonjs/Cameras/freeCamera";
  40304. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40305. export * from "babylonjs/Cameras/touchCamera";
  40306. export * from "babylonjs/Cameras/arcRotateCamera";
  40307. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40308. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40309. export * from "babylonjs/Cameras/flyCamera";
  40310. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40311. export * from "babylonjs/Cameras/followCamera";
  40312. export * from "babylonjs/Cameras/gamepadCamera";
  40313. export * from "babylonjs/Cameras/Stereoscopic/index";
  40314. export * from "babylonjs/Cameras/universalCamera";
  40315. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40316. export * from "babylonjs/Cameras/VR/index";
  40317. export * from "babylonjs/Cameras/XR/index";
  40318. export * from "babylonjs/Cameras/RigModes/index";
  40319. }
  40320. declare module "babylonjs/Collisions/index" {
  40321. export * from "babylonjs/Collisions/collider";
  40322. export * from "babylonjs/Collisions/collisionCoordinator";
  40323. export * from "babylonjs/Collisions/pickingInfo";
  40324. export * from "babylonjs/Collisions/intersectionInfo";
  40325. }
  40326. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40327. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40328. import { Vector3, Plane } from "babylonjs/Maths/math";
  40329. import { Ray } from "babylonjs/Culling/ray";
  40330. /**
  40331. * Contains an array of blocks representing the octree
  40332. */
  40333. export interface IOctreeContainer<T> {
  40334. /**
  40335. * Blocks within the octree
  40336. */
  40337. blocks: Array<OctreeBlock<T>>;
  40338. }
  40339. /**
  40340. * Class used to store a cell in an octree
  40341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40342. */
  40343. export class OctreeBlock<T> {
  40344. /**
  40345. * Gets the content of the current block
  40346. */
  40347. entries: T[];
  40348. /**
  40349. * Gets the list of block children
  40350. */
  40351. blocks: Array<OctreeBlock<T>>;
  40352. private _depth;
  40353. private _maxDepth;
  40354. private _capacity;
  40355. private _minPoint;
  40356. private _maxPoint;
  40357. private _boundingVectors;
  40358. private _creationFunc;
  40359. /**
  40360. * Creates a new block
  40361. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40362. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40363. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40364. * @param depth defines the current depth of this block in the octree
  40365. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40366. * @param creationFunc defines a callback to call when an element is added to the block
  40367. */
  40368. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40369. /**
  40370. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40371. */
  40372. readonly capacity: number;
  40373. /**
  40374. * Gets the minimum vector (in world space) of the block's bounding box
  40375. */
  40376. readonly minPoint: Vector3;
  40377. /**
  40378. * Gets the maximum vector (in world space) of the block's bounding box
  40379. */
  40380. readonly maxPoint: Vector3;
  40381. /**
  40382. * Add a new element to this block
  40383. * @param entry defines the element to add
  40384. */
  40385. addEntry(entry: T): void;
  40386. /**
  40387. * Remove an element from this block
  40388. * @param entry defines the element to remove
  40389. */
  40390. removeEntry(entry: T): void;
  40391. /**
  40392. * Add an array of elements to this block
  40393. * @param entries defines the array of elements to add
  40394. */
  40395. addEntries(entries: T[]): void;
  40396. /**
  40397. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40398. * @param frustumPlanes defines the frustum planes to test
  40399. * @param selection defines the array to store current content if selection is positive
  40400. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40401. */
  40402. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40403. /**
  40404. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40405. * @param sphereCenter defines the bounding sphere center
  40406. * @param sphereRadius defines the bounding sphere radius
  40407. * @param selection defines the array to store current content if selection is positive
  40408. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40409. */
  40410. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40411. /**
  40412. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40413. * @param ray defines the ray to test with
  40414. * @param selection defines the array to store current content if selection is positive
  40415. */
  40416. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40417. /**
  40418. * Subdivide the content into child blocks (this block will then be empty)
  40419. */
  40420. createInnerBlocks(): void;
  40421. /**
  40422. * @hidden
  40423. */
  40424. 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;
  40425. }
  40426. }
  40427. declare module "babylonjs/Culling/Octrees/octree" {
  40428. import { SmartArray } from "babylonjs/Misc/smartArray";
  40429. import { Vector3, Plane } from "babylonjs/Maths/math";
  40430. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40432. import { Ray } from "babylonjs/Culling/ray";
  40433. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40434. /**
  40435. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40436. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40437. */
  40438. export class Octree<T> {
  40439. /** 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.) */
  40440. maxDepth: number;
  40441. /**
  40442. * Blocks within the octree containing objects
  40443. */
  40444. blocks: Array<OctreeBlock<T>>;
  40445. /**
  40446. * Content stored in the octree
  40447. */
  40448. dynamicContent: T[];
  40449. private _maxBlockCapacity;
  40450. private _selectionContent;
  40451. private _creationFunc;
  40452. /**
  40453. * Creates a octree
  40454. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40455. * @param creationFunc function to be used to instatiate the octree
  40456. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40457. * @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.)
  40458. */
  40459. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40460. /** 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.) */
  40461. maxDepth?: number);
  40462. /**
  40463. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40464. * @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);
  40465. * @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);
  40466. * @param entries meshes to be added to the octree blocks
  40467. */
  40468. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40469. /**
  40470. * Adds a mesh to the octree
  40471. * @param entry Mesh to add to the octree
  40472. */
  40473. addMesh(entry: T): void;
  40474. /**
  40475. * Remove an element from the octree
  40476. * @param entry defines the element to remove
  40477. */
  40478. removeMesh(entry: T): void;
  40479. /**
  40480. * Selects an array of meshes within the frustum
  40481. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40482. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40483. * @returns array of meshes within the frustum
  40484. */
  40485. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40486. /**
  40487. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40488. * @param sphereCenter defines the bounding sphere center
  40489. * @param sphereRadius defines the bounding sphere radius
  40490. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40491. * @returns an array of objects that intersect the sphere
  40492. */
  40493. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40494. /**
  40495. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40496. * @param ray defines the ray to test with
  40497. * @returns array of intersected objects
  40498. */
  40499. intersectsRay(ray: Ray): SmartArray<T>;
  40500. /**
  40501. * Adds a mesh into the octree block if it intersects the block
  40502. */
  40503. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40504. /**
  40505. * Adds a submesh into the octree block if it intersects the block
  40506. */
  40507. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40508. }
  40509. }
  40510. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40511. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40512. import { Scene } from "babylonjs/scene";
  40513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40515. import { Ray } from "babylonjs/Culling/ray";
  40516. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40517. import { Collider } from "babylonjs/Collisions/collider";
  40518. module "babylonjs/scene" {
  40519. interface Scene {
  40520. /**
  40521. * @hidden
  40522. * Backing Filed
  40523. */
  40524. _selectionOctree: Octree<AbstractMesh>;
  40525. /**
  40526. * Gets the octree used to boost mesh selection (picking)
  40527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40528. */
  40529. selectionOctree: Octree<AbstractMesh>;
  40530. /**
  40531. * Creates or updates the octree used to boost selection (picking)
  40532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40533. * @param maxCapacity defines the maximum capacity per leaf
  40534. * @param maxDepth defines the maximum depth of the octree
  40535. * @returns an octree of AbstractMesh
  40536. */
  40537. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40538. }
  40539. }
  40540. module "babylonjs/Meshes/abstractMesh" {
  40541. interface AbstractMesh {
  40542. /**
  40543. * @hidden
  40544. * Backing Field
  40545. */
  40546. _submeshesOctree: Octree<SubMesh>;
  40547. /**
  40548. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40549. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40550. * @param maxCapacity defines the maximum size of each block (64 by default)
  40551. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40552. * @returns the new octree
  40553. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40555. */
  40556. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40557. }
  40558. }
  40559. /**
  40560. * Defines the octree scene component responsible to manage any octrees
  40561. * in a given scene.
  40562. */
  40563. export class OctreeSceneComponent {
  40564. /**
  40565. * The component name helpfull to identify the component in the list of scene components.
  40566. */
  40567. readonly name: string;
  40568. /**
  40569. * The scene the component belongs to.
  40570. */
  40571. scene: Scene;
  40572. /**
  40573. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40574. */
  40575. readonly checksIsEnabled: boolean;
  40576. /**
  40577. * Creates a new instance of the component for the given scene
  40578. * @param scene Defines the scene to register the component in
  40579. */
  40580. constructor(scene: Scene);
  40581. /**
  40582. * Registers the component in a given scene
  40583. */
  40584. register(): void;
  40585. /**
  40586. * Return the list of active meshes
  40587. * @returns the list of active meshes
  40588. */
  40589. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40590. /**
  40591. * Return the list of active sub meshes
  40592. * @param mesh The mesh to get the candidates sub meshes from
  40593. * @returns the list of active sub meshes
  40594. */
  40595. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40596. private _tempRay;
  40597. /**
  40598. * Return the list of sub meshes intersecting with a given local ray
  40599. * @param mesh defines the mesh to find the submesh for
  40600. * @param localRay defines the ray in local space
  40601. * @returns the list of intersecting sub meshes
  40602. */
  40603. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40604. /**
  40605. * Return the list of sub meshes colliding with a collider
  40606. * @param mesh defines the mesh to find the submesh for
  40607. * @param collider defines the collider to evaluate the collision against
  40608. * @returns the list of colliding sub meshes
  40609. */
  40610. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40611. /**
  40612. * Rebuilds the elements related to this component in case of
  40613. * context lost for instance.
  40614. */
  40615. rebuild(): void;
  40616. /**
  40617. * Disposes the component and the associated ressources.
  40618. */
  40619. dispose(): void;
  40620. }
  40621. }
  40622. declare module "babylonjs/Culling/Octrees/index" {
  40623. export * from "babylonjs/Culling/Octrees/octree";
  40624. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40625. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40626. }
  40627. declare module "babylonjs/Culling/index" {
  40628. export * from "babylonjs/Culling/boundingBox";
  40629. export * from "babylonjs/Culling/boundingInfo";
  40630. export * from "babylonjs/Culling/boundingSphere";
  40631. export * from "babylonjs/Culling/Octrees/index";
  40632. export * from "babylonjs/Culling/ray";
  40633. }
  40634. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40635. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40636. import { Nullable } from "babylonjs/types";
  40637. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40638. import { Scene } from "babylonjs/scene";
  40639. /**
  40640. * Class containing static functions to help procedurally build meshes
  40641. */
  40642. export class LinesBuilder {
  40643. /**
  40644. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40645. * * 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
  40646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40647. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40648. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40649. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40650. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40651. * * 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
  40652. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40655. * @param name defines the name of the new line system
  40656. * @param options defines the options used to create the line system
  40657. * @param scene defines the hosting scene
  40658. * @returns a new line system mesh
  40659. */
  40660. static CreateLineSystem(name: string, options: {
  40661. lines: Vector3[][];
  40662. updatable?: boolean;
  40663. instance?: Nullable<LinesMesh>;
  40664. colors?: Nullable<Color4[][]>;
  40665. useVertexAlpha?: boolean;
  40666. }, scene: Nullable<Scene>): LinesMesh;
  40667. /**
  40668. * Creates a line mesh
  40669. * 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
  40670. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40671. * * The parameter `points` is an array successive Vector3
  40672. * * 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
  40673. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40674. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40675. * * When updating an instance, remember that only point positions can change, not the number of points
  40676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40678. * @param name defines the name of the new line system
  40679. * @param options defines the options used to create the line system
  40680. * @param scene defines the hosting scene
  40681. * @returns a new line mesh
  40682. */
  40683. static CreateLines(name: string, options: {
  40684. points: Vector3[];
  40685. updatable?: boolean;
  40686. instance?: Nullable<LinesMesh>;
  40687. colors?: Color4[];
  40688. useVertexAlpha?: boolean;
  40689. }, scene?: Nullable<Scene>): LinesMesh;
  40690. /**
  40691. * Creates a dashed line mesh
  40692. * * 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
  40693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40694. * * The parameter `points` is an array successive Vector3
  40695. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40696. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40697. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40698. * * 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
  40699. * * When updating an instance, remember that only point positions can change, not the number of points
  40700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40701. * @param name defines the name of the mesh
  40702. * @param options defines the options used to create the mesh
  40703. * @param scene defines the hosting scene
  40704. * @returns the dashed line mesh
  40705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40706. */
  40707. static CreateDashedLines(name: string, options: {
  40708. points: Vector3[];
  40709. dashSize?: number;
  40710. gapSize?: number;
  40711. dashNb?: number;
  40712. updatable?: boolean;
  40713. instance?: LinesMesh;
  40714. }, scene?: Nullable<Scene>): LinesMesh;
  40715. }
  40716. }
  40717. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40718. import { IDisposable, Scene } from "babylonjs/scene";
  40719. import { Nullable } from "babylonjs/types";
  40720. import { Observable } from "babylonjs/Misc/observable";
  40721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40722. /**
  40723. * Renders a layer on top of an existing scene
  40724. */
  40725. export class UtilityLayerRenderer implements IDisposable {
  40726. /** the original scene that will be rendered on top of */
  40727. originalScene: Scene;
  40728. private _pointerCaptures;
  40729. private _lastPointerEvents;
  40730. private static _DefaultUtilityLayer;
  40731. private static _DefaultKeepDepthUtilityLayer;
  40732. /**
  40733. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40734. */
  40735. pickUtilitySceneFirst: boolean;
  40736. /**
  40737. * 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)
  40738. */
  40739. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40740. /**
  40741. * 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)
  40742. */
  40743. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40744. /**
  40745. * The scene that is rendered on top of the original scene
  40746. */
  40747. utilityLayerScene: Scene;
  40748. /**
  40749. * If the utility layer should automatically be rendered on top of existing scene
  40750. */
  40751. shouldRender: boolean;
  40752. /**
  40753. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40754. */
  40755. onlyCheckPointerDownEvents: boolean;
  40756. /**
  40757. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40758. */
  40759. processAllEvents: boolean;
  40760. /**
  40761. * Observable raised when the pointer move from the utility layer scene to the main scene
  40762. */
  40763. onPointerOutObservable: Observable<number>;
  40764. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40765. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40766. private _afterRenderObserver;
  40767. private _sceneDisposeObserver;
  40768. private _originalPointerObserver;
  40769. /**
  40770. * Instantiates a UtilityLayerRenderer
  40771. * @param originalScene the original scene that will be rendered on top of
  40772. * @param handleEvents boolean indicating if the utility layer should handle events
  40773. */
  40774. constructor(
  40775. /** the original scene that will be rendered on top of */
  40776. originalScene: Scene, handleEvents?: boolean);
  40777. private _notifyObservers;
  40778. /**
  40779. * Renders the utility layers scene on top of the original scene
  40780. */
  40781. render(): void;
  40782. /**
  40783. * Disposes of the renderer
  40784. */
  40785. dispose(): void;
  40786. private _updateCamera;
  40787. }
  40788. }
  40789. declare module "babylonjs/Gizmos/gizmo" {
  40790. import { Nullable } from "babylonjs/types";
  40791. import { IDisposable } from "babylonjs/scene";
  40792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40793. import { Mesh } from "babylonjs/Meshes/mesh";
  40794. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40795. /**
  40796. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40797. */
  40798. export class Gizmo implements IDisposable {
  40799. /** The utility layer the gizmo will be added to */
  40800. gizmoLayer: UtilityLayerRenderer;
  40801. /**
  40802. * The root mesh of the gizmo
  40803. */
  40804. _rootMesh: Mesh;
  40805. private _attachedMesh;
  40806. /**
  40807. * Ratio for the scale of the gizmo (Default: 1)
  40808. */
  40809. scaleRatio: number;
  40810. private _tmpMatrix;
  40811. /**
  40812. * If a custom mesh has been set (Default: false)
  40813. */
  40814. protected _customMeshSet: boolean;
  40815. /**
  40816. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40817. * * When set, interactions will be enabled
  40818. */
  40819. attachedMesh: Nullable<AbstractMesh>;
  40820. /**
  40821. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40822. * @param mesh The mesh to replace the default mesh of the gizmo
  40823. */
  40824. setCustomMesh(mesh: Mesh): void;
  40825. /**
  40826. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40827. */
  40828. updateGizmoRotationToMatchAttachedMesh: boolean;
  40829. /**
  40830. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40831. */
  40832. updateGizmoPositionToMatchAttachedMesh: boolean;
  40833. /**
  40834. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40835. */
  40836. protected _updateScale: boolean;
  40837. protected _interactionsEnabled: boolean;
  40838. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40839. private _beforeRenderObserver;
  40840. /**
  40841. * Creates a gizmo
  40842. * @param gizmoLayer The utility layer the gizmo will be added to
  40843. */
  40844. constructor(
  40845. /** The utility layer the gizmo will be added to */
  40846. gizmoLayer?: UtilityLayerRenderer);
  40847. private _tempVector;
  40848. /**
  40849. * @hidden
  40850. * Updates the gizmo to match the attached mesh's position/rotation
  40851. */
  40852. protected _update(): void;
  40853. /**
  40854. * Disposes of the gizmo
  40855. */
  40856. dispose(): void;
  40857. }
  40858. }
  40859. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40860. import { Observable } from "babylonjs/Misc/observable";
  40861. import { Nullable } from "babylonjs/types";
  40862. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40863. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40865. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40866. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40867. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40868. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40869. import { Scene } from "babylonjs/scene";
  40870. /**
  40871. * Single axis drag gizmo
  40872. */
  40873. export class AxisDragGizmo extends Gizmo {
  40874. /**
  40875. * Drag behavior responsible for the gizmos dragging interactions
  40876. */
  40877. dragBehavior: PointerDragBehavior;
  40878. private _pointerObserver;
  40879. /**
  40880. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40881. */
  40882. snapDistance: number;
  40883. /**
  40884. * Event that fires each time the gizmo snaps to a new location.
  40885. * * snapDistance is the the change in distance
  40886. */
  40887. onSnapObservable: Observable<{
  40888. snapDistance: number;
  40889. }>;
  40890. /** @hidden */
  40891. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40892. /** @hidden */
  40893. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40894. /**
  40895. * Creates an AxisDragGizmo
  40896. * @param gizmoLayer The utility layer the gizmo will be added to
  40897. * @param dragAxis The axis which the gizmo will be able to drag on
  40898. * @param color The color of the gizmo
  40899. */
  40900. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40901. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40902. /**
  40903. * Disposes of the gizmo
  40904. */
  40905. dispose(): void;
  40906. }
  40907. }
  40908. declare module "babylonjs/Debug/axesViewer" {
  40909. import { Vector3 } from "babylonjs/Maths/math";
  40910. import { Nullable } from "babylonjs/types";
  40911. import { Scene } from "babylonjs/scene";
  40912. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40913. /**
  40914. * The Axes viewer will show 3 axes in a specific point in space
  40915. */
  40916. export class AxesViewer {
  40917. private _xAxis;
  40918. private _yAxis;
  40919. private _zAxis;
  40920. private _scaleLinesFactor;
  40921. private _instanced;
  40922. /**
  40923. * Gets the hosting scene
  40924. */
  40925. scene: Scene;
  40926. /**
  40927. * Gets or sets a number used to scale line length
  40928. */
  40929. scaleLines: number;
  40930. /** Gets the node hierarchy used to render x-axis */
  40931. readonly xAxis: TransformNode;
  40932. /** Gets the node hierarchy used to render y-axis */
  40933. readonly yAxis: TransformNode;
  40934. /** Gets the node hierarchy used to render z-axis */
  40935. readonly zAxis: TransformNode;
  40936. /**
  40937. * Creates a new AxesViewer
  40938. * @param scene defines the hosting scene
  40939. * @param scaleLines defines a number used to scale line length (1 by default)
  40940. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40941. * @param xAxis defines the node hierarchy used to render the x-axis
  40942. * @param yAxis defines the node hierarchy used to render the y-axis
  40943. * @param zAxis defines the node hierarchy used to render the z-axis
  40944. */
  40945. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40946. /**
  40947. * Force the viewer to update
  40948. * @param position defines the position of the viewer
  40949. * @param xaxis defines the x axis of the viewer
  40950. * @param yaxis defines the y axis of the viewer
  40951. * @param zaxis defines the z axis of the viewer
  40952. */
  40953. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40954. /**
  40955. * Creates an instance of this axes viewer.
  40956. * @returns a new axes viewer with instanced meshes
  40957. */
  40958. createInstance(): AxesViewer;
  40959. /** Releases resources */
  40960. dispose(): void;
  40961. private static _SetRenderingGroupId;
  40962. }
  40963. }
  40964. declare module "babylonjs/Debug/boneAxesViewer" {
  40965. import { Nullable } from "babylonjs/types";
  40966. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40967. import { Vector3 } from "babylonjs/Maths/math";
  40968. import { Mesh } from "babylonjs/Meshes/mesh";
  40969. import { Bone } from "babylonjs/Bones/bone";
  40970. import { Scene } from "babylonjs/scene";
  40971. /**
  40972. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40973. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40974. */
  40975. export class BoneAxesViewer extends AxesViewer {
  40976. /**
  40977. * Gets or sets the target mesh where to display the axes viewer
  40978. */
  40979. mesh: Nullable<Mesh>;
  40980. /**
  40981. * Gets or sets the target bone where to display the axes viewer
  40982. */
  40983. bone: Nullable<Bone>;
  40984. /** Gets current position */
  40985. pos: Vector3;
  40986. /** Gets direction of X axis */
  40987. xaxis: Vector3;
  40988. /** Gets direction of Y axis */
  40989. yaxis: Vector3;
  40990. /** Gets direction of Z axis */
  40991. zaxis: Vector3;
  40992. /**
  40993. * Creates a new BoneAxesViewer
  40994. * @param scene defines the hosting scene
  40995. * @param bone defines the target bone
  40996. * @param mesh defines the target mesh
  40997. * @param scaleLines defines a scaling factor for line length (1 by default)
  40998. */
  40999. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41000. /**
  41001. * Force the viewer to update
  41002. */
  41003. update(): void;
  41004. /** Releases resources */
  41005. dispose(): void;
  41006. }
  41007. }
  41008. declare module "babylonjs/Debug/debugLayer" {
  41009. import { Observable } from "babylonjs/Misc/observable";
  41010. import { Scene } from "babylonjs/scene";
  41011. /**
  41012. * Interface used to define scene explorer extensibility option
  41013. */
  41014. export interface IExplorerExtensibilityOption {
  41015. /**
  41016. * Define the option label
  41017. */
  41018. label: string;
  41019. /**
  41020. * Defines the action to execute on click
  41021. */
  41022. action: (entity: any) => void;
  41023. }
  41024. /**
  41025. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41026. */
  41027. export interface IExplorerExtensibilityGroup {
  41028. /**
  41029. * Defines a predicate to test if a given type mut be extended
  41030. */
  41031. predicate: (entity: any) => boolean;
  41032. /**
  41033. * Gets the list of options added to a type
  41034. */
  41035. entries: IExplorerExtensibilityOption[];
  41036. }
  41037. /**
  41038. * Interface used to define the options to use to create the Inspector
  41039. */
  41040. export interface IInspectorOptions {
  41041. /**
  41042. * Display in overlay mode (default: false)
  41043. */
  41044. overlay?: boolean;
  41045. /**
  41046. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41047. */
  41048. globalRoot?: HTMLElement;
  41049. /**
  41050. * Display the Scene explorer
  41051. */
  41052. showExplorer?: boolean;
  41053. /**
  41054. * Display the property inspector
  41055. */
  41056. showInspector?: boolean;
  41057. /**
  41058. * Display in embed mode (both panes on the right)
  41059. */
  41060. embedMode?: boolean;
  41061. /**
  41062. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41063. */
  41064. handleResize?: boolean;
  41065. /**
  41066. * Allow the panes to popup (default: true)
  41067. */
  41068. enablePopup?: boolean;
  41069. /**
  41070. * Allow the panes to be closed by users (default: true)
  41071. */
  41072. enableClose?: boolean;
  41073. /**
  41074. * Optional list of extensibility entries
  41075. */
  41076. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41077. /**
  41078. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41079. */
  41080. inspectorURL?: string;
  41081. }
  41082. module "babylonjs/scene" {
  41083. interface Scene {
  41084. /**
  41085. * @hidden
  41086. * Backing field
  41087. */
  41088. _debugLayer: DebugLayer;
  41089. /**
  41090. * Gets the debug layer (aka Inspector) associated with the scene
  41091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41092. */
  41093. debugLayer: DebugLayer;
  41094. }
  41095. }
  41096. /**
  41097. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41098. * what is happening in your scene
  41099. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41100. */
  41101. export class DebugLayer {
  41102. /**
  41103. * Define the url to get the inspector script from.
  41104. * By default it uses the babylonjs CDN.
  41105. * @ignoreNaming
  41106. */
  41107. static InspectorURL: string;
  41108. private _scene;
  41109. private BJSINSPECTOR;
  41110. /**
  41111. * Observable triggered when a property is changed through the inspector.
  41112. */
  41113. onPropertyChangedObservable: Observable<{
  41114. object: any;
  41115. property: string;
  41116. value: any;
  41117. initialValue: any;
  41118. }>;
  41119. /**
  41120. * Instantiates a new debug layer.
  41121. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41122. * what is happening in your scene
  41123. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41124. * @param scene Defines the scene to inspect
  41125. */
  41126. constructor(scene: Scene);
  41127. /** Creates the inspector window. */
  41128. private _createInspector;
  41129. /** Get the inspector from bundle or global */
  41130. private _getGlobalInspector;
  41131. /**
  41132. * Get if the inspector is visible or not.
  41133. * @returns true if visible otherwise, false
  41134. */
  41135. isVisible(): boolean;
  41136. /**
  41137. * Hide the inspector and close its window.
  41138. */
  41139. hide(): void;
  41140. /**
  41141. * Launch the debugLayer.
  41142. * @param config Define the configuration of the inspector
  41143. */
  41144. show(config?: IInspectorOptions): void;
  41145. }
  41146. }
  41147. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41148. import { Nullable } from "babylonjs/types";
  41149. import { Scene } from "babylonjs/scene";
  41150. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41151. import { Mesh } from "babylonjs/Meshes/mesh";
  41152. /**
  41153. * Class containing static functions to help procedurally build meshes
  41154. */
  41155. export class BoxBuilder {
  41156. /**
  41157. * Creates a box mesh
  41158. * * The parameter `size` sets the size (float) of each box side (default 1)
  41159. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41160. * * 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)
  41161. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41165. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41166. * @param name defines the name of the mesh
  41167. * @param options defines the options used to create the mesh
  41168. * @param scene defines the hosting scene
  41169. * @returns the box mesh
  41170. */
  41171. static CreateBox(name: string, options: {
  41172. size?: number;
  41173. width?: number;
  41174. height?: number;
  41175. depth?: number;
  41176. faceUV?: Vector4[];
  41177. faceColors?: Color4[];
  41178. sideOrientation?: number;
  41179. frontUVs?: Vector4;
  41180. backUVs?: Vector4;
  41181. updatable?: boolean;
  41182. }, scene?: Nullable<Scene>): Mesh;
  41183. }
  41184. }
  41185. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41186. import { Vector4 } from "babylonjs/Maths/math";
  41187. import { Mesh } from "babylonjs/Meshes/mesh";
  41188. /**
  41189. * Class containing static functions to help procedurally build meshes
  41190. */
  41191. export class SphereBuilder {
  41192. /**
  41193. * Creates a sphere mesh
  41194. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41195. * * 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`)
  41196. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41197. * * 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
  41198. * * 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)
  41199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41202. * @param name defines the name of the mesh
  41203. * @param options defines the options used to create the mesh
  41204. * @param scene defines the hosting scene
  41205. * @returns the sphere mesh
  41206. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41207. */
  41208. static CreateSphere(name: string, options: {
  41209. segments?: number;
  41210. diameter?: number;
  41211. diameterX?: number;
  41212. diameterY?: number;
  41213. diameterZ?: number;
  41214. arc?: number;
  41215. slice?: number;
  41216. sideOrientation?: number;
  41217. frontUVs?: Vector4;
  41218. backUVs?: Vector4;
  41219. updatable?: boolean;
  41220. }, scene: any): Mesh;
  41221. }
  41222. }
  41223. declare module "babylonjs/Debug/physicsViewer" {
  41224. import { Nullable } from "babylonjs/types";
  41225. import { Scene } from "babylonjs/scene";
  41226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41227. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41228. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41229. /**
  41230. * Used to show the physics impostor around the specific mesh
  41231. */
  41232. export class PhysicsViewer {
  41233. /** @hidden */
  41234. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41235. /** @hidden */
  41236. protected _meshes: Array<Nullable<AbstractMesh>>;
  41237. /** @hidden */
  41238. protected _scene: Nullable<Scene>;
  41239. /** @hidden */
  41240. protected _numMeshes: number;
  41241. /** @hidden */
  41242. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41243. private _renderFunction;
  41244. private _utilityLayer;
  41245. private _debugBoxMesh;
  41246. private _debugSphereMesh;
  41247. private _debugMaterial;
  41248. /**
  41249. * Creates a new PhysicsViewer
  41250. * @param scene defines the hosting scene
  41251. */
  41252. constructor(scene: Scene);
  41253. /** @hidden */
  41254. protected _updateDebugMeshes(): void;
  41255. /**
  41256. * Renders a specified physic impostor
  41257. * @param impostor defines the impostor to render
  41258. * @returns the new debug mesh used to render the impostor
  41259. */
  41260. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41261. /**
  41262. * Hides a specified physic impostor
  41263. * @param impostor defines the impostor to hide
  41264. */
  41265. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41266. private _getDebugMaterial;
  41267. private _getDebugBoxMesh;
  41268. private _getDebugSphereMesh;
  41269. private _getDebugMesh;
  41270. /** Releases all resources */
  41271. dispose(): void;
  41272. }
  41273. }
  41274. declare module "babylonjs/Debug/rayHelper" {
  41275. import { Nullable } from "babylonjs/types";
  41276. import { Ray } from "babylonjs/Culling/ray";
  41277. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41278. import { Scene } from "babylonjs/scene";
  41279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41280. import "babylonjs/Meshes/Builders/linesBuilder";
  41281. /**
  41282. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41283. * in order to better appreciate the issue one might have.
  41284. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41285. */
  41286. export class RayHelper {
  41287. /**
  41288. * Defines the ray we are currently tryin to visualize.
  41289. */
  41290. ray: Nullable<Ray>;
  41291. private _renderPoints;
  41292. private _renderLine;
  41293. private _renderFunction;
  41294. private _scene;
  41295. private _updateToMeshFunction;
  41296. private _attachedToMesh;
  41297. private _meshSpaceDirection;
  41298. private _meshSpaceOrigin;
  41299. /**
  41300. * Helper function to create a colored helper in a scene in one line.
  41301. * @param ray Defines the ray we are currently tryin to visualize
  41302. * @param scene Defines the scene the ray is used in
  41303. * @param color Defines the color we want to see the ray in
  41304. * @returns The newly created ray helper.
  41305. */
  41306. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41307. /**
  41308. * Instantiate a new ray helper.
  41309. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41310. * in order to better appreciate the issue one might have.
  41311. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41312. * @param ray Defines the ray we are currently tryin to visualize
  41313. */
  41314. constructor(ray: Ray);
  41315. /**
  41316. * Shows the ray we are willing to debug.
  41317. * @param scene Defines the scene the ray needs to be rendered in
  41318. * @param color Defines the color the ray needs to be rendered in
  41319. */
  41320. show(scene: Scene, color?: Color3): void;
  41321. /**
  41322. * Hides the ray we are debugging.
  41323. */
  41324. hide(): void;
  41325. private _render;
  41326. /**
  41327. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41328. * @param mesh Defines the mesh we want the helper attached to
  41329. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41330. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41331. * @param length Defines the length of the ray
  41332. */
  41333. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41334. /**
  41335. * Detach the ray helper from the mesh it has previously been attached to.
  41336. */
  41337. detachFromMesh(): void;
  41338. private _updateToMesh;
  41339. /**
  41340. * Dispose the helper and release its associated resources.
  41341. */
  41342. dispose(): void;
  41343. }
  41344. }
  41345. declare module "babylonjs/Debug/skeletonViewer" {
  41346. import { Color3 } from "babylonjs/Maths/math";
  41347. import { Scene } from "babylonjs/scene";
  41348. import { Nullable } from "babylonjs/types";
  41349. import { Skeleton } from "babylonjs/Bones/skeleton";
  41350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41351. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41352. /**
  41353. * Class used to render a debug view of a given skeleton
  41354. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41355. */
  41356. export class SkeletonViewer {
  41357. /** defines the skeleton to render */
  41358. skeleton: Skeleton;
  41359. /** defines the mesh attached to the skeleton */
  41360. mesh: AbstractMesh;
  41361. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41362. autoUpdateBonesMatrices: boolean;
  41363. /** defines the rendering group id to use with the viewer */
  41364. renderingGroupId: number;
  41365. /** Gets or sets the color used to render the skeleton */
  41366. color: Color3;
  41367. private _scene;
  41368. private _debugLines;
  41369. private _debugMesh;
  41370. private _isEnabled;
  41371. private _renderFunction;
  41372. private _utilityLayer;
  41373. /**
  41374. * Returns the mesh used to render the bones
  41375. */
  41376. readonly debugMesh: Nullable<LinesMesh>;
  41377. /**
  41378. * Creates a new SkeletonViewer
  41379. * @param skeleton defines the skeleton to render
  41380. * @param mesh defines the mesh attached to the skeleton
  41381. * @param scene defines the hosting scene
  41382. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41383. * @param renderingGroupId defines the rendering group id to use with the viewer
  41384. */
  41385. constructor(
  41386. /** defines the skeleton to render */
  41387. skeleton: Skeleton,
  41388. /** defines the mesh attached to the skeleton */
  41389. mesh: AbstractMesh, scene: Scene,
  41390. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41391. autoUpdateBonesMatrices?: boolean,
  41392. /** defines the rendering group id to use with the viewer */
  41393. renderingGroupId?: number);
  41394. /** Gets or sets a boolean indicating if the viewer is enabled */
  41395. isEnabled: boolean;
  41396. private _getBonePosition;
  41397. private _getLinesForBonesWithLength;
  41398. private _getLinesForBonesNoLength;
  41399. /** Update the viewer to sync with current skeleton state */
  41400. update(): void;
  41401. /** Release associated resources */
  41402. dispose(): void;
  41403. }
  41404. }
  41405. declare module "babylonjs/Debug/index" {
  41406. export * from "babylonjs/Debug/axesViewer";
  41407. export * from "babylonjs/Debug/boneAxesViewer";
  41408. export * from "babylonjs/Debug/debugLayer";
  41409. export * from "babylonjs/Debug/physicsViewer";
  41410. export * from "babylonjs/Debug/rayHelper";
  41411. export * from "babylonjs/Debug/skeletonViewer";
  41412. }
  41413. declare module "babylonjs/Engines/nullEngine" {
  41414. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41415. import { Scene } from "babylonjs/scene";
  41416. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41417. import { Engine } from "babylonjs/Engines/engine";
  41418. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41419. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41420. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41421. import { Effect } from "babylonjs/Materials/effect";
  41422. /**
  41423. * Options to create the null engine
  41424. */
  41425. export class NullEngineOptions {
  41426. /**
  41427. * Render width (Default: 512)
  41428. */
  41429. renderWidth: number;
  41430. /**
  41431. * Render height (Default: 256)
  41432. */
  41433. renderHeight: number;
  41434. /**
  41435. * Texture size (Default: 512)
  41436. */
  41437. textureSize: number;
  41438. /**
  41439. * If delta time between frames should be constant
  41440. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41441. */
  41442. deterministicLockstep: boolean;
  41443. /**
  41444. * Maximum about of steps between frames (Default: 4)
  41445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41446. */
  41447. lockstepMaxSteps: number;
  41448. }
  41449. /**
  41450. * The null engine class provides support for headless version of babylon.js.
  41451. * This can be used in server side scenario or for testing purposes
  41452. */
  41453. export class NullEngine extends Engine {
  41454. private _options;
  41455. /**
  41456. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41457. */
  41458. isDeterministicLockStep(): boolean;
  41459. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41460. getLockstepMaxSteps(): number;
  41461. /**
  41462. * Sets hardware scaling, used to save performance if needed
  41463. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41464. */
  41465. getHardwareScalingLevel(): number;
  41466. constructor(options?: NullEngineOptions);
  41467. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41468. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41469. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41470. getRenderWidth(useScreen?: boolean): number;
  41471. getRenderHeight(useScreen?: boolean): number;
  41472. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41473. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41474. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41475. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41476. bindSamplers(effect: Effect): void;
  41477. enableEffect(effect: Effect): void;
  41478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41479. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41480. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41481. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41482. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41483. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41484. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41485. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41486. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41487. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41488. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41489. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41490. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41491. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41492. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41493. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41494. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41495. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41496. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41497. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41498. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41499. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41500. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41501. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41502. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41503. bindBuffers(vertexBuffers: {
  41504. [key: string]: VertexBuffer;
  41505. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41506. wipeCaches(bruteForce?: boolean): void;
  41507. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41508. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41509. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41510. /** @hidden */
  41511. _createTexture(): WebGLTexture;
  41512. /** @hidden */
  41513. _releaseTexture(texture: InternalTexture): void;
  41514. 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;
  41515. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41516. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41517. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41518. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41519. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41520. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41521. areAllEffectsReady(): boolean;
  41522. /**
  41523. * @hidden
  41524. * Get the current error code of the webGL context
  41525. * @returns the error code
  41526. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41527. */
  41528. getError(): number;
  41529. /** @hidden */
  41530. _getUnpackAlignement(): number;
  41531. /** @hidden */
  41532. _unpackFlipY(value: boolean): void;
  41533. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41534. /**
  41535. * Updates a dynamic vertex buffer.
  41536. * @param vertexBuffer the vertex buffer to update
  41537. * @param data the data used to update the vertex buffer
  41538. * @param byteOffset the byte offset of the data (optional)
  41539. * @param byteLength the byte length of the data (optional)
  41540. */
  41541. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41542. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41543. /** @hidden */
  41544. _bindTexture(channel: number, texture: InternalTexture): void;
  41545. /** @hidden */
  41546. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41547. releaseEffects(): void;
  41548. displayLoadingUI(): void;
  41549. hideLoadingUI(): void;
  41550. /** @hidden */
  41551. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41552. /** @hidden */
  41553. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41554. /** @hidden */
  41555. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41556. /** @hidden */
  41557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41558. }
  41559. }
  41560. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41561. import { Nullable, int } from "babylonjs/types";
  41562. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41563. /** @hidden */
  41564. export class _OcclusionDataStorage {
  41565. /** @hidden */
  41566. occlusionInternalRetryCounter: number;
  41567. /** @hidden */
  41568. isOcclusionQueryInProgress: boolean;
  41569. /** @hidden */
  41570. isOccluded: boolean;
  41571. /** @hidden */
  41572. occlusionRetryCount: number;
  41573. /** @hidden */
  41574. occlusionType: number;
  41575. /** @hidden */
  41576. occlusionQueryAlgorithmType: number;
  41577. }
  41578. module "babylonjs/Engines/engine" {
  41579. interface Engine {
  41580. /**
  41581. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41582. * @return the new query
  41583. */
  41584. createQuery(): WebGLQuery;
  41585. /**
  41586. * Delete and release a webGL query
  41587. * @param query defines the query to delete
  41588. * @return the current engine
  41589. */
  41590. deleteQuery(query: WebGLQuery): Engine;
  41591. /**
  41592. * Check if a given query has resolved and got its value
  41593. * @param query defines the query to check
  41594. * @returns true if the query got its value
  41595. */
  41596. isQueryResultAvailable(query: WebGLQuery): boolean;
  41597. /**
  41598. * Gets the value of a given query
  41599. * @param query defines the query to check
  41600. * @returns the value of the query
  41601. */
  41602. getQueryResult(query: WebGLQuery): number;
  41603. /**
  41604. * Initiates an occlusion query
  41605. * @param algorithmType defines the algorithm to use
  41606. * @param query defines the query to use
  41607. * @returns the current engine
  41608. * @see http://doc.babylonjs.com/features/occlusionquery
  41609. */
  41610. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41611. /**
  41612. * Ends an occlusion query
  41613. * @see http://doc.babylonjs.com/features/occlusionquery
  41614. * @param algorithmType defines the algorithm to use
  41615. * @returns the current engine
  41616. */
  41617. endOcclusionQuery(algorithmType: number): Engine;
  41618. /**
  41619. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41620. * Please note that only one query can be issued at a time
  41621. * @returns a time token used to track the time span
  41622. */
  41623. startTimeQuery(): Nullable<_TimeToken>;
  41624. /**
  41625. * Ends a time query
  41626. * @param token defines the token used to measure the time span
  41627. * @returns the time spent (in ns)
  41628. */
  41629. endTimeQuery(token: _TimeToken): int;
  41630. /** @hidden */
  41631. _currentNonTimestampToken: Nullable<_TimeToken>;
  41632. /** @hidden */
  41633. _createTimeQuery(): WebGLQuery;
  41634. /** @hidden */
  41635. _deleteTimeQuery(query: WebGLQuery): void;
  41636. /** @hidden */
  41637. _getGlAlgorithmType(algorithmType: number): number;
  41638. /** @hidden */
  41639. _getTimeQueryResult(query: WebGLQuery): any;
  41640. /** @hidden */
  41641. _getTimeQueryAvailability(query: WebGLQuery): any;
  41642. }
  41643. }
  41644. module "babylonjs/Meshes/abstractMesh" {
  41645. interface AbstractMesh {
  41646. /**
  41647. * Backing filed
  41648. * @hidden
  41649. */
  41650. __occlusionDataStorage: _OcclusionDataStorage;
  41651. /**
  41652. * Access property
  41653. * @hidden
  41654. */
  41655. _occlusionDataStorage: _OcclusionDataStorage;
  41656. /**
  41657. * 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.
  41658. * The default value is -1 which means don't break the query and wait till the result
  41659. * @see http://doc.babylonjs.com/features/occlusionquery
  41660. */
  41661. occlusionRetryCount: number;
  41662. /**
  41663. * 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:
  41664. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41665. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41666. * * 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.
  41667. * @see http://doc.babylonjs.com/features/occlusionquery
  41668. */
  41669. occlusionType: number;
  41670. /**
  41671. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41672. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41673. * * 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.
  41674. * @see http://doc.babylonjs.com/features/occlusionquery
  41675. */
  41676. occlusionQueryAlgorithmType: number;
  41677. /**
  41678. * 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
  41679. * @see http://doc.babylonjs.com/features/occlusionquery
  41680. */
  41681. isOccluded: boolean;
  41682. /**
  41683. * Flag to check the progress status of the query
  41684. * @see http://doc.babylonjs.com/features/occlusionquery
  41685. */
  41686. isOcclusionQueryInProgress: boolean;
  41687. }
  41688. }
  41689. }
  41690. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41691. import { Nullable } from "babylonjs/types";
  41692. /** @hidden */
  41693. export var _forceTransformFeedbackToBundle: boolean;
  41694. module "babylonjs/Engines/engine" {
  41695. interface Engine {
  41696. /**
  41697. * Creates a webGL transform feedback object
  41698. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41699. * @returns the webGL transform feedback object
  41700. */
  41701. createTransformFeedback(): WebGLTransformFeedback;
  41702. /**
  41703. * Delete a webGL transform feedback object
  41704. * @param value defines the webGL transform feedback object to delete
  41705. */
  41706. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41707. /**
  41708. * Bind a webGL transform feedback object to the webgl context
  41709. * @param value defines the webGL transform feedback object to bind
  41710. */
  41711. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41712. /**
  41713. * Begins a transform feedback operation
  41714. * @param usePoints defines if points or triangles must be used
  41715. */
  41716. beginTransformFeedback(usePoints: boolean): void;
  41717. /**
  41718. * Ends a transform feedback operation
  41719. */
  41720. endTransformFeedback(): void;
  41721. /**
  41722. * Specify the varyings to use with transform feedback
  41723. * @param program defines the associated webGL program
  41724. * @param value defines the list of strings representing the varying names
  41725. */
  41726. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41727. /**
  41728. * Bind a webGL buffer for a transform feedback operation
  41729. * @param value defines the webGL buffer to bind
  41730. */
  41731. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41732. }
  41733. }
  41734. }
  41735. declare module "babylonjs/Engines/Extensions/index" {
  41736. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41737. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41738. }
  41739. declare module "babylonjs/Engines/index" {
  41740. export * from "babylonjs/Engines/constants";
  41741. export * from "babylonjs/Engines/engine";
  41742. export * from "babylonjs/Engines/engineStore";
  41743. export * from "babylonjs/Engines/nullEngine";
  41744. export * from "babylonjs/Engines/Extensions/index";
  41745. }
  41746. declare module "babylonjs/Events/clipboardEvents" {
  41747. /**
  41748. * Gather the list of clipboard event types as constants.
  41749. */
  41750. export class ClipboardEventTypes {
  41751. /**
  41752. * The clipboard event is fired when a copy command is active (pressed).
  41753. */
  41754. static readonly COPY: number;
  41755. /**
  41756. * The clipboard event is fired when a cut command is active (pressed).
  41757. */
  41758. static readonly CUT: number;
  41759. /**
  41760. * The clipboard event is fired when a paste command is active (pressed).
  41761. */
  41762. static readonly PASTE: number;
  41763. }
  41764. /**
  41765. * This class is used to store clipboard related info for the onClipboardObservable event.
  41766. */
  41767. export class ClipboardInfo {
  41768. /**
  41769. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41770. */
  41771. type: number;
  41772. /**
  41773. * Defines the related dom event
  41774. */
  41775. event: ClipboardEvent;
  41776. /**
  41777. *Creates an instance of ClipboardInfo.
  41778. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41779. * @param event Defines the related dom event
  41780. */
  41781. constructor(
  41782. /**
  41783. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41784. */
  41785. type: number,
  41786. /**
  41787. * Defines the related dom event
  41788. */
  41789. event: ClipboardEvent);
  41790. /**
  41791. * Get the clipboard event's type from the keycode.
  41792. * @param keyCode Defines the keyCode for the current keyboard event.
  41793. * @return {number}
  41794. */
  41795. static GetTypeFromCharacter(keyCode: number): number;
  41796. }
  41797. }
  41798. declare module "babylonjs/Events/index" {
  41799. export * from "babylonjs/Events/keyboardEvents";
  41800. export * from "babylonjs/Events/pointerEvents";
  41801. export * from "babylonjs/Events/clipboardEvents";
  41802. }
  41803. declare module "babylonjs/Loading/sceneLoader" {
  41804. import { Observable } from "babylonjs/Misc/observable";
  41805. import { Nullable } from "babylonjs/types";
  41806. import { Scene } from "babylonjs/scene";
  41807. import { Engine } from "babylonjs/Engines/engine";
  41808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41809. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41810. import { AssetContainer } from "babylonjs/assetContainer";
  41811. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41812. import { Skeleton } from "babylonjs/Bones/skeleton";
  41813. /**
  41814. * Class used to represent data loading progression
  41815. */
  41816. export class SceneLoaderProgressEvent {
  41817. /** defines if data length to load can be evaluated */
  41818. readonly lengthComputable: boolean;
  41819. /** defines the loaded data length */
  41820. readonly loaded: number;
  41821. /** defines the data length to load */
  41822. readonly total: number;
  41823. /**
  41824. * Create a new progress event
  41825. * @param lengthComputable defines if data length to load can be evaluated
  41826. * @param loaded defines the loaded data length
  41827. * @param total defines the data length to load
  41828. */
  41829. constructor(
  41830. /** defines if data length to load can be evaluated */
  41831. lengthComputable: boolean,
  41832. /** defines the loaded data length */
  41833. loaded: number,
  41834. /** defines the data length to load */
  41835. total: number);
  41836. /**
  41837. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41838. * @param event defines the source event
  41839. * @returns a new SceneLoaderProgressEvent
  41840. */
  41841. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41842. }
  41843. /**
  41844. * Interface used by SceneLoader plugins to define supported file extensions
  41845. */
  41846. export interface ISceneLoaderPluginExtensions {
  41847. /**
  41848. * Defines the list of supported extensions
  41849. */
  41850. [extension: string]: {
  41851. isBinary: boolean;
  41852. };
  41853. }
  41854. /**
  41855. * Interface used by SceneLoader plugin factory
  41856. */
  41857. export interface ISceneLoaderPluginFactory {
  41858. /**
  41859. * Defines the name of the factory
  41860. */
  41861. name: string;
  41862. /**
  41863. * Function called to create a new plugin
  41864. * @return the new plugin
  41865. */
  41866. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41867. /**
  41868. * Boolean indicating if the plugin can direct load specific data
  41869. */
  41870. canDirectLoad?: (data: string) => boolean;
  41871. }
  41872. /**
  41873. * Interface used to define a SceneLoader plugin
  41874. */
  41875. export interface ISceneLoaderPlugin {
  41876. /**
  41877. * The friendly name of this plugin.
  41878. */
  41879. name: string;
  41880. /**
  41881. * The file extensions supported by this plugin.
  41882. */
  41883. extensions: string | ISceneLoaderPluginExtensions;
  41884. /**
  41885. * Import meshes into a scene.
  41886. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41887. * @param scene The scene to import into
  41888. * @param data The data to import
  41889. * @param rootUrl The root url for scene and resources
  41890. * @param meshes The meshes array to import into
  41891. * @param particleSystems The particle systems array to import into
  41892. * @param skeletons The skeletons array to import into
  41893. * @param onError The callback when import fails
  41894. * @returns True if successful or false otherwise
  41895. */
  41896. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41897. /**
  41898. * Load into a scene.
  41899. * @param scene The scene to load into
  41900. * @param data The data to import
  41901. * @param rootUrl The root url for scene and resources
  41902. * @param onError The callback when import fails
  41903. * @returns true if successful or false otherwise
  41904. */
  41905. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41906. /**
  41907. * The callback that returns true if the data can be directly loaded.
  41908. */
  41909. canDirectLoad?: (data: string) => boolean;
  41910. /**
  41911. * The callback that allows custom handling of the root url based on the response url.
  41912. */
  41913. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41914. /**
  41915. * Load into an asset container.
  41916. * @param scene The scene to load into
  41917. * @param data The data to import
  41918. * @param rootUrl The root url for scene and resources
  41919. * @param onError The callback when import fails
  41920. * @returns The loaded asset container
  41921. */
  41922. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41923. }
  41924. /**
  41925. * Interface used to define an async SceneLoader plugin
  41926. */
  41927. export interface ISceneLoaderPluginAsync {
  41928. /**
  41929. * The friendly name of this plugin.
  41930. */
  41931. name: string;
  41932. /**
  41933. * The file extensions supported by this plugin.
  41934. */
  41935. extensions: string | ISceneLoaderPluginExtensions;
  41936. /**
  41937. * Import meshes into a scene.
  41938. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41939. * @param scene The scene to import into
  41940. * @param data The data to import
  41941. * @param rootUrl The root url for scene and resources
  41942. * @param onProgress The callback when the load progresses
  41943. * @param fileName Defines the name of the file to load
  41944. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41945. */
  41946. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41947. meshes: AbstractMesh[];
  41948. particleSystems: IParticleSystem[];
  41949. skeletons: Skeleton[];
  41950. animationGroups: AnimationGroup[];
  41951. }>;
  41952. /**
  41953. * Load into a scene.
  41954. * @param scene The scene to load into
  41955. * @param data The data to import
  41956. * @param rootUrl The root url for scene and resources
  41957. * @param onProgress The callback when the load progresses
  41958. * @param fileName Defines the name of the file to load
  41959. * @returns Nothing
  41960. */
  41961. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41962. /**
  41963. * The callback that returns true if the data can be directly loaded.
  41964. */
  41965. canDirectLoad?: (data: string) => boolean;
  41966. /**
  41967. * The callback that allows custom handling of the root url based on the response url.
  41968. */
  41969. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41970. /**
  41971. * Load into an asset container.
  41972. * @param scene The scene to load into
  41973. * @param data The data to import
  41974. * @param rootUrl The root url for scene and resources
  41975. * @param onProgress The callback when the load progresses
  41976. * @param fileName Defines the name of the file to load
  41977. * @returns The loaded asset container
  41978. */
  41979. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41980. }
  41981. /**
  41982. * Class used to load scene from various file formats using registered plugins
  41983. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41984. */
  41985. export class SceneLoader {
  41986. /**
  41987. * No logging while loading
  41988. */
  41989. static readonly NO_LOGGING: number;
  41990. /**
  41991. * Minimal logging while loading
  41992. */
  41993. static readonly MINIMAL_LOGGING: number;
  41994. /**
  41995. * Summary logging while loading
  41996. */
  41997. static readonly SUMMARY_LOGGING: number;
  41998. /**
  41999. * Detailled logging while loading
  42000. */
  42001. static readonly DETAILED_LOGGING: number;
  42002. /**
  42003. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42004. */
  42005. static ForceFullSceneLoadingForIncremental: boolean;
  42006. /**
  42007. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42008. */
  42009. static ShowLoadingScreen: boolean;
  42010. /**
  42011. * Defines the current logging level (while loading the scene)
  42012. * @ignorenaming
  42013. */
  42014. static loggingLevel: number;
  42015. /**
  42016. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42017. */
  42018. static CleanBoneMatrixWeights: boolean;
  42019. /**
  42020. * Event raised when a plugin is used to load a scene
  42021. */
  42022. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42023. private static _registeredPlugins;
  42024. private static _getDefaultPlugin;
  42025. private static _getPluginForExtension;
  42026. private static _getPluginForDirectLoad;
  42027. private static _getPluginForFilename;
  42028. private static _getDirectLoad;
  42029. private static _loadData;
  42030. private static _getFileInfo;
  42031. /**
  42032. * Gets a plugin that can load the given extension
  42033. * @param extension defines the extension to load
  42034. * @returns a plugin or null if none works
  42035. */
  42036. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42037. /**
  42038. * Gets a boolean indicating that the given extension can be loaded
  42039. * @param extension defines the extension to load
  42040. * @returns true if the extension is supported
  42041. */
  42042. static IsPluginForExtensionAvailable(extension: string): boolean;
  42043. /**
  42044. * Adds a new plugin to the list of registered plugins
  42045. * @param plugin defines the plugin to add
  42046. */
  42047. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42048. /**
  42049. * Import meshes into a scene
  42050. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42051. * @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)
  42052. * @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)
  42053. * @param scene the instance of BABYLON.Scene to append to
  42054. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42055. * @param onProgress a callback with a progress event for each file being loaded
  42056. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42057. * @param pluginExtension the extension used to determine the plugin
  42058. * @returns The loaded plugin
  42059. */
  42060. 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>;
  42061. /**
  42062. * Import meshes into a scene
  42063. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42064. * @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)
  42065. * @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)
  42066. * @param scene the instance of BABYLON.Scene to append to
  42067. * @param onProgress a callback with a progress event for each file being loaded
  42068. * @param pluginExtension the extension used to determine the plugin
  42069. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42070. */
  42071. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42072. meshes: AbstractMesh[];
  42073. particleSystems: IParticleSystem[];
  42074. skeletons: Skeleton[];
  42075. animationGroups: AnimationGroup[];
  42076. }>;
  42077. /**
  42078. * Load a scene
  42079. * @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)
  42080. * @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)
  42081. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42082. * @param onSuccess a callback with the scene when import succeeds
  42083. * @param onProgress a callback with a progress event for each file being loaded
  42084. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42085. * @param pluginExtension the extension used to determine the plugin
  42086. * @returns The loaded plugin
  42087. */
  42088. 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>;
  42089. /**
  42090. * Load a scene
  42091. * @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)
  42092. * @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)
  42093. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42094. * @param onProgress a callback with a progress event for each file being loaded
  42095. * @param pluginExtension the extension used to determine the plugin
  42096. * @returns The loaded scene
  42097. */
  42098. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42099. /**
  42100. * Append a scene
  42101. * @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)
  42102. * @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)
  42103. * @param scene is the instance of BABYLON.Scene to append to
  42104. * @param onSuccess a callback with the scene when import succeeds
  42105. * @param onProgress a callback with a progress event for each file being loaded
  42106. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42107. * @param pluginExtension the extension used to determine the plugin
  42108. * @returns The loaded plugin
  42109. */
  42110. 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>;
  42111. /**
  42112. * Append a scene
  42113. * @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)
  42114. * @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)
  42115. * @param scene is the instance of BABYLON.Scene to append to
  42116. * @param onProgress a callback with a progress event for each file being loaded
  42117. * @param pluginExtension the extension used to determine the plugin
  42118. * @returns The given scene
  42119. */
  42120. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42121. /**
  42122. * Load a scene into an asset container
  42123. * @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)
  42124. * @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)
  42125. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42126. * @param onSuccess a callback with the scene when import succeeds
  42127. * @param onProgress a callback with a progress event for each file being loaded
  42128. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42129. * @param pluginExtension the extension used to determine the plugin
  42130. * @returns The loaded plugin
  42131. */
  42132. 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>;
  42133. /**
  42134. * Load a scene into an asset container
  42135. * @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)
  42136. * @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)
  42137. * @param scene is the instance of Scene to append to
  42138. * @param onProgress a callback with a progress event for each file being loaded
  42139. * @param pluginExtension the extension used to determine the plugin
  42140. * @returns The loaded asset container
  42141. */
  42142. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42143. }
  42144. }
  42145. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42146. import { Scene } from "babylonjs/scene";
  42147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42148. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42149. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42150. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42151. /**
  42152. * Google Daydream controller
  42153. */
  42154. export class DaydreamController extends WebVRController {
  42155. /**
  42156. * Base Url for the controller model.
  42157. */
  42158. static MODEL_BASE_URL: string;
  42159. /**
  42160. * File name for the controller model.
  42161. */
  42162. static MODEL_FILENAME: string;
  42163. /**
  42164. * Gamepad Id prefix used to identify Daydream Controller.
  42165. */
  42166. static readonly GAMEPAD_ID_PREFIX: string;
  42167. /**
  42168. * Creates a new DaydreamController from a gamepad
  42169. * @param vrGamepad the gamepad that the controller should be created from
  42170. */
  42171. constructor(vrGamepad: any);
  42172. /**
  42173. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42174. * @param scene scene in which to add meshes
  42175. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42176. */
  42177. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42178. /**
  42179. * Called once for each button that changed state since the last frame
  42180. * @param buttonIdx Which button index changed
  42181. * @param state New state of the button
  42182. * @param changes Which properties on the state changed since last frame
  42183. */
  42184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42185. }
  42186. }
  42187. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42188. import { Scene } from "babylonjs/scene";
  42189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42190. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42191. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42192. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42193. /**
  42194. * Gear VR Controller
  42195. */
  42196. export class GearVRController extends WebVRController {
  42197. /**
  42198. * Base Url for the controller model.
  42199. */
  42200. static MODEL_BASE_URL: string;
  42201. /**
  42202. * File name for the controller model.
  42203. */
  42204. static MODEL_FILENAME: string;
  42205. /**
  42206. * Gamepad Id prefix used to identify this controller.
  42207. */
  42208. static readonly GAMEPAD_ID_PREFIX: string;
  42209. private readonly _buttonIndexToObservableNameMap;
  42210. /**
  42211. * Creates a new GearVRController from a gamepad
  42212. * @param vrGamepad the gamepad that the controller should be created from
  42213. */
  42214. constructor(vrGamepad: any);
  42215. /**
  42216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42217. * @param scene scene in which to add meshes
  42218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42219. */
  42220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42221. /**
  42222. * Called once for each button that changed state since the last frame
  42223. * @param buttonIdx Which button index changed
  42224. * @param state New state of the button
  42225. * @param changes Which properties on the state changed since last frame
  42226. */
  42227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42228. }
  42229. }
  42230. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42231. import { Scene } from "babylonjs/scene";
  42232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42233. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42234. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42235. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42236. /**
  42237. * Generic Controller
  42238. */
  42239. export class GenericController extends WebVRController {
  42240. /**
  42241. * Base Url for the controller model.
  42242. */
  42243. static readonly MODEL_BASE_URL: string;
  42244. /**
  42245. * File name for the controller model.
  42246. */
  42247. static readonly MODEL_FILENAME: string;
  42248. /**
  42249. * Creates a new GenericController from a gamepad
  42250. * @param vrGamepad the gamepad that the controller should be created from
  42251. */
  42252. constructor(vrGamepad: any);
  42253. /**
  42254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42255. * @param scene scene in which to add meshes
  42256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42257. */
  42258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42259. /**
  42260. * Called once for each button that changed state since the last frame
  42261. * @param buttonIdx Which button index changed
  42262. * @param state New state of the button
  42263. * @param changes Which properties on the state changed since last frame
  42264. */
  42265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42266. }
  42267. }
  42268. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42269. import { Observable } from "babylonjs/Misc/observable";
  42270. import { Scene } from "babylonjs/scene";
  42271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42272. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42273. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42274. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42275. /**
  42276. * Oculus Touch Controller
  42277. */
  42278. export class OculusTouchController extends WebVRController {
  42279. /**
  42280. * Base Url for the controller model.
  42281. */
  42282. static MODEL_BASE_URL: string;
  42283. /**
  42284. * File name for the left controller model.
  42285. */
  42286. static MODEL_LEFT_FILENAME: string;
  42287. /**
  42288. * File name for the right controller model.
  42289. */
  42290. static MODEL_RIGHT_FILENAME: string;
  42291. /**
  42292. * Fired when the secondary trigger on this controller is modified
  42293. */
  42294. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42295. /**
  42296. * Fired when the thumb rest on this controller is modified
  42297. */
  42298. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42299. /**
  42300. * Creates a new OculusTouchController from a gamepad
  42301. * @param vrGamepad the gamepad that the controller should be created from
  42302. */
  42303. constructor(vrGamepad: any);
  42304. /**
  42305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42306. * @param scene scene in which to add meshes
  42307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42308. */
  42309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42310. /**
  42311. * Fired when the A button on this controller is modified
  42312. */
  42313. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42314. /**
  42315. * Fired when the B button on this controller is modified
  42316. */
  42317. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42318. /**
  42319. * Fired when the X button on this controller is modified
  42320. */
  42321. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42322. /**
  42323. * Fired when the Y button on this controller is modified
  42324. */
  42325. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42326. /**
  42327. * Called once for each button that changed state since the last frame
  42328. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42329. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42330. * 2) secondary trigger (same)
  42331. * 3) A (right) X (left), touch, pressed = value
  42332. * 4) B / Y
  42333. * 5) thumb rest
  42334. * @param buttonIdx Which button index changed
  42335. * @param state New state of the button
  42336. * @param changes Which properties on the state changed since last frame
  42337. */
  42338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42339. }
  42340. }
  42341. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42342. import { Scene } from "babylonjs/scene";
  42343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42344. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42345. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42346. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42347. import { Observable } from "babylonjs/Misc/observable";
  42348. /**
  42349. * Vive Controller
  42350. */
  42351. export class ViveController extends WebVRController {
  42352. /**
  42353. * Base Url for the controller model.
  42354. */
  42355. static MODEL_BASE_URL: string;
  42356. /**
  42357. * File name for the controller model.
  42358. */
  42359. static MODEL_FILENAME: string;
  42360. /**
  42361. * Creates a new ViveController from a gamepad
  42362. * @param vrGamepad the gamepad that the controller should be created from
  42363. */
  42364. constructor(vrGamepad: any);
  42365. /**
  42366. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42367. * @param scene scene in which to add meshes
  42368. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42369. */
  42370. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42371. /**
  42372. * Fired when the left button on this controller is modified
  42373. */
  42374. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42375. /**
  42376. * Fired when the right button on this controller is modified
  42377. */
  42378. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42379. /**
  42380. * Fired when the menu button on this controller is modified
  42381. */
  42382. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42383. /**
  42384. * Called once for each button that changed state since the last frame
  42385. * Vive mapping:
  42386. * 0: touchpad
  42387. * 1: trigger
  42388. * 2: left AND right buttons
  42389. * 3: menu button
  42390. * @param buttonIdx Which button index changed
  42391. * @param state New state of the button
  42392. * @param changes Which properties on the state changed since last frame
  42393. */
  42394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42395. }
  42396. }
  42397. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42398. import { Observable } from "babylonjs/Misc/observable";
  42399. import { Scene } from "babylonjs/scene";
  42400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42401. import { Ray } from "babylonjs/Culling/ray";
  42402. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42403. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42404. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42405. /**
  42406. * Defines the WindowsMotionController object that the state of the windows motion controller
  42407. */
  42408. export class WindowsMotionController extends WebVRController {
  42409. /**
  42410. * The base url used to load the left and right controller models
  42411. */
  42412. static MODEL_BASE_URL: string;
  42413. /**
  42414. * The name of the left controller model file
  42415. */
  42416. static MODEL_LEFT_FILENAME: string;
  42417. /**
  42418. * The name of the right controller model file
  42419. */
  42420. static MODEL_RIGHT_FILENAME: string;
  42421. /**
  42422. * The controller name prefix for this controller type
  42423. */
  42424. static readonly GAMEPAD_ID_PREFIX: string;
  42425. /**
  42426. * The controller id pattern for this controller type
  42427. */
  42428. private static readonly GAMEPAD_ID_PATTERN;
  42429. private _loadedMeshInfo;
  42430. private readonly _mapping;
  42431. /**
  42432. * Fired when the trackpad on this controller is clicked
  42433. */
  42434. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42435. /**
  42436. * Fired when the trackpad on this controller is modified
  42437. */
  42438. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42439. /**
  42440. * The current x and y values of this controller's trackpad
  42441. */
  42442. trackpad: StickValues;
  42443. /**
  42444. * Creates a new WindowsMotionController from a gamepad
  42445. * @param vrGamepad the gamepad that the controller should be created from
  42446. */
  42447. constructor(vrGamepad: any);
  42448. /**
  42449. * Fired when the trigger on this controller is modified
  42450. */
  42451. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42452. /**
  42453. * Fired when the menu button on this controller is modified
  42454. */
  42455. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42456. /**
  42457. * Fired when the grip button on this controller is modified
  42458. */
  42459. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42460. /**
  42461. * Fired when the thumbstick button on this controller is modified
  42462. */
  42463. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42464. /**
  42465. * Fired when the touchpad button on this controller is modified
  42466. */
  42467. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42468. /**
  42469. * Fired when the touchpad values on this controller are modified
  42470. */
  42471. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42472. private _updateTrackpad;
  42473. /**
  42474. * Called once per frame by the engine.
  42475. */
  42476. update(): void;
  42477. /**
  42478. * Called once for each button that changed state since the last frame
  42479. * @param buttonIdx Which button index changed
  42480. * @param state New state of the button
  42481. * @param changes Which properties on the state changed since last frame
  42482. */
  42483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42484. /**
  42485. * Moves the buttons on the controller mesh based on their current state
  42486. * @param buttonName the name of the button to move
  42487. * @param buttonValue the value of the button which determines the buttons new position
  42488. */
  42489. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42490. /**
  42491. * Moves the axis on the controller mesh based on its current state
  42492. * @param axis the index of the axis
  42493. * @param axisValue the value of the axis which determines the meshes new position
  42494. * @hidden
  42495. */
  42496. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42497. /**
  42498. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42499. * @param scene scene in which to add meshes
  42500. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42501. */
  42502. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42503. /**
  42504. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42505. * can be transformed by button presses and axes values, based on this._mapping.
  42506. *
  42507. * @param scene scene in which the meshes exist
  42508. * @param meshes list of meshes that make up the controller model to process
  42509. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42510. */
  42511. private processModel;
  42512. private createMeshInfo;
  42513. /**
  42514. * Gets the ray of the controller in the direction the controller is pointing
  42515. * @param length the length the resulting ray should be
  42516. * @returns a ray in the direction the controller is pointing
  42517. */
  42518. getForwardRay(length?: number): Ray;
  42519. /**
  42520. * Disposes of the controller
  42521. */
  42522. dispose(): void;
  42523. }
  42524. }
  42525. declare module "babylonjs/Gamepads/Controllers/index" {
  42526. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42527. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42528. export * from "babylonjs/Gamepads/Controllers/genericController";
  42529. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42530. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42531. export * from "babylonjs/Gamepads/Controllers/viveController";
  42532. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42533. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42534. }
  42535. declare module "babylonjs/Gamepads/index" {
  42536. export * from "babylonjs/Gamepads/Controllers/index";
  42537. export * from "babylonjs/Gamepads/gamepad";
  42538. export * from "babylonjs/Gamepads/gamepadManager";
  42539. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42540. export * from "babylonjs/Gamepads/xboxGamepad";
  42541. }
  42542. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42543. import { Observable } from "babylonjs/Misc/observable";
  42544. import { Nullable } from "babylonjs/types";
  42545. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42547. import { Mesh } from "babylonjs/Meshes/mesh";
  42548. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42549. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42550. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42551. /**
  42552. * Single axis scale gizmo
  42553. */
  42554. export class AxisScaleGizmo extends Gizmo {
  42555. private _coloredMaterial;
  42556. /**
  42557. * Drag behavior responsible for the gizmos dragging interactions
  42558. */
  42559. dragBehavior: PointerDragBehavior;
  42560. private _pointerObserver;
  42561. /**
  42562. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42563. */
  42564. snapDistance: number;
  42565. /**
  42566. * Event that fires each time the gizmo snaps to a new location.
  42567. * * snapDistance is the the change in distance
  42568. */
  42569. onSnapObservable: Observable<{
  42570. snapDistance: number;
  42571. }>;
  42572. /**
  42573. * If the scaling operation should be done on all axis (default: false)
  42574. */
  42575. uniformScaling: boolean;
  42576. /**
  42577. * Creates an AxisScaleGizmo
  42578. * @param gizmoLayer The utility layer the gizmo will be added to
  42579. * @param dragAxis The axis which the gizmo will be able to scale on
  42580. * @param color The color of the gizmo
  42581. */
  42582. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42583. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42584. /**
  42585. * Disposes of the gizmo
  42586. */
  42587. dispose(): void;
  42588. /**
  42589. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42590. * @param mesh The mesh to replace the default mesh of the gizmo
  42591. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42592. */
  42593. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42594. }
  42595. }
  42596. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42597. import { Observable } from "babylonjs/Misc/observable";
  42598. import { Nullable } from "babylonjs/types";
  42599. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42601. import { Mesh } from "babylonjs/Meshes/mesh";
  42602. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42604. import "babylonjs/Meshes/Builders/boxBuilder";
  42605. /**
  42606. * Bounding box gizmo
  42607. */
  42608. export class BoundingBoxGizmo extends Gizmo {
  42609. private _lineBoundingBox;
  42610. private _rotateSpheresParent;
  42611. private _scaleBoxesParent;
  42612. private _boundingDimensions;
  42613. private _renderObserver;
  42614. private _pointerObserver;
  42615. private _scaleDragSpeed;
  42616. private _tmpQuaternion;
  42617. private _tmpVector;
  42618. private _tmpRotationMatrix;
  42619. /**
  42620. * 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)
  42621. */
  42622. ignoreChildren: boolean;
  42623. /**
  42624. * 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)
  42625. */
  42626. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42627. /**
  42628. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42629. */
  42630. rotationSphereSize: number;
  42631. /**
  42632. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42633. */
  42634. scaleBoxSize: number;
  42635. /**
  42636. * 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)
  42637. */
  42638. fixedDragMeshScreenSize: boolean;
  42639. /**
  42640. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42641. */
  42642. fixedDragMeshScreenSizeDistanceFactor: number;
  42643. /**
  42644. * Fired when a rotation sphere or scale box is dragged
  42645. */
  42646. onDragStartObservable: Observable<{}>;
  42647. /**
  42648. * Fired when a scale box is dragged
  42649. */
  42650. onScaleBoxDragObservable: Observable<{}>;
  42651. /**
  42652. * Fired when a scale box drag is ended
  42653. */
  42654. onScaleBoxDragEndObservable: Observable<{}>;
  42655. /**
  42656. * Fired when a rotation sphere is dragged
  42657. */
  42658. onRotationSphereDragObservable: Observable<{}>;
  42659. /**
  42660. * Fired when a rotation sphere drag is ended
  42661. */
  42662. onRotationSphereDragEndObservable: Observable<{}>;
  42663. /**
  42664. * 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)
  42665. */
  42666. scalePivot: Nullable<Vector3>;
  42667. private _anchorMesh;
  42668. private _existingMeshScale;
  42669. private _dragMesh;
  42670. private pointerDragBehavior;
  42671. /**
  42672. * Creates an BoundingBoxGizmo
  42673. * @param gizmoLayer The utility layer the gizmo will be added to
  42674. * @param color The color of the gizmo
  42675. */
  42676. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42677. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42678. private _selectNode;
  42679. /**
  42680. * Updates the bounding box information for the Gizmo
  42681. */
  42682. updateBoundingBox(): void;
  42683. private _updateRotationSpheres;
  42684. private _updateScaleBoxes;
  42685. /**
  42686. * Enables rotation on the specified axis and disables rotation on the others
  42687. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42688. */
  42689. setEnabledRotationAxis(axis: string): void;
  42690. /**
  42691. * Enables/disables scaling
  42692. * @param enable if scaling should be enabled
  42693. */
  42694. setEnabledScaling(enable: boolean): void;
  42695. private _updateDummy;
  42696. /**
  42697. * Enables a pointer drag behavior on the bounding box of the gizmo
  42698. */
  42699. enableDragBehavior(): void;
  42700. /**
  42701. * Disposes of the gizmo
  42702. */
  42703. dispose(): void;
  42704. /**
  42705. * 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)
  42706. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42707. * @returns the bounding box mesh with the passed in mesh as a child
  42708. */
  42709. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42710. /**
  42711. * CustomMeshes are not supported by this gizmo
  42712. * @param mesh The mesh to replace the default mesh of the gizmo
  42713. */
  42714. setCustomMesh(mesh: Mesh): void;
  42715. }
  42716. }
  42717. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42718. import { Observable } from "babylonjs/Misc/observable";
  42719. import { Nullable } from "babylonjs/types";
  42720. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42722. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42723. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42724. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42725. import "babylonjs/Meshes/Builders/linesBuilder";
  42726. /**
  42727. * Single plane rotation gizmo
  42728. */
  42729. export class PlaneRotationGizmo extends Gizmo {
  42730. /**
  42731. * Drag behavior responsible for the gizmos dragging interactions
  42732. */
  42733. dragBehavior: PointerDragBehavior;
  42734. private _pointerObserver;
  42735. /**
  42736. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42737. */
  42738. snapDistance: number;
  42739. /**
  42740. * Event that fires each time the gizmo snaps to a new location.
  42741. * * snapDistance is the the change in distance
  42742. */
  42743. onSnapObservable: Observable<{
  42744. snapDistance: number;
  42745. }>;
  42746. /**
  42747. * Creates a PlaneRotationGizmo
  42748. * @param gizmoLayer The utility layer the gizmo will be added to
  42749. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42750. * @param color The color of the gizmo
  42751. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42752. */
  42753. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42755. /**
  42756. * Disposes of the gizmo
  42757. */
  42758. dispose(): void;
  42759. }
  42760. }
  42761. declare module "babylonjs/Gizmos/rotationGizmo" {
  42762. import { Observable } from "babylonjs/Misc/observable";
  42763. import { Nullable } from "babylonjs/types";
  42764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42765. import { Mesh } from "babylonjs/Meshes/mesh";
  42766. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42767. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42769. /**
  42770. * Gizmo that enables rotating a mesh along 3 axis
  42771. */
  42772. export class RotationGizmo extends Gizmo {
  42773. /**
  42774. * Internal gizmo used for interactions on the x axis
  42775. */
  42776. xGizmo: PlaneRotationGizmo;
  42777. /**
  42778. * Internal gizmo used for interactions on the y axis
  42779. */
  42780. yGizmo: PlaneRotationGizmo;
  42781. /**
  42782. * Internal gizmo used for interactions on the z axis
  42783. */
  42784. zGizmo: PlaneRotationGizmo;
  42785. /** Fires an event when any of it's sub gizmos are dragged */
  42786. onDragStartObservable: Observable<{}>;
  42787. /** Fires an event when any of it's sub gizmos are released from dragging */
  42788. onDragEndObservable: Observable<{}>;
  42789. attachedMesh: Nullable<AbstractMesh>;
  42790. /**
  42791. * Creates a RotationGizmo
  42792. * @param gizmoLayer The utility layer the gizmo will be added to
  42793. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42794. */
  42795. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42796. updateGizmoRotationToMatchAttachedMesh: boolean;
  42797. /**
  42798. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42799. */
  42800. snapDistance: number;
  42801. /**
  42802. * Ratio for the scale of the gizmo (Default: 1)
  42803. */
  42804. scaleRatio: number;
  42805. /**
  42806. * Disposes of the gizmo
  42807. */
  42808. dispose(): void;
  42809. /**
  42810. * CustomMeshes are not supported by this gizmo
  42811. * @param mesh The mesh to replace the default mesh of the gizmo
  42812. */
  42813. setCustomMesh(mesh: Mesh): void;
  42814. }
  42815. }
  42816. declare module "babylonjs/Gizmos/positionGizmo" {
  42817. import { Observable } from "babylonjs/Misc/observable";
  42818. import { Nullable } from "babylonjs/types";
  42819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42820. import { Mesh } from "babylonjs/Meshes/mesh";
  42821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42822. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42823. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42824. /**
  42825. * Gizmo that enables dragging a mesh along 3 axis
  42826. */
  42827. export class PositionGizmo extends Gizmo {
  42828. /**
  42829. * Internal gizmo used for interactions on the x axis
  42830. */
  42831. xGizmo: AxisDragGizmo;
  42832. /**
  42833. * Internal gizmo used for interactions on the y axis
  42834. */
  42835. yGizmo: AxisDragGizmo;
  42836. /**
  42837. * Internal gizmo used for interactions on the z axis
  42838. */
  42839. zGizmo: AxisDragGizmo;
  42840. /** Fires an event when any of it's sub gizmos are dragged */
  42841. onDragStartObservable: Observable<{}>;
  42842. /** Fires an event when any of it's sub gizmos are released from dragging */
  42843. onDragEndObservable: Observable<{}>;
  42844. attachedMesh: Nullable<AbstractMesh>;
  42845. /**
  42846. * Creates a PositionGizmo
  42847. * @param gizmoLayer The utility layer the gizmo will be added to
  42848. */
  42849. constructor(gizmoLayer?: UtilityLayerRenderer);
  42850. updateGizmoRotationToMatchAttachedMesh: boolean;
  42851. /**
  42852. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42853. */
  42854. snapDistance: number;
  42855. /**
  42856. * Ratio for the scale of the gizmo (Default: 1)
  42857. */
  42858. scaleRatio: number;
  42859. /**
  42860. * Disposes of the gizmo
  42861. */
  42862. dispose(): void;
  42863. /**
  42864. * CustomMeshes are not supported by this gizmo
  42865. * @param mesh The mesh to replace the default mesh of the gizmo
  42866. */
  42867. setCustomMesh(mesh: Mesh): void;
  42868. }
  42869. }
  42870. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42871. import { Scene } from "babylonjs/scene";
  42872. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42873. import { Mesh } from "babylonjs/Meshes/mesh";
  42874. /**
  42875. * Class containing static functions to help procedurally build meshes
  42876. */
  42877. export class PolyhedronBuilder {
  42878. /**
  42879. * Creates a polyhedron mesh
  42880. * * 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
  42881. * * The parameter `size` (positive float, default 1) sets the polygon size
  42882. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42883. * * 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`
  42884. * * 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
  42885. * * 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)`)
  42886. * * 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
  42887. * * 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
  42888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42891. * @param name defines the name of the mesh
  42892. * @param options defines the options used to create the mesh
  42893. * @param scene defines the hosting scene
  42894. * @returns the polyhedron mesh
  42895. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42896. */
  42897. static CreatePolyhedron(name: string, options: {
  42898. type?: number;
  42899. size?: number;
  42900. sizeX?: number;
  42901. sizeY?: number;
  42902. sizeZ?: number;
  42903. custom?: any;
  42904. faceUV?: Vector4[];
  42905. faceColors?: Color4[];
  42906. flat?: boolean;
  42907. updatable?: boolean;
  42908. sideOrientation?: number;
  42909. frontUVs?: Vector4;
  42910. backUVs?: Vector4;
  42911. }, scene: Scene): Mesh;
  42912. }
  42913. }
  42914. declare module "babylonjs/Gizmos/scaleGizmo" {
  42915. import { Observable } from "babylonjs/Misc/observable";
  42916. import { Nullable } from "babylonjs/types";
  42917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42918. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42919. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42920. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42921. /**
  42922. * Gizmo that enables scaling a mesh along 3 axis
  42923. */
  42924. export class ScaleGizmo extends Gizmo {
  42925. /**
  42926. * Internal gizmo used for interactions on the x axis
  42927. */
  42928. xGizmo: AxisScaleGizmo;
  42929. /**
  42930. * Internal gizmo used for interactions on the y axis
  42931. */
  42932. yGizmo: AxisScaleGizmo;
  42933. /**
  42934. * Internal gizmo used for interactions on the z axis
  42935. */
  42936. zGizmo: AxisScaleGizmo;
  42937. /**
  42938. * Internal gizmo used to scale all axis equally
  42939. */
  42940. uniformScaleGizmo: AxisScaleGizmo;
  42941. /** Fires an event when any of it's sub gizmos are dragged */
  42942. onDragStartObservable: Observable<{}>;
  42943. /** Fires an event when any of it's sub gizmos are released from dragging */
  42944. onDragEndObservable: Observable<{}>;
  42945. attachedMesh: Nullable<AbstractMesh>;
  42946. /**
  42947. * Creates a ScaleGizmo
  42948. * @param gizmoLayer The utility layer the gizmo will be added to
  42949. */
  42950. constructor(gizmoLayer?: UtilityLayerRenderer);
  42951. updateGizmoRotationToMatchAttachedMesh: boolean;
  42952. /**
  42953. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42954. */
  42955. snapDistance: number;
  42956. /**
  42957. * Ratio for the scale of the gizmo (Default: 1)
  42958. */
  42959. scaleRatio: number;
  42960. /**
  42961. * Disposes of the gizmo
  42962. */
  42963. dispose(): void;
  42964. }
  42965. }
  42966. declare module "babylonjs/Gizmos/gizmoManager" {
  42967. import { Observable } from "babylonjs/Misc/observable";
  42968. import { Nullable } from "babylonjs/types";
  42969. import { Scene, IDisposable } from "babylonjs/scene";
  42970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42971. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42972. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42973. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42974. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42975. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42976. /**
  42977. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42978. */
  42979. export class GizmoManager implements IDisposable {
  42980. private scene;
  42981. /**
  42982. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42983. */
  42984. gizmos: {
  42985. positionGizmo: Nullable<PositionGizmo>;
  42986. rotationGizmo: Nullable<RotationGizmo>;
  42987. scaleGizmo: Nullable<ScaleGizmo>;
  42988. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42989. };
  42990. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42991. clearGizmoOnEmptyPointerEvent: boolean;
  42992. /** Fires an event when the manager is attached to a mesh */
  42993. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42994. private _gizmosEnabled;
  42995. private _pointerObserver;
  42996. private _attachedMesh;
  42997. private _boundingBoxColor;
  42998. private _defaultUtilityLayer;
  42999. private _defaultKeepDepthUtilityLayer;
  43000. /**
  43001. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43002. */
  43003. boundingBoxDragBehavior: SixDofDragBehavior;
  43004. /**
  43005. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43006. */
  43007. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43008. /**
  43009. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43010. */
  43011. usePointerToAttachGizmos: boolean;
  43012. /**
  43013. * Instatiates a gizmo manager
  43014. * @param scene the scene to overlay the gizmos on top of
  43015. */
  43016. constructor(scene: Scene);
  43017. /**
  43018. * Attaches a set of gizmos to the specified mesh
  43019. * @param mesh The mesh the gizmo's should be attached to
  43020. */
  43021. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43022. /**
  43023. * If the position gizmo is enabled
  43024. */
  43025. positionGizmoEnabled: boolean;
  43026. /**
  43027. * If the rotation gizmo is enabled
  43028. */
  43029. rotationGizmoEnabled: boolean;
  43030. /**
  43031. * If the scale gizmo is enabled
  43032. */
  43033. scaleGizmoEnabled: boolean;
  43034. /**
  43035. * If the boundingBox gizmo is enabled
  43036. */
  43037. boundingBoxGizmoEnabled: boolean;
  43038. /**
  43039. * Disposes of the gizmo manager
  43040. */
  43041. dispose(): void;
  43042. }
  43043. }
  43044. declare module "babylonjs/Gizmos/lightGizmo" {
  43045. import { Nullable } from "babylonjs/types";
  43046. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43048. import { Light } from "babylonjs/Lights/light";
  43049. /**
  43050. * Gizmo that enables viewing a light
  43051. */
  43052. export class LightGizmo extends Gizmo {
  43053. private _box;
  43054. /**
  43055. * Creates a LightGizmo
  43056. * @param gizmoLayer The utility layer the gizmo will be added to
  43057. */
  43058. constructor(gizmoLayer?: UtilityLayerRenderer);
  43059. private _light;
  43060. /**
  43061. * The light that the gizmo is attached to
  43062. */
  43063. light: Nullable<Light>;
  43064. /**
  43065. * @hidden
  43066. * Updates the gizmo to match the attached mesh's position/rotation
  43067. */
  43068. protected _update(): void;
  43069. }
  43070. }
  43071. declare module "babylonjs/Gizmos/index" {
  43072. export * from "babylonjs/Gizmos/axisDragGizmo";
  43073. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43074. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43075. export * from "babylonjs/Gizmos/gizmo";
  43076. export * from "babylonjs/Gizmos/gizmoManager";
  43077. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43078. export * from "babylonjs/Gizmos/positionGizmo";
  43079. export * from "babylonjs/Gizmos/rotationGizmo";
  43080. export * from "babylonjs/Gizmos/scaleGizmo";
  43081. export * from "babylonjs/Gizmos/lightGizmo";
  43082. }
  43083. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43084. /** @hidden */
  43085. export var backgroundFragmentDeclaration: {
  43086. name: string;
  43087. shader: string;
  43088. };
  43089. }
  43090. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43091. /** @hidden */
  43092. export var backgroundUboDeclaration: {
  43093. name: string;
  43094. shader: string;
  43095. };
  43096. }
  43097. declare module "babylonjs/Shaders/background.fragment" {
  43098. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43099. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43100. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43101. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43102. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43103. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43105. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43106. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43107. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43108. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43109. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43110. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43111. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43112. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43113. /** @hidden */
  43114. export var backgroundPixelShader: {
  43115. name: string;
  43116. shader: string;
  43117. };
  43118. }
  43119. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43120. /** @hidden */
  43121. export var backgroundVertexDeclaration: {
  43122. name: string;
  43123. shader: string;
  43124. };
  43125. }
  43126. declare module "babylonjs/Shaders/background.vertex" {
  43127. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43128. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43130. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43131. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43132. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43133. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43134. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43135. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43136. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43137. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43138. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43139. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43140. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43141. /** @hidden */
  43142. export var backgroundVertexShader: {
  43143. name: string;
  43144. shader: string;
  43145. };
  43146. }
  43147. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43148. import { Nullable, int, float } from "babylonjs/types";
  43149. import { Scene } from "babylonjs/scene";
  43150. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43153. import { Mesh } from "babylonjs/Meshes/mesh";
  43154. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43155. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43156. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43158. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43159. import "babylonjs/Shaders/background.fragment";
  43160. import "babylonjs/Shaders/background.vertex";
  43161. /**
  43162. * Background material used to create an efficient environement around your scene.
  43163. */
  43164. export class BackgroundMaterial extends PushMaterial {
  43165. /**
  43166. * Standard reflectance value at parallel view angle.
  43167. */
  43168. static StandardReflectance0: number;
  43169. /**
  43170. * Standard reflectance value at grazing angle.
  43171. */
  43172. static StandardReflectance90: number;
  43173. protected _primaryColor: Color3;
  43174. /**
  43175. * Key light Color (multiply against the environement texture)
  43176. */
  43177. primaryColor: Color3;
  43178. protected __perceptualColor: Nullable<Color3>;
  43179. /**
  43180. * Experimental Internal Use Only.
  43181. *
  43182. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43183. * This acts as a helper to set the primary color to a more "human friendly" value.
  43184. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43185. * output color as close as possible from the chosen value.
  43186. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43187. * part of lighting setup.)
  43188. */
  43189. _perceptualColor: Nullable<Color3>;
  43190. protected _primaryColorShadowLevel: float;
  43191. /**
  43192. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43193. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43194. */
  43195. primaryColorShadowLevel: float;
  43196. protected _primaryColorHighlightLevel: float;
  43197. /**
  43198. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43199. * The primary color is used at the level chosen to define what the white area would look.
  43200. */
  43201. primaryColorHighlightLevel: float;
  43202. protected _reflectionTexture: Nullable<BaseTexture>;
  43203. /**
  43204. * Reflection Texture used in the material.
  43205. * Should be author in a specific way for the best result (refer to the documentation).
  43206. */
  43207. reflectionTexture: Nullable<BaseTexture>;
  43208. protected _reflectionBlur: float;
  43209. /**
  43210. * Reflection Texture level of blur.
  43211. *
  43212. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43213. * texture twice.
  43214. */
  43215. reflectionBlur: float;
  43216. protected _diffuseTexture: Nullable<BaseTexture>;
  43217. /**
  43218. * Diffuse Texture used in the material.
  43219. * Should be author in a specific way for the best result (refer to the documentation).
  43220. */
  43221. diffuseTexture: Nullable<BaseTexture>;
  43222. protected _shadowLights: Nullable<IShadowLight[]>;
  43223. /**
  43224. * Specify the list of lights casting shadow on the material.
  43225. * All scene shadow lights will be included if null.
  43226. */
  43227. shadowLights: Nullable<IShadowLight[]>;
  43228. protected _shadowLevel: float;
  43229. /**
  43230. * Helps adjusting the shadow to a softer level if required.
  43231. * 0 means black shadows and 1 means no shadows.
  43232. */
  43233. shadowLevel: float;
  43234. protected _sceneCenter: Vector3;
  43235. /**
  43236. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43237. * It is usually zero but might be interesting to modify according to your setup.
  43238. */
  43239. sceneCenter: Vector3;
  43240. protected _opacityFresnel: boolean;
  43241. /**
  43242. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43243. * This helps ensuring a nice transition when the camera goes under the ground.
  43244. */
  43245. opacityFresnel: boolean;
  43246. protected _reflectionFresnel: boolean;
  43247. /**
  43248. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43249. * This helps adding a mirror texture on the ground.
  43250. */
  43251. reflectionFresnel: boolean;
  43252. protected _reflectionFalloffDistance: number;
  43253. /**
  43254. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43255. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43256. */
  43257. reflectionFalloffDistance: number;
  43258. protected _reflectionAmount: number;
  43259. /**
  43260. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43261. */
  43262. reflectionAmount: number;
  43263. protected _reflectionReflectance0: number;
  43264. /**
  43265. * This specifies the weight of the reflection at grazing angle.
  43266. */
  43267. reflectionReflectance0: number;
  43268. protected _reflectionReflectance90: number;
  43269. /**
  43270. * This specifies the weight of the reflection at a perpendicular point of view.
  43271. */
  43272. reflectionReflectance90: number;
  43273. /**
  43274. * Sets the reflection reflectance fresnel values according to the default standard
  43275. * empirically know to work well :-)
  43276. */
  43277. reflectionStandardFresnelWeight: number;
  43278. protected _useRGBColor: boolean;
  43279. /**
  43280. * Helps to directly use the maps channels instead of their level.
  43281. */
  43282. useRGBColor: boolean;
  43283. protected _enableNoise: boolean;
  43284. /**
  43285. * This helps reducing the banding effect that could occur on the background.
  43286. */
  43287. enableNoise: boolean;
  43288. /**
  43289. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43290. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43291. * Recommended to be keep at 1.0 except for special cases.
  43292. */
  43293. fovMultiplier: number;
  43294. private _fovMultiplier;
  43295. /**
  43296. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43297. */
  43298. useEquirectangularFOV: boolean;
  43299. private _maxSimultaneousLights;
  43300. /**
  43301. * Number of Simultaneous lights allowed on the material.
  43302. */
  43303. maxSimultaneousLights: int;
  43304. /**
  43305. * Default configuration related to image processing available in the Background Material.
  43306. */
  43307. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43308. /**
  43309. * Keep track of the image processing observer to allow dispose and replace.
  43310. */
  43311. private _imageProcessingObserver;
  43312. /**
  43313. * Attaches a new image processing configuration to the PBR Material.
  43314. * @param configuration (if null the scene configuration will be use)
  43315. */
  43316. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43317. /**
  43318. * Gets the image processing configuration used either in this material.
  43319. */
  43320. /**
  43321. * Sets the Default image processing configuration used either in the this material.
  43322. *
  43323. * If sets to null, the scene one is in use.
  43324. */
  43325. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43326. /**
  43327. * Gets wether the color curves effect is enabled.
  43328. */
  43329. /**
  43330. * Sets wether the color curves effect is enabled.
  43331. */
  43332. cameraColorCurvesEnabled: boolean;
  43333. /**
  43334. * Gets wether the color grading effect is enabled.
  43335. */
  43336. /**
  43337. * Gets wether the color grading effect is enabled.
  43338. */
  43339. cameraColorGradingEnabled: boolean;
  43340. /**
  43341. * Gets wether tonemapping is enabled or not.
  43342. */
  43343. /**
  43344. * Sets wether tonemapping is enabled or not
  43345. */
  43346. cameraToneMappingEnabled: boolean;
  43347. /**
  43348. * The camera exposure used on this material.
  43349. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43350. * This corresponds to a photographic exposure.
  43351. */
  43352. /**
  43353. * The camera exposure used on this material.
  43354. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43355. * This corresponds to a photographic exposure.
  43356. */
  43357. cameraExposure: float;
  43358. /**
  43359. * Gets The camera contrast used on this material.
  43360. */
  43361. /**
  43362. * Sets The camera contrast used on this material.
  43363. */
  43364. cameraContrast: float;
  43365. /**
  43366. * Gets the Color Grading 2D Lookup Texture.
  43367. */
  43368. /**
  43369. * Sets the Color Grading 2D Lookup Texture.
  43370. */
  43371. cameraColorGradingTexture: Nullable<BaseTexture>;
  43372. /**
  43373. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43374. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43375. * 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;
  43376. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43377. */
  43378. /**
  43379. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43380. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43381. * 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;
  43382. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43383. */
  43384. cameraColorCurves: Nullable<ColorCurves>;
  43385. /**
  43386. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43387. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43388. */
  43389. switchToBGR: boolean;
  43390. private _renderTargets;
  43391. private _reflectionControls;
  43392. private _white;
  43393. private _primaryShadowColor;
  43394. private _primaryHighlightColor;
  43395. /**
  43396. * Instantiates a Background Material in the given scene
  43397. * @param name The friendly name of the material
  43398. * @param scene The scene to add the material to
  43399. */
  43400. constructor(name: string, scene: Scene);
  43401. /**
  43402. * Gets a boolean indicating that current material needs to register RTT
  43403. */
  43404. readonly hasRenderTargetTextures: boolean;
  43405. /**
  43406. * The entire material has been created in order to prevent overdraw.
  43407. * @returns false
  43408. */
  43409. needAlphaTesting(): boolean;
  43410. /**
  43411. * The entire material has been created in order to prevent overdraw.
  43412. * @returns true if blending is enable
  43413. */
  43414. needAlphaBlending(): boolean;
  43415. /**
  43416. * Checks wether the material is ready to be rendered for a given mesh.
  43417. * @param mesh The mesh to render
  43418. * @param subMesh The submesh to check against
  43419. * @param useInstances Specify wether or not the material is used with instances
  43420. * @returns true if all the dependencies are ready (Textures, Effects...)
  43421. */
  43422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43423. /**
  43424. * Compute the primary color according to the chosen perceptual color.
  43425. */
  43426. private _computePrimaryColorFromPerceptualColor;
  43427. /**
  43428. * Compute the highlights and shadow colors according to their chosen levels.
  43429. */
  43430. private _computePrimaryColors;
  43431. /**
  43432. * Build the uniform buffer used in the material.
  43433. */
  43434. buildUniformLayout(): void;
  43435. /**
  43436. * Unbind the material.
  43437. */
  43438. unbind(): void;
  43439. /**
  43440. * Bind only the world matrix to the material.
  43441. * @param world The world matrix to bind.
  43442. */
  43443. bindOnlyWorldMatrix(world: Matrix): void;
  43444. /**
  43445. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43446. * @param world The world matrix to bind.
  43447. * @param subMesh The submesh to bind for.
  43448. */
  43449. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43450. /**
  43451. * Dispose the material.
  43452. * @param forceDisposeEffect Force disposal of the associated effect.
  43453. * @param forceDisposeTextures Force disposal of the associated textures.
  43454. */
  43455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43456. /**
  43457. * Clones the material.
  43458. * @param name The cloned name.
  43459. * @returns The cloned material.
  43460. */
  43461. clone(name: string): BackgroundMaterial;
  43462. /**
  43463. * Serializes the current material to its JSON representation.
  43464. * @returns The JSON representation.
  43465. */
  43466. serialize(): any;
  43467. /**
  43468. * Gets the class name of the material
  43469. * @returns "BackgroundMaterial"
  43470. */
  43471. getClassName(): string;
  43472. /**
  43473. * Parse a JSON input to create back a background material.
  43474. * @param source The JSON data to parse
  43475. * @param scene The scene to create the parsed material in
  43476. * @param rootUrl The root url of the assets the material depends upon
  43477. * @returns the instantiated BackgroundMaterial.
  43478. */
  43479. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43480. }
  43481. }
  43482. declare module "babylonjs/Helpers/environmentHelper" {
  43483. import { Observable } from "babylonjs/Misc/observable";
  43484. import { Nullable } from "babylonjs/types";
  43485. import { Scene } from "babylonjs/scene";
  43486. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43488. import { Mesh } from "babylonjs/Meshes/mesh";
  43489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43490. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43491. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43492. import "babylonjs/Meshes/Builders/planeBuilder";
  43493. import "babylonjs/Meshes/Builders/boxBuilder";
  43494. /**
  43495. * Represents the different options available during the creation of
  43496. * a Environment helper.
  43497. *
  43498. * This can control the default ground, skybox and image processing setup of your scene.
  43499. */
  43500. export interface IEnvironmentHelperOptions {
  43501. /**
  43502. * Specifies wether or not to create a ground.
  43503. * True by default.
  43504. */
  43505. createGround: boolean;
  43506. /**
  43507. * Specifies the ground size.
  43508. * 15 by default.
  43509. */
  43510. groundSize: number;
  43511. /**
  43512. * The texture used on the ground for the main color.
  43513. * Comes from the BabylonJS CDN by default.
  43514. *
  43515. * Remarks: Can be either a texture or a url.
  43516. */
  43517. groundTexture: string | BaseTexture;
  43518. /**
  43519. * The color mixed in the ground texture by default.
  43520. * BabylonJS clearColor by default.
  43521. */
  43522. groundColor: Color3;
  43523. /**
  43524. * Specifies the ground opacity.
  43525. * 1 by default.
  43526. */
  43527. groundOpacity: number;
  43528. /**
  43529. * Enables the ground to receive shadows.
  43530. * True by default.
  43531. */
  43532. enableGroundShadow: boolean;
  43533. /**
  43534. * Helps preventing the shadow to be fully black on the ground.
  43535. * 0.5 by default.
  43536. */
  43537. groundShadowLevel: number;
  43538. /**
  43539. * Creates a mirror texture attach to the ground.
  43540. * false by default.
  43541. */
  43542. enableGroundMirror: boolean;
  43543. /**
  43544. * Specifies the ground mirror size ratio.
  43545. * 0.3 by default as the default kernel is 64.
  43546. */
  43547. groundMirrorSizeRatio: number;
  43548. /**
  43549. * Specifies the ground mirror blur kernel size.
  43550. * 64 by default.
  43551. */
  43552. groundMirrorBlurKernel: number;
  43553. /**
  43554. * Specifies the ground mirror visibility amount.
  43555. * 1 by default
  43556. */
  43557. groundMirrorAmount: number;
  43558. /**
  43559. * Specifies the ground mirror reflectance weight.
  43560. * This uses the standard weight of the background material to setup the fresnel effect
  43561. * of the mirror.
  43562. * 1 by default.
  43563. */
  43564. groundMirrorFresnelWeight: number;
  43565. /**
  43566. * Specifies the ground mirror Falloff distance.
  43567. * This can helps reducing the size of the reflection.
  43568. * 0 by Default.
  43569. */
  43570. groundMirrorFallOffDistance: number;
  43571. /**
  43572. * Specifies the ground mirror texture type.
  43573. * Unsigned Int by Default.
  43574. */
  43575. groundMirrorTextureType: number;
  43576. /**
  43577. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43578. * the shown objects.
  43579. */
  43580. groundYBias: number;
  43581. /**
  43582. * Specifies wether or not to create a skybox.
  43583. * True by default.
  43584. */
  43585. createSkybox: boolean;
  43586. /**
  43587. * Specifies the skybox size.
  43588. * 20 by default.
  43589. */
  43590. skyboxSize: number;
  43591. /**
  43592. * The texture used on the skybox for the main color.
  43593. * Comes from the BabylonJS CDN by default.
  43594. *
  43595. * Remarks: Can be either a texture or a url.
  43596. */
  43597. skyboxTexture: string | BaseTexture;
  43598. /**
  43599. * The color mixed in the skybox texture by default.
  43600. * BabylonJS clearColor by default.
  43601. */
  43602. skyboxColor: Color3;
  43603. /**
  43604. * The background rotation around the Y axis of the scene.
  43605. * This helps aligning the key lights of your scene with the background.
  43606. * 0 by default.
  43607. */
  43608. backgroundYRotation: number;
  43609. /**
  43610. * Compute automatically the size of the elements to best fit with the scene.
  43611. */
  43612. sizeAuto: boolean;
  43613. /**
  43614. * Default position of the rootMesh if autoSize is not true.
  43615. */
  43616. rootPosition: Vector3;
  43617. /**
  43618. * Sets up the image processing in the scene.
  43619. * true by default.
  43620. */
  43621. setupImageProcessing: boolean;
  43622. /**
  43623. * The texture used as your environment texture in the scene.
  43624. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43625. *
  43626. * Remarks: Can be either a texture or a url.
  43627. */
  43628. environmentTexture: string | BaseTexture;
  43629. /**
  43630. * The value of the exposure to apply to the scene.
  43631. * 0.6 by default if setupImageProcessing is true.
  43632. */
  43633. cameraExposure: number;
  43634. /**
  43635. * The value of the contrast to apply to the scene.
  43636. * 1.6 by default if setupImageProcessing is true.
  43637. */
  43638. cameraContrast: number;
  43639. /**
  43640. * Specifies wether or not tonemapping should be enabled in the scene.
  43641. * true by default if setupImageProcessing is true.
  43642. */
  43643. toneMappingEnabled: boolean;
  43644. }
  43645. /**
  43646. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43647. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43648. * It also helps with the default setup of your imageProcessing configuration.
  43649. */
  43650. export class EnvironmentHelper {
  43651. /**
  43652. * Default ground texture URL.
  43653. */
  43654. private static _groundTextureCDNUrl;
  43655. /**
  43656. * Default skybox texture URL.
  43657. */
  43658. private static _skyboxTextureCDNUrl;
  43659. /**
  43660. * Default environment texture URL.
  43661. */
  43662. private static _environmentTextureCDNUrl;
  43663. /**
  43664. * Creates the default options for the helper.
  43665. */
  43666. private static _getDefaultOptions;
  43667. private _rootMesh;
  43668. /**
  43669. * Gets the root mesh created by the helper.
  43670. */
  43671. readonly rootMesh: Mesh;
  43672. private _skybox;
  43673. /**
  43674. * Gets the skybox created by the helper.
  43675. */
  43676. readonly skybox: Nullable<Mesh>;
  43677. private _skyboxTexture;
  43678. /**
  43679. * Gets the skybox texture created by the helper.
  43680. */
  43681. readonly skyboxTexture: Nullable<BaseTexture>;
  43682. private _skyboxMaterial;
  43683. /**
  43684. * Gets the skybox material created by the helper.
  43685. */
  43686. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43687. private _ground;
  43688. /**
  43689. * Gets the ground mesh created by the helper.
  43690. */
  43691. readonly ground: Nullable<Mesh>;
  43692. private _groundTexture;
  43693. /**
  43694. * Gets the ground texture created by the helper.
  43695. */
  43696. readonly groundTexture: Nullable<BaseTexture>;
  43697. private _groundMirror;
  43698. /**
  43699. * Gets the ground mirror created by the helper.
  43700. */
  43701. readonly groundMirror: Nullable<MirrorTexture>;
  43702. /**
  43703. * Gets the ground mirror render list to helps pushing the meshes
  43704. * you wish in the ground reflection.
  43705. */
  43706. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43707. private _groundMaterial;
  43708. /**
  43709. * Gets the ground material created by the helper.
  43710. */
  43711. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43712. /**
  43713. * Stores the creation options.
  43714. */
  43715. private readonly _scene;
  43716. private _options;
  43717. /**
  43718. * This observable will be notified with any error during the creation of the environment,
  43719. * mainly texture creation errors.
  43720. */
  43721. onErrorObservable: Observable<{
  43722. message?: string;
  43723. exception?: any;
  43724. }>;
  43725. /**
  43726. * constructor
  43727. * @param options Defines the options we want to customize the helper
  43728. * @param scene The scene to add the material to
  43729. */
  43730. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43731. /**
  43732. * Updates the background according to the new options
  43733. * @param options
  43734. */
  43735. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43736. /**
  43737. * Sets the primary color of all the available elements.
  43738. * @param color the main color to affect to the ground and the background
  43739. */
  43740. setMainColor(color: Color3): void;
  43741. /**
  43742. * Setup the image processing according to the specified options.
  43743. */
  43744. private _setupImageProcessing;
  43745. /**
  43746. * Setup the environment texture according to the specified options.
  43747. */
  43748. private _setupEnvironmentTexture;
  43749. /**
  43750. * Setup the background according to the specified options.
  43751. */
  43752. private _setupBackground;
  43753. /**
  43754. * Get the scene sizes according to the setup.
  43755. */
  43756. private _getSceneSize;
  43757. /**
  43758. * Setup the ground according to the specified options.
  43759. */
  43760. private _setupGround;
  43761. /**
  43762. * Setup the ground material according to the specified options.
  43763. */
  43764. private _setupGroundMaterial;
  43765. /**
  43766. * Setup the ground diffuse texture according to the specified options.
  43767. */
  43768. private _setupGroundDiffuseTexture;
  43769. /**
  43770. * Setup the ground mirror texture according to the specified options.
  43771. */
  43772. private _setupGroundMirrorTexture;
  43773. /**
  43774. * Setup the ground to receive the mirror texture.
  43775. */
  43776. private _setupMirrorInGroundMaterial;
  43777. /**
  43778. * Setup the skybox according to the specified options.
  43779. */
  43780. private _setupSkybox;
  43781. /**
  43782. * Setup the skybox material according to the specified options.
  43783. */
  43784. private _setupSkyboxMaterial;
  43785. /**
  43786. * Setup the skybox reflection texture according to the specified options.
  43787. */
  43788. private _setupSkyboxReflectionTexture;
  43789. private _errorHandler;
  43790. /**
  43791. * Dispose all the elements created by the Helper.
  43792. */
  43793. dispose(): void;
  43794. }
  43795. }
  43796. declare module "babylonjs/Helpers/photoDome" {
  43797. import { Observable } from "babylonjs/Misc/observable";
  43798. import { Nullable } from "babylonjs/types";
  43799. import { Scene } from "babylonjs/scene";
  43800. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43801. import { Mesh } from "babylonjs/Meshes/mesh";
  43802. import { Texture } from "babylonjs/Materials/Textures/texture";
  43803. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43804. import "babylonjs/Meshes/Builders/sphereBuilder";
  43805. /**
  43806. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43807. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43808. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43809. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43810. */
  43811. export class PhotoDome extends TransformNode {
  43812. private _useDirectMapping;
  43813. /**
  43814. * The texture being displayed on the sphere
  43815. */
  43816. protected _photoTexture: Texture;
  43817. /**
  43818. * Gets or sets the texture being displayed on the sphere
  43819. */
  43820. photoTexture: Texture;
  43821. /**
  43822. * Observable raised when an error occured while loading the 360 image
  43823. */
  43824. onLoadErrorObservable: Observable<string>;
  43825. /**
  43826. * The skybox material
  43827. */
  43828. protected _material: BackgroundMaterial;
  43829. /**
  43830. * The surface used for the skybox
  43831. */
  43832. protected _mesh: Mesh;
  43833. /**
  43834. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43835. * Also see the options.resolution property.
  43836. */
  43837. fovMultiplier: number;
  43838. /**
  43839. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43840. * @param name Element's name, child elements will append suffixes for their own names.
  43841. * @param urlsOfPhoto defines the url of the photo to display
  43842. * @param options defines an object containing optional or exposed sub element properties
  43843. * @param onError defines a callback called when an error occured while loading the texture
  43844. */
  43845. constructor(name: string, urlOfPhoto: string, options: {
  43846. resolution?: number;
  43847. size?: number;
  43848. useDirectMapping?: boolean;
  43849. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43850. /**
  43851. * Releases resources associated with this node.
  43852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43854. */
  43855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Misc/textureTools" {
  43859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43860. import { Texture } from "babylonjs/Materials/Textures/texture";
  43861. import { Scene } from "babylonjs/scene";
  43862. /**
  43863. * Class used to host texture specific utilities
  43864. */
  43865. export class TextureTools {
  43866. /**
  43867. * Uses the GPU to create a copy texture rescaled at a given size
  43868. * @param texture Texture to copy from
  43869. * @param width defines the desired width
  43870. * @param height defines the desired height
  43871. * @param useBilinearMode defines if bilinear mode has to be used
  43872. * @return the generated texture
  43873. */
  43874. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43875. /**
  43876. * Gets an environment BRDF texture for a given scene
  43877. * @param scene defines the hosting scene
  43878. * @returns the environment BRDF texture
  43879. */
  43880. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43881. private static _environmentBRDFBase64Texture;
  43882. }
  43883. }
  43884. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  43885. import { Nullable } from "babylonjs/types";
  43886. import { IAnimatable } from "babylonjs/Misc/tools";
  43887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43888. import { EffectFallbacks } from "babylonjs/Materials/effect";
  43889. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43890. import { Engine } from "babylonjs/Engines/engine";
  43891. import { Scene } from "babylonjs/scene";
  43892. /**
  43893. * @hidden
  43894. */
  43895. export interface IMaterialClearCoatDefines {
  43896. CLEARCOAT: boolean;
  43897. CLEARCOAT_TEXTURE: boolean;
  43898. CLEARCOAT_TEXTUREDIRECTUV: number;
  43899. CLEARCOAT_BUMP: boolean;
  43900. CLEARCOAT_BUMPDIRECTUV: number;
  43901. /** @hidden */
  43902. _areTexturesDirty: boolean;
  43903. }
  43904. /**
  43905. * Define the code related to the clear coat parameters of the pbr material.
  43906. */
  43907. export class PBRClearCoatConfiguration {
  43908. private _isEnabled;
  43909. /**
  43910. * Defines if the clear coat is enabled in the material.
  43911. */
  43912. isEnabled: boolean;
  43913. /**
  43914. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43915. */
  43916. intensity: number;
  43917. /**
  43918. * Defines the clear coat layer roughness.
  43919. */
  43920. roughness: number;
  43921. private _texture;
  43922. /**
  43923. * Stores the clear coat values in a texture.
  43924. */
  43925. texture: Nullable<BaseTexture>;
  43926. private _bumpTexture;
  43927. /**
  43928. * Define the clear coat specific bump texture.
  43929. */
  43930. bumpTexture: Nullable<BaseTexture>;
  43931. /** @hidden */
  43932. private _internalMarkAllSubMeshesAsTexturesDirty;
  43933. /** @hidden */
  43934. _markAllSubMeshesAsTexturesDirty(): void;
  43935. /**
  43936. * Instantiate a new istance of clear coat configuration.
  43937. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43938. */
  43939. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43940. /**
  43941. * Specifies that the submesh is ready to be used.
  43942. * @param defines the list of "defines" to update.
  43943. * @param scene defines the scene the material belongs to.
  43944. * @param engine defines the engine the material belongs to.
  43945. * @param disableBumpMap defines wether the material disables bump or not.
  43946. * @returns - boolean indicating that the submesh is ready or not.
  43947. */
  43948. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43949. /**
  43950. * Checks to see if a texture is used in the material.
  43951. * @param defines the list of "defines" to update.
  43952. * @param scene defines the scene to the material belongs to.
  43953. */
  43954. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43955. /**
  43956. * Binds the material data.
  43957. * @param uniformBuffer defines the Uniform buffer to fill in.
  43958. * @param scene defines the scene the material belongs to.
  43959. * @param engine defines the engine the material belongs to.
  43960. * @param disableBumpMap defines wether the material disables bump or not.
  43961. * @param isFrozen defines wether the material is frozen or not.
  43962. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43963. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43964. */
  43965. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43966. /**
  43967. * Checks to see if a texture is used in the material.
  43968. * @param texture - Base texture to use.
  43969. * @returns - Boolean specifying if a texture is used in the material.
  43970. */
  43971. hasTexture(texture: BaseTexture): boolean;
  43972. /**
  43973. * Returns an array of the actively used textures.
  43974. * @param activeTextures Array of BaseTextures
  43975. */
  43976. getActiveTextures(activeTextures: BaseTexture[]): void;
  43977. /**
  43978. * Returns the animatable textures.
  43979. * @param animatables Array of animatable textures.
  43980. */
  43981. getAnimatables(animatables: IAnimatable[]): void;
  43982. /**
  43983. * Disposes the resources of the material.
  43984. * @param forceDisposeTextures - Forces the disposal of all textures.
  43985. */
  43986. dispose(forceDisposeTextures?: boolean): void;
  43987. /**
  43988. * Get the current class name of the texture useful for serialization or dynamic coding.
  43989. * @returns "PBRClearCoatConfiguration"
  43990. */
  43991. getClassName(): string;
  43992. /**
  43993. * Makes a duplicate of the current configuration into another one.
  43994. * @param clearCoatConfiguration define the config where to copy the info
  43995. */
  43996. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43997. /**
  43998. * Serializes this clear coat configuration.
  43999. * @returns - An object with the serialized config.
  44000. */
  44001. serialize(): any;
  44002. /**
  44003. * Parses a Clear Coat Configuration from a serialized object.
  44004. * @param source - Serialized object.
  44005. */
  44006. parse(source: any): void;
  44007. /**
  44008. * Add fallbacks to the effect fallbacks list.
  44009. * @param defines defines the Base texture to use.
  44010. * @param fallbacks defines the current fallback list.
  44011. * @param currentRank defines the current fallback rank.
  44012. * @returns the new fallback rank.
  44013. */
  44014. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44015. /**
  44016. * Add the required uniforms to the current list.
  44017. * @param uniforms defines the current uniform list.
  44018. */
  44019. static AddUniforms(uniforms: string[]): void;
  44020. /**
  44021. * Add the required samplers to the current list.
  44022. * @param samplers defines the current sampler list.
  44023. */
  44024. static AddSamplers(samplers: string[]): void;
  44025. /**
  44026. * Add the required uniforms to the current buffer.
  44027. * @param uniformBuffer defines the current uniform buffer.
  44028. */
  44029. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44030. }
  44031. }
  44032. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44033. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44034. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44036. /**
  44037. * @hidden
  44038. */
  44039. export interface IMaterialAnisotropicDefines {
  44040. ANISOTROPIC: boolean;
  44041. MAINUV1: boolean;
  44042. _areMiscDirty: boolean;
  44043. _needUVs: boolean;
  44044. }
  44045. /**
  44046. * Define the code related to the anisotropic parameters of the pbr material.
  44047. */
  44048. export class PBRAnisotropicConfiguration {
  44049. private _isEnabled;
  44050. /**
  44051. * Defines if the anisotropy is enabled in the material.
  44052. */
  44053. isEnabled: boolean;
  44054. /**
  44055. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44056. */
  44057. intensity: number;
  44058. /**
  44059. * Defines if the effect is along the tangents or bitangents.
  44060. * By default, the effect is "strectching" the highlights along the tangents.
  44061. */
  44062. followTangents: boolean;
  44063. /** @hidden */
  44064. private _internalMarkAllSubMeshesAsMiscDirty;
  44065. /** @hidden */
  44066. _markAllSubMeshesAsMiscDirty(): void;
  44067. /**
  44068. * Instantiate a new istance of clear coat configuration.
  44069. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44070. */
  44071. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44072. /**
  44073. * Checks to see if a texture is used in the material.
  44074. * @param defines the list of "defines" to update.
  44075. * @param mesh the mesh we are preparing the defines for.
  44076. */
  44077. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44078. /**
  44079. * Binds the material data.
  44080. * @param uniformBuffer defines the Uniform buffer to fill in.
  44081. * @param isFrozen defines wether the material is frozen or not.
  44082. */
  44083. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44084. /**
  44085. * Get the current class name of the texture useful for serialization or dynamic coding.
  44086. * @returns "PBRAnisotropicConfiguration"
  44087. */
  44088. getClassName(): string;
  44089. /**
  44090. * Makes a duplicate of the current configuration into another one.
  44091. * @param anisotropicConfiguration define the config where to copy the info
  44092. */
  44093. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44094. /**
  44095. * Serializes this clear coat configuration.
  44096. * @returns - An object with the serialized config.
  44097. */
  44098. serialize(): any;
  44099. /**
  44100. * Parses a Clear Coat Configuration from a serialized object.
  44101. * @param source - Serialized object.
  44102. */
  44103. parse(source: any): void;
  44104. /**
  44105. * Add fallbacks to the effect fallbacks list.
  44106. * @param defines defines the Base texture to use.
  44107. * @param fallbacks defines the current fallback list.
  44108. * @param currentRank defines the current fallback rank.
  44109. * @returns the new fallback rank.
  44110. */
  44111. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44112. /**
  44113. * Add the required uniforms to the current list.
  44114. * @param uniforms defines the current uniform list.
  44115. */
  44116. static AddUniforms(uniforms: string[]): void;
  44117. /**
  44118. * Add the required uniforms to the current buffer.
  44119. * @param uniformBuffer defines the current uniform buffer.
  44120. */
  44121. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44122. }
  44123. }
  44124. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44125. /** @hidden */
  44126. export var pbrFragmentDeclaration: {
  44127. name: string;
  44128. shader: string;
  44129. };
  44130. }
  44131. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44132. /** @hidden */
  44133. export var pbrUboDeclaration: {
  44134. name: string;
  44135. shader: string;
  44136. };
  44137. }
  44138. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44139. /** @hidden */
  44140. export var pbrFunctions: {
  44141. name: string;
  44142. shader: string;
  44143. };
  44144. }
  44145. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44146. /** @hidden */
  44147. export var harmonicsFunctions: {
  44148. name: string;
  44149. shader: string;
  44150. };
  44151. }
  44152. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44153. /** @hidden */
  44154. export var pbrPreLightingFunctions: {
  44155. name: string;
  44156. shader: string;
  44157. };
  44158. }
  44159. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44160. /** @hidden */
  44161. export var pbrFalloffLightingFunctions: {
  44162. name: string;
  44163. shader: string;
  44164. };
  44165. }
  44166. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44167. /** @hidden */
  44168. export var pbrLightingFunctions: {
  44169. name: string;
  44170. shader: string;
  44171. };
  44172. }
  44173. declare module "babylonjs/Shaders/pbr.fragment" {
  44174. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44175. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44176. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44177. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44178. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44179. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44180. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44181. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44182. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44183. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44184. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44185. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44186. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44187. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44188. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44189. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44190. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44191. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44192. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44193. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44194. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44195. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44196. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44197. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44198. /** @hidden */
  44199. export var pbrPixelShader: {
  44200. name: string;
  44201. shader: string;
  44202. };
  44203. }
  44204. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44205. /** @hidden */
  44206. export var pbrVertexDeclaration: {
  44207. name: string;
  44208. shader: string;
  44209. };
  44210. }
  44211. declare module "babylonjs/Shaders/pbr.vertex" {
  44212. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44213. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44214. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44215. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44216. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44217. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44218. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44219. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44220. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44221. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44222. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44223. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44225. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44227. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44228. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44229. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44230. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44231. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44232. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44233. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44234. /** @hidden */
  44235. export var pbrVertexShader: {
  44236. name: string;
  44237. shader: string;
  44238. };
  44239. }
  44240. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44241. import { IAnimatable } from "babylonjs/Misc/tools";
  44242. import { Nullable } from "babylonjs/types";
  44243. import { Scene } from "babylonjs/scene";
  44244. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44247. import { Mesh } from "babylonjs/Meshes/mesh";
  44248. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44249. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44250. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44251. import { Material } from "babylonjs/Materials/material";
  44252. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44254. import "babylonjs/Shaders/pbr.fragment";
  44255. import "babylonjs/Shaders/pbr.vertex";
  44256. /**
  44257. * The Physically based material base class of BJS.
  44258. *
  44259. * This offers the main features of a standard PBR material.
  44260. * For more information, please refer to the documentation :
  44261. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44262. */
  44263. export abstract class PBRBaseMaterial extends PushMaterial {
  44264. /**
  44265. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44266. */
  44267. static readonly PBRMATERIAL_OPAQUE: number;
  44268. /**
  44269. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44270. */
  44271. static readonly PBRMATERIAL_ALPHATEST: number;
  44272. /**
  44273. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44274. */
  44275. static readonly PBRMATERIAL_ALPHABLEND: number;
  44276. /**
  44277. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44278. * They are also discarded below the alpha cutoff threshold to improve performances.
  44279. */
  44280. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44281. /**
  44282. * Defines the default value of how much AO map is occluding the analytical lights
  44283. * (point spot...).
  44284. */
  44285. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44286. /**
  44287. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44288. */
  44289. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44290. /**
  44291. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44292. * to enhance interoperability with other engines.
  44293. */
  44294. static readonly LIGHTFALLOFF_GLTF: number;
  44295. /**
  44296. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44297. * to enhance interoperability with other materials.
  44298. */
  44299. static readonly LIGHTFALLOFF_STANDARD: number;
  44300. /**
  44301. * Intensity of the direct lights e.g. the four lights available in your scene.
  44302. * This impacts both the direct diffuse and specular highlights.
  44303. */
  44304. protected _directIntensity: number;
  44305. /**
  44306. * Intensity of the emissive part of the material.
  44307. * This helps controlling the emissive effect without modifying the emissive color.
  44308. */
  44309. protected _emissiveIntensity: number;
  44310. /**
  44311. * Intensity of the environment e.g. how much the environment will light the object
  44312. * either through harmonics for rough material or through the refelction for shiny ones.
  44313. */
  44314. protected _environmentIntensity: number;
  44315. /**
  44316. * This is a special control allowing the reduction of the specular highlights coming from the
  44317. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44318. */
  44319. protected _specularIntensity: number;
  44320. /**
  44321. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44322. */
  44323. private _lightingInfos;
  44324. /**
  44325. * Debug Control allowing disabling the bump map on this material.
  44326. */
  44327. protected _disableBumpMap: boolean;
  44328. /**
  44329. * AKA Diffuse Texture in standard nomenclature.
  44330. */
  44331. protected _albedoTexture: BaseTexture;
  44332. /**
  44333. * AKA Occlusion Texture in other nomenclature.
  44334. */
  44335. protected _ambientTexture: BaseTexture;
  44336. /**
  44337. * AKA Occlusion Texture Intensity in other nomenclature.
  44338. */
  44339. protected _ambientTextureStrength: number;
  44340. /**
  44341. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44342. * 1 means it completely occludes it
  44343. * 0 mean it has no impact
  44344. */
  44345. protected _ambientTextureImpactOnAnalyticalLights: number;
  44346. /**
  44347. * Stores the alpha values in a texture.
  44348. */
  44349. protected _opacityTexture: BaseTexture;
  44350. /**
  44351. * Stores the reflection values in a texture.
  44352. */
  44353. protected _reflectionTexture: BaseTexture;
  44354. /**
  44355. * Stores the refraction values in a texture.
  44356. */
  44357. protected _refractionTexture: BaseTexture;
  44358. /**
  44359. * Stores the emissive values in a texture.
  44360. */
  44361. protected _emissiveTexture: BaseTexture;
  44362. /**
  44363. * AKA Specular texture in other nomenclature.
  44364. */
  44365. protected _reflectivityTexture: BaseTexture;
  44366. /**
  44367. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44368. */
  44369. protected _metallicTexture: BaseTexture;
  44370. /**
  44371. * Specifies the metallic scalar of the metallic/roughness workflow.
  44372. * Can also be used to scale the metalness values of the metallic texture.
  44373. */
  44374. protected _metallic: Nullable<number>;
  44375. /**
  44376. * Specifies the roughness scalar of the metallic/roughness workflow.
  44377. * Can also be used to scale the roughness values of the metallic texture.
  44378. */
  44379. protected _roughness: Nullable<number>;
  44380. /**
  44381. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44382. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44383. */
  44384. protected _microSurfaceTexture: BaseTexture;
  44385. /**
  44386. * Stores surface normal data used to displace a mesh in a texture.
  44387. */
  44388. protected _bumpTexture: BaseTexture;
  44389. /**
  44390. * Stores the pre-calculated light information of a mesh in a texture.
  44391. */
  44392. protected _lightmapTexture: BaseTexture;
  44393. /**
  44394. * The color of a material in ambient lighting.
  44395. */
  44396. protected _ambientColor: Color3;
  44397. /**
  44398. * AKA Diffuse Color in other nomenclature.
  44399. */
  44400. protected _albedoColor: Color3;
  44401. /**
  44402. * AKA Specular Color in other nomenclature.
  44403. */
  44404. protected _reflectivityColor: Color3;
  44405. /**
  44406. * The color applied when light is reflected from a material.
  44407. */
  44408. protected _reflectionColor: Color3;
  44409. /**
  44410. * The color applied when light is emitted from a material.
  44411. */
  44412. protected _emissiveColor: Color3;
  44413. /**
  44414. * AKA Glossiness in other nomenclature.
  44415. */
  44416. protected _microSurface: number;
  44417. /**
  44418. * source material index of refraction (IOR)' / 'destination material IOR.
  44419. */
  44420. protected _indexOfRefraction: number;
  44421. /**
  44422. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44423. */
  44424. protected _invertRefractionY: boolean;
  44425. /**
  44426. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44427. * Materials half opaque for instance using refraction could benefit from this control.
  44428. */
  44429. protected _linkRefractionWithTransparency: boolean;
  44430. /**
  44431. * Specifies that the material will use the light map as a show map.
  44432. */
  44433. protected _useLightmapAsShadowmap: boolean;
  44434. /**
  44435. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44436. * makes the reflect vector face the model (under horizon).
  44437. */
  44438. protected _useHorizonOcclusion: boolean;
  44439. /**
  44440. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44441. * too much the area relying on ambient texture to define their ambient occlusion.
  44442. */
  44443. protected _useRadianceOcclusion: boolean;
  44444. /**
  44445. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44446. */
  44447. protected _useAlphaFromAlbedoTexture: boolean;
  44448. /**
  44449. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44450. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44451. */
  44452. protected _useSpecularOverAlpha: boolean;
  44453. /**
  44454. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44455. */
  44456. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44457. /**
  44458. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44459. */
  44460. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44461. /**
  44462. * Specifies if the metallic texture contains the roughness information in its green channel.
  44463. */
  44464. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44465. /**
  44466. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44467. */
  44468. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44469. /**
  44470. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44471. */
  44472. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44473. /**
  44474. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44475. */
  44476. protected _useAmbientInGrayScale: boolean;
  44477. /**
  44478. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44479. * The material will try to infer what glossiness each pixel should be.
  44480. */
  44481. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44482. /**
  44483. * Defines the falloff type used in this material.
  44484. * It by default is Physical.
  44485. */
  44486. protected _lightFalloff: number;
  44487. /**
  44488. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44489. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44490. */
  44491. protected _useRadianceOverAlpha: boolean;
  44492. /**
  44493. * Allows using an object space normal map (instead of tangent space).
  44494. */
  44495. protected _useObjectSpaceNormalMap: boolean;
  44496. /**
  44497. * Allows using the bump map in parallax mode.
  44498. */
  44499. protected _useParallax: boolean;
  44500. /**
  44501. * Allows using the bump map in parallax occlusion mode.
  44502. */
  44503. protected _useParallaxOcclusion: boolean;
  44504. /**
  44505. * Controls the scale bias of the parallax mode.
  44506. */
  44507. protected _parallaxScaleBias: number;
  44508. /**
  44509. * If sets to true, disables all the lights affecting the material.
  44510. */
  44511. protected _disableLighting: boolean;
  44512. /**
  44513. * Number of Simultaneous lights allowed on the material.
  44514. */
  44515. protected _maxSimultaneousLights: number;
  44516. /**
  44517. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44518. */
  44519. protected _invertNormalMapX: boolean;
  44520. /**
  44521. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44522. */
  44523. protected _invertNormalMapY: boolean;
  44524. /**
  44525. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44526. */
  44527. protected _twoSidedLighting: boolean;
  44528. /**
  44529. * Defines the alpha limits in alpha test mode.
  44530. */
  44531. protected _alphaCutOff: number;
  44532. /**
  44533. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44534. */
  44535. protected _forceAlphaTest: boolean;
  44536. /**
  44537. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44538. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44539. */
  44540. protected _useAlphaFresnel: boolean;
  44541. /**
  44542. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44543. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44544. */
  44545. protected _useLinearAlphaFresnel: boolean;
  44546. /**
  44547. * The transparency mode of the material.
  44548. */
  44549. protected _transparencyMode: Nullable<number>;
  44550. /**
  44551. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44552. * from cos thetav and roughness:
  44553. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44554. */
  44555. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44556. /**
  44557. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44558. */
  44559. protected _forceIrradianceInFragment: boolean;
  44560. /**
  44561. * Force normal to face away from face.
  44562. */
  44563. protected _forceNormalForward: boolean;
  44564. /**
  44565. * Enables specular anti aliasing in the PBR shader.
  44566. * It will both interacts on the Geometry for analytical and IBL lighting.
  44567. * It also prefilter the roughness map based on the bump values.
  44568. */
  44569. protected _enableSpecularAntiAliasing: boolean;
  44570. /**
  44571. * Default configuration related to image processing available in the PBR Material.
  44572. */
  44573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44574. /**
  44575. * Keep track of the image processing observer to allow dispose and replace.
  44576. */
  44577. private _imageProcessingObserver;
  44578. /**
  44579. * Attaches a new image processing configuration to the PBR Material.
  44580. * @param configuration
  44581. */
  44582. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44583. /**
  44584. * Stores the available render targets.
  44585. */
  44586. private _renderTargets;
  44587. /**
  44588. * Sets the global ambient color for the material used in lighting calculations.
  44589. */
  44590. private _globalAmbientColor;
  44591. /**
  44592. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44593. */
  44594. private _useLogarithmicDepth;
  44595. /**
  44596. * If set to true, no lighting calculations will be applied.
  44597. */
  44598. private _unlit;
  44599. /**
  44600. * Defines the clear coat layer parameters for the material.
  44601. */
  44602. readonly clearCoat: PBRClearCoatConfiguration;
  44603. /**
  44604. * Defines the anisotropic parameters for the material.
  44605. */
  44606. readonly anisotropy: PBRAnisotropicConfiguration;
  44607. /**
  44608. * Instantiates a new PBRMaterial instance.
  44609. *
  44610. * @param name The material name
  44611. * @param scene The scene the material will be use in.
  44612. */
  44613. constructor(name: string, scene: Scene);
  44614. /**
  44615. * Gets a boolean indicating that current material needs to register RTT
  44616. */
  44617. readonly hasRenderTargetTextures: boolean;
  44618. /**
  44619. * Gets the name of the material class.
  44620. */
  44621. getClassName(): string;
  44622. /**
  44623. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44624. */
  44625. /**
  44626. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44627. */
  44628. useLogarithmicDepth: boolean;
  44629. /**
  44630. * Gets the current transparency mode.
  44631. */
  44632. /**
  44633. * Sets the transparency mode of the material.
  44634. *
  44635. * | Value | Type | Description |
  44636. * | ----- | ----------------------------------- | ----------- |
  44637. * | 0 | OPAQUE | |
  44638. * | 1 | ALPHATEST | |
  44639. * | 2 | ALPHABLEND | |
  44640. * | 3 | ALPHATESTANDBLEND | |
  44641. *
  44642. */
  44643. transparencyMode: Nullable<number>;
  44644. /**
  44645. * Returns true if alpha blending should be disabled.
  44646. */
  44647. private readonly _disableAlphaBlending;
  44648. /**
  44649. * Specifies whether or not this material should be rendered in alpha blend mode.
  44650. */
  44651. needAlphaBlending(): boolean;
  44652. /**
  44653. * Specifies if the mesh will require alpha blending.
  44654. * @param mesh - BJS mesh.
  44655. */
  44656. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44657. /**
  44658. * Specifies whether or not this material should be rendered in alpha test mode.
  44659. */
  44660. needAlphaTesting(): boolean;
  44661. /**
  44662. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44663. */
  44664. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44665. /**
  44666. * Gets the texture used for the alpha test.
  44667. */
  44668. getAlphaTestTexture(): BaseTexture;
  44669. /**
  44670. * Specifies that the submesh is ready to be used.
  44671. * @param mesh - BJS mesh.
  44672. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44673. * @param useInstances - Specifies that instances should be used.
  44674. * @returns - boolean indicating that the submesh is ready or not.
  44675. */
  44676. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44677. /**
  44678. * Specifies if the material uses metallic roughness workflow.
  44679. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44680. */
  44681. isMetallicWorkflow(): boolean;
  44682. private _prepareEffect;
  44683. private _prepareDefines;
  44684. /**
  44685. * Force shader compilation
  44686. */
  44687. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44688. clipPlane: boolean;
  44689. }>): void;
  44690. /**
  44691. * Initializes the uniform buffer layout for the shader.
  44692. */
  44693. buildUniformLayout(): void;
  44694. /**
  44695. * Unbinds the textures.
  44696. */
  44697. unbind(): void;
  44698. /**
  44699. * Binds the submesh data.
  44700. * @param world - The world matrix.
  44701. * @param mesh - The BJS mesh.
  44702. * @param subMesh - A submesh of the BJS mesh.
  44703. */
  44704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44705. /**
  44706. * Returns the animatable textures.
  44707. * @returns - Array of animatable textures.
  44708. */
  44709. getAnimatables(): IAnimatable[];
  44710. /**
  44711. * Returns the texture used for reflections.
  44712. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44713. */
  44714. private _getReflectionTexture;
  44715. /**
  44716. * Returns the texture used for refraction or null if none is used.
  44717. * @returns - Refection texture if present. If no refraction texture and refraction
  44718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44719. */
  44720. private _getRefractionTexture;
  44721. /**
  44722. * Returns an array of the actively used textures.
  44723. * @returns - Array of BaseTextures
  44724. */
  44725. getActiveTextures(): BaseTexture[];
  44726. /**
  44727. * Checks to see if a texture is used in the material.
  44728. * @param texture - Base texture to use.
  44729. * @returns - Boolean specifying if a texture is used in the material.
  44730. */
  44731. hasTexture(texture: BaseTexture): boolean;
  44732. /**
  44733. * Disposes the resources of the material.
  44734. * @param forceDisposeEffect - Forces the disposal of effects.
  44735. * @param forceDisposeTextures - Forces the disposal of all textures.
  44736. */
  44737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44738. }
  44739. }
  44740. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44741. import { Nullable } from "babylonjs/types";
  44742. import { Scene } from "babylonjs/scene";
  44743. import { Color3 } from "babylonjs/Maths/math";
  44744. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44745. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44747. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44748. /**
  44749. * The Physically based material of BJS.
  44750. *
  44751. * This offers the main features of a standard PBR material.
  44752. * For more information, please refer to the documentation :
  44753. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44754. */
  44755. export class PBRMaterial extends PBRBaseMaterial {
  44756. /**
  44757. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44758. */
  44759. static readonly PBRMATERIAL_OPAQUE: number;
  44760. /**
  44761. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44762. */
  44763. static readonly PBRMATERIAL_ALPHATEST: number;
  44764. /**
  44765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44766. */
  44767. static readonly PBRMATERIAL_ALPHABLEND: number;
  44768. /**
  44769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44770. * They are also discarded below the alpha cutoff threshold to improve performances.
  44771. */
  44772. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44773. /**
  44774. * Defines the default value of how much AO map is occluding the analytical lights
  44775. * (point spot...).
  44776. */
  44777. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44778. /**
  44779. * Intensity of the direct lights e.g. the four lights available in your scene.
  44780. * This impacts both the direct diffuse and specular highlights.
  44781. */
  44782. directIntensity: number;
  44783. /**
  44784. * Intensity of the emissive part of the material.
  44785. * This helps controlling the emissive effect without modifying the emissive color.
  44786. */
  44787. emissiveIntensity: number;
  44788. /**
  44789. * Intensity of the environment e.g. how much the environment will light the object
  44790. * either through harmonics for rough material or through the refelction for shiny ones.
  44791. */
  44792. environmentIntensity: number;
  44793. /**
  44794. * This is a special control allowing the reduction of the specular highlights coming from the
  44795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44796. */
  44797. specularIntensity: number;
  44798. /**
  44799. * Debug Control allowing disabling the bump map on this material.
  44800. */
  44801. disableBumpMap: boolean;
  44802. /**
  44803. * AKA Diffuse Texture in standard nomenclature.
  44804. */
  44805. albedoTexture: BaseTexture;
  44806. /**
  44807. * AKA Occlusion Texture in other nomenclature.
  44808. */
  44809. ambientTexture: BaseTexture;
  44810. /**
  44811. * AKA Occlusion Texture Intensity in other nomenclature.
  44812. */
  44813. ambientTextureStrength: number;
  44814. /**
  44815. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44816. * 1 means it completely occludes it
  44817. * 0 mean it has no impact
  44818. */
  44819. ambientTextureImpactOnAnalyticalLights: number;
  44820. /**
  44821. * Stores the alpha values in a texture.
  44822. */
  44823. opacityTexture: BaseTexture;
  44824. /**
  44825. * Stores the reflection values in a texture.
  44826. */
  44827. reflectionTexture: Nullable<BaseTexture>;
  44828. /**
  44829. * Stores the emissive values in a texture.
  44830. */
  44831. emissiveTexture: BaseTexture;
  44832. /**
  44833. * AKA Specular texture in other nomenclature.
  44834. */
  44835. reflectivityTexture: BaseTexture;
  44836. /**
  44837. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44838. */
  44839. metallicTexture: BaseTexture;
  44840. /**
  44841. * Specifies the metallic scalar of the metallic/roughness workflow.
  44842. * Can also be used to scale the metalness values of the metallic texture.
  44843. */
  44844. metallic: Nullable<number>;
  44845. /**
  44846. * Specifies the roughness scalar of the metallic/roughness workflow.
  44847. * Can also be used to scale the roughness values of the metallic texture.
  44848. */
  44849. roughness: Nullable<number>;
  44850. /**
  44851. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44852. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44853. */
  44854. microSurfaceTexture: BaseTexture;
  44855. /**
  44856. * Stores surface normal data used to displace a mesh in a texture.
  44857. */
  44858. bumpTexture: BaseTexture;
  44859. /**
  44860. * Stores the pre-calculated light information of a mesh in a texture.
  44861. */
  44862. lightmapTexture: BaseTexture;
  44863. /**
  44864. * Stores the refracted light information in a texture.
  44865. */
  44866. refractionTexture: BaseTexture;
  44867. /**
  44868. * The color of a material in ambient lighting.
  44869. */
  44870. ambientColor: Color3;
  44871. /**
  44872. * AKA Diffuse Color in other nomenclature.
  44873. */
  44874. albedoColor: Color3;
  44875. /**
  44876. * AKA Specular Color in other nomenclature.
  44877. */
  44878. reflectivityColor: Color3;
  44879. /**
  44880. * The color reflected from the material.
  44881. */
  44882. reflectionColor: Color3;
  44883. /**
  44884. * The color emitted from the material.
  44885. */
  44886. emissiveColor: Color3;
  44887. /**
  44888. * AKA Glossiness in other nomenclature.
  44889. */
  44890. microSurface: number;
  44891. /**
  44892. * source material index of refraction (IOR)' / 'destination material IOR.
  44893. */
  44894. indexOfRefraction: number;
  44895. /**
  44896. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44897. */
  44898. invertRefractionY: boolean;
  44899. /**
  44900. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44901. * Materials half opaque for instance using refraction could benefit from this control.
  44902. */
  44903. linkRefractionWithTransparency: boolean;
  44904. /**
  44905. * If true, the light map contains occlusion information instead of lighting info.
  44906. */
  44907. useLightmapAsShadowmap: boolean;
  44908. /**
  44909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44910. */
  44911. useAlphaFromAlbedoTexture: boolean;
  44912. /**
  44913. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44914. */
  44915. forceAlphaTest: boolean;
  44916. /**
  44917. * Defines the alpha limits in alpha test mode.
  44918. */
  44919. alphaCutOff: number;
  44920. /**
  44921. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44923. */
  44924. useSpecularOverAlpha: boolean;
  44925. /**
  44926. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44927. */
  44928. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44929. /**
  44930. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44931. */
  44932. useRoughnessFromMetallicTextureAlpha: boolean;
  44933. /**
  44934. * Specifies if the metallic texture contains the roughness information in its green channel.
  44935. */
  44936. useRoughnessFromMetallicTextureGreen: boolean;
  44937. /**
  44938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44939. */
  44940. useMetallnessFromMetallicTextureBlue: boolean;
  44941. /**
  44942. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44943. */
  44944. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44945. /**
  44946. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44947. */
  44948. useAmbientInGrayScale: boolean;
  44949. /**
  44950. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44951. * The material will try to infer what glossiness each pixel should be.
  44952. */
  44953. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44954. /**
  44955. * BJS is using an harcoded light falloff based on a manually sets up range.
  44956. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44957. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44958. */
  44959. /**
  44960. * BJS is using an harcoded light falloff based on a manually sets up range.
  44961. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44962. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44963. */
  44964. usePhysicalLightFalloff: boolean;
  44965. /**
  44966. * In order to support the falloff compatibility with gltf, a special mode has been added
  44967. * to reproduce the gltf light falloff.
  44968. */
  44969. /**
  44970. * In order to support the falloff compatibility with gltf, a special mode has been added
  44971. * to reproduce the gltf light falloff.
  44972. */
  44973. useGLTFLightFalloff: boolean;
  44974. /**
  44975. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44976. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44977. */
  44978. useRadianceOverAlpha: boolean;
  44979. /**
  44980. * Allows using an object space normal map (instead of tangent space).
  44981. */
  44982. useObjectSpaceNormalMap: boolean;
  44983. /**
  44984. * Allows using the bump map in parallax mode.
  44985. */
  44986. useParallax: boolean;
  44987. /**
  44988. * Allows using the bump map in parallax occlusion mode.
  44989. */
  44990. useParallaxOcclusion: boolean;
  44991. /**
  44992. * Controls the scale bias of the parallax mode.
  44993. */
  44994. parallaxScaleBias: number;
  44995. /**
  44996. * If sets to true, disables all the lights affecting the material.
  44997. */
  44998. disableLighting: boolean;
  44999. /**
  45000. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45001. */
  45002. forceIrradianceInFragment: boolean;
  45003. /**
  45004. * Number of Simultaneous lights allowed on the material.
  45005. */
  45006. maxSimultaneousLights: number;
  45007. /**
  45008. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45009. */
  45010. invertNormalMapX: boolean;
  45011. /**
  45012. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45013. */
  45014. invertNormalMapY: boolean;
  45015. /**
  45016. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45017. */
  45018. twoSidedLighting: boolean;
  45019. /**
  45020. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45021. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45022. */
  45023. useAlphaFresnel: boolean;
  45024. /**
  45025. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45026. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45027. */
  45028. useLinearAlphaFresnel: boolean;
  45029. /**
  45030. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45031. * And/Or occlude the blended part.
  45032. */
  45033. environmentBRDFTexture: Nullable<BaseTexture>;
  45034. /**
  45035. * Force normal to face away from face.
  45036. */
  45037. forceNormalForward: boolean;
  45038. /**
  45039. * Enables specular anti aliasing in the PBR shader.
  45040. * It will both interacts on the Geometry for analytical and IBL lighting.
  45041. * It also prefilter the roughness map based on the bump values.
  45042. */
  45043. enableSpecularAntiAliasing: boolean;
  45044. /**
  45045. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45046. * makes the reflect vector face the model (under horizon).
  45047. */
  45048. useHorizonOcclusion: boolean;
  45049. /**
  45050. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45051. * too much the area relying on ambient texture to define their ambient occlusion.
  45052. */
  45053. useRadianceOcclusion: boolean;
  45054. /**
  45055. * If set to true, no lighting calculations will be applied.
  45056. */
  45057. unlit: boolean;
  45058. /**
  45059. * Gets the image processing configuration used either in this material.
  45060. */
  45061. /**
  45062. * Sets the Default image processing configuration used either in the this material.
  45063. *
  45064. * If sets to null, the scene one is in use.
  45065. */
  45066. imageProcessingConfiguration: ImageProcessingConfiguration;
  45067. /**
  45068. * Gets wether the color curves effect is enabled.
  45069. */
  45070. /**
  45071. * Sets wether the color curves effect is enabled.
  45072. */
  45073. cameraColorCurvesEnabled: boolean;
  45074. /**
  45075. * Gets wether the color grading effect is enabled.
  45076. */
  45077. /**
  45078. * Gets wether the color grading effect is enabled.
  45079. */
  45080. cameraColorGradingEnabled: boolean;
  45081. /**
  45082. * Gets wether tonemapping is enabled or not.
  45083. */
  45084. /**
  45085. * Sets wether tonemapping is enabled or not
  45086. */
  45087. cameraToneMappingEnabled: boolean;
  45088. /**
  45089. * The camera exposure used on this material.
  45090. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45091. * This corresponds to a photographic exposure.
  45092. */
  45093. /**
  45094. * The camera exposure used on this material.
  45095. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45096. * This corresponds to a photographic exposure.
  45097. */
  45098. cameraExposure: number;
  45099. /**
  45100. * Gets The camera contrast used on this material.
  45101. */
  45102. /**
  45103. * Sets The camera contrast used on this material.
  45104. */
  45105. cameraContrast: number;
  45106. /**
  45107. * Gets the Color Grading 2D Lookup Texture.
  45108. */
  45109. /**
  45110. * Sets the Color Grading 2D Lookup Texture.
  45111. */
  45112. cameraColorGradingTexture: Nullable<BaseTexture>;
  45113. /**
  45114. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45115. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45116. * 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;
  45117. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45118. */
  45119. /**
  45120. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45121. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45122. * 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;
  45123. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45124. */
  45125. cameraColorCurves: Nullable<ColorCurves>;
  45126. /**
  45127. * Instantiates a new PBRMaterial instance.
  45128. *
  45129. * @param name The material name
  45130. * @param scene The scene the material will be use in.
  45131. */
  45132. constructor(name: string, scene: Scene);
  45133. /**
  45134. * Returns the name of this material class.
  45135. */
  45136. getClassName(): string;
  45137. /**
  45138. * Makes a duplicate of the current material.
  45139. * @param name - name to use for the new material.
  45140. */
  45141. clone(name: string): PBRMaterial;
  45142. /**
  45143. * Serializes this PBR Material.
  45144. * @returns - An object with the serialized material.
  45145. */
  45146. serialize(): any;
  45147. /**
  45148. * Parses a PBR Material from a serialized object.
  45149. * @param source - Serialized object.
  45150. * @param scene - BJS scene instance.
  45151. * @param rootUrl - url for the scene object
  45152. * @returns - PBRMaterial
  45153. */
  45154. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45155. }
  45156. }
  45157. declare module "babylonjs/Helpers/sceneHelpers" {
  45158. import { Nullable } from "babylonjs/types";
  45159. import { Mesh } from "babylonjs/Meshes/mesh";
  45160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45161. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45162. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45163. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45164. import "babylonjs/Meshes/Builders/boxBuilder";
  45165. /** @hidden */
  45166. export var _forceSceneHelpersToBundle: boolean;
  45167. module "babylonjs/scene" {
  45168. interface Scene {
  45169. /**
  45170. * Creates a default light for the scene.
  45171. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45172. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45173. */
  45174. createDefaultLight(replace?: boolean): void;
  45175. /**
  45176. * Creates a default camera for the scene.
  45177. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45178. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45179. * @param replace has default false, when true replaces the active camera in the scene
  45180. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45181. */
  45182. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45183. /**
  45184. * Creates a default camera and a default light.
  45185. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45186. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45187. * @param replace has the default false, when true replaces the active camera/light in the scene
  45188. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45189. */
  45190. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45191. /**
  45192. * Creates a new sky box
  45193. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45194. * @param environmentTexture defines the texture to use as environment texture
  45195. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45196. * @param scale defines the overall scale of the skybox
  45197. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45198. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45199. * @returns a new mesh holding the sky box
  45200. */
  45201. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45202. /**
  45203. * Creates a new environment
  45204. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45205. * @param options defines the options you can use to configure the environment
  45206. * @returns the new EnvironmentHelper
  45207. */
  45208. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45209. /**
  45210. * Creates a new VREXperienceHelper
  45211. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45212. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45213. * @returns a new VREXperienceHelper
  45214. */
  45215. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45216. /**
  45217. * Creates a new XREXperienceHelper
  45218. * @see http://doc.babylonjs.com/how_to/webxr
  45219. * @returns a promise for a new XREXperienceHelper
  45220. */
  45221. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45222. }
  45223. }
  45224. }
  45225. declare module "babylonjs/Helpers/videoDome" {
  45226. import { Scene } from "babylonjs/scene";
  45227. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45228. import { Mesh } from "babylonjs/Meshes/mesh";
  45229. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45230. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45231. import "babylonjs/Meshes/Builders/sphereBuilder";
  45232. /**
  45233. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45234. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45235. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45236. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45237. */
  45238. export class VideoDome extends TransformNode {
  45239. private _useDirectMapping;
  45240. /**
  45241. * The video texture being displayed on the sphere
  45242. */
  45243. protected _videoTexture: VideoTexture;
  45244. /**
  45245. * Gets the video texture being displayed on the sphere
  45246. */
  45247. readonly videoTexture: VideoTexture;
  45248. /**
  45249. * The skybox material
  45250. */
  45251. protected _material: BackgroundMaterial;
  45252. /**
  45253. * The surface used for the skybox
  45254. */
  45255. protected _mesh: Mesh;
  45256. /**
  45257. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45258. * Also see the options.resolution property.
  45259. */
  45260. fovMultiplier: number;
  45261. /**
  45262. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45263. * @param name Element's name, child elements will append suffixes for their own names.
  45264. * @param urlsOrVideo defines the url(s) or the video element to use
  45265. * @param options An object containing optional or exposed sub element properties
  45266. */
  45267. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45268. resolution?: number;
  45269. clickToPlay?: boolean;
  45270. autoPlay?: boolean;
  45271. loop?: boolean;
  45272. size?: number;
  45273. poster?: string;
  45274. useDirectMapping?: boolean;
  45275. }, scene: Scene);
  45276. /**
  45277. * Releases resources associated with this node.
  45278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45280. */
  45281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45282. }
  45283. }
  45284. declare module "babylonjs/Helpers/index" {
  45285. export * from "babylonjs/Helpers/environmentHelper";
  45286. export * from "babylonjs/Helpers/photoDome";
  45287. export * from "babylonjs/Helpers/sceneHelpers";
  45288. export * from "babylonjs/Helpers/videoDome";
  45289. }
  45290. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45291. import { PerfCounter } from "babylonjs/Misc/tools";
  45292. import { IDisposable } from "babylonjs/scene";
  45293. import { Engine } from "babylonjs/Engines/engine";
  45294. /**
  45295. * This class can be used to get instrumentation data from a Babylon engine
  45296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45297. */
  45298. export class EngineInstrumentation implements IDisposable {
  45299. /**
  45300. * Define the instrumented engine.
  45301. */
  45302. engine: Engine;
  45303. private _captureGPUFrameTime;
  45304. private _gpuFrameTimeToken;
  45305. private _gpuFrameTime;
  45306. private _captureShaderCompilationTime;
  45307. private _shaderCompilationTime;
  45308. private _onBeginFrameObserver;
  45309. private _onEndFrameObserver;
  45310. private _onBeforeShaderCompilationObserver;
  45311. private _onAfterShaderCompilationObserver;
  45312. /**
  45313. * Gets the perf counter used for GPU frame time
  45314. */
  45315. readonly gpuFrameTimeCounter: PerfCounter;
  45316. /**
  45317. * Gets the GPU frame time capture status
  45318. */
  45319. /**
  45320. * Enable or disable the GPU frame time capture
  45321. */
  45322. captureGPUFrameTime: boolean;
  45323. /**
  45324. * Gets the perf counter used for shader compilation time
  45325. */
  45326. readonly shaderCompilationTimeCounter: PerfCounter;
  45327. /**
  45328. * Gets the shader compilation time capture status
  45329. */
  45330. /**
  45331. * Enable or disable the shader compilation time capture
  45332. */
  45333. captureShaderCompilationTime: boolean;
  45334. /**
  45335. * Instantiates a new engine instrumentation.
  45336. * This class can be used to get instrumentation data from a Babylon engine
  45337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45338. * @param engine Defines the engine to instrument
  45339. */
  45340. constructor(
  45341. /**
  45342. * Define the instrumented engine.
  45343. */
  45344. engine: Engine);
  45345. /**
  45346. * Dispose and release associated resources.
  45347. */
  45348. dispose(): void;
  45349. }
  45350. }
  45351. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45352. import { PerfCounter } from "babylonjs/Misc/tools";
  45353. import { Scene, IDisposable } from "babylonjs/scene";
  45354. /**
  45355. * This class can be used to get instrumentation data from a Babylon engine
  45356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45357. */
  45358. export class SceneInstrumentation implements IDisposable {
  45359. /**
  45360. * Defines the scene to instrument
  45361. */
  45362. scene: Scene;
  45363. private _captureActiveMeshesEvaluationTime;
  45364. private _activeMeshesEvaluationTime;
  45365. private _captureRenderTargetsRenderTime;
  45366. private _renderTargetsRenderTime;
  45367. private _captureFrameTime;
  45368. private _frameTime;
  45369. private _captureRenderTime;
  45370. private _renderTime;
  45371. private _captureInterFrameTime;
  45372. private _interFrameTime;
  45373. private _captureParticlesRenderTime;
  45374. private _particlesRenderTime;
  45375. private _captureSpritesRenderTime;
  45376. private _spritesRenderTime;
  45377. private _capturePhysicsTime;
  45378. private _physicsTime;
  45379. private _captureAnimationsTime;
  45380. private _animationsTime;
  45381. private _captureCameraRenderTime;
  45382. private _cameraRenderTime;
  45383. private _onBeforeActiveMeshesEvaluationObserver;
  45384. private _onAfterActiveMeshesEvaluationObserver;
  45385. private _onBeforeRenderTargetsRenderObserver;
  45386. private _onAfterRenderTargetsRenderObserver;
  45387. private _onAfterRenderObserver;
  45388. private _onBeforeDrawPhaseObserver;
  45389. private _onAfterDrawPhaseObserver;
  45390. private _onBeforeAnimationsObserver;
  45391. private _onBeforeParticlesRenderingObserver;
  45392. private _onAfterParticlesRenderingObserver;
  45393. private _onBeforeSpritesRenderingObserver;
  45394. private _onAfterSpritesRenderingObserver;
  45395. private _onBeforePhysicsObserver;
  45396. private _onAfterPhysicsObserver;
  45397. private _onAfterAnimationsObserver;
  45398. private _onBeforeCameraRenderObserver;
  45399. private _onAfterCameraRenderObserver;
  45400. /**
  45401. * Gets the perf counter used for active meshes evaluation time
  45402. */
  45403. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45404. /**
  45405. * Gets the active meshes evaluation time capture status
  45406. */
  45407. /**
  45408. * Enable or disable the active meshes evaluation time capture
  45409. */
  45410. captureActiveMeshesEvaluationTime: boolean;
  45411. /**
  45412. * Gets the perf counter used for render targets render time
  45413. */
  45414. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45415. /**
  45416. * Gets the render targets render time capture status
  45417. */
  45418. /**
  45419. * Enable or disable the render targets render time capture
  45420. */
  45421. captureRenderTargetsRenderTime: boolean;
  45422. /**
  45423. * Gets the perf counter used for particles render time
  45424. */
  45425. readonly particlesRenderTimeCounter: PerfCounter;
  45426. /**
  45427. * Gets the particles render time capture status
  45428. */
  45429. /**
  45430. * Enable or disable the particles render time capture
  45431. */
  45432. captureParticlesRenderTime: boolean;
  45433. /**
  45434. * Gets the perf counter used for sprites render time
  45435. */
  45436. readonly spritesRenderTimeCounter: PerfCounter;
  45437. /**
  45438. * Gets the sprites render time capture status
  45439. */
  45440. /**
  45441. * Enable or disable the sprites render time capture
  45442. */
  45443. captureSpritesRenderTime: boolean;
  45444. /**
  45445. * Gets the perf counter used for physics time
  45446. */
  45447. readonly physicsTimeCounter: PerfCounter;
  45448. /**
  45449. * Gets the physics time capture status
  45450. */
  45451. /**
  45452. * Enable or disable the physics time capture
  45453. */
  45454. capturePhysicsTime: boolean;
  45455. /**
  45456. * Gets the perf counter used for animations time
  45457. */
  45458. readonly animationsTimeCounter: PerfCounter;
  45459. /**
  45460. * Gets the animations time capture status
  45461. */
  45462. /**
  45463. * Enable or disable the animations time capture
  45464. */
  45465. captureAnimationsTime: boolean;
  45466. /**
  45467. * Gets the perf counter used for frame time capture
  45468. */
  45469. readonly frameTimeCounter: PerfCounter;
  45470. /**
  45471. * Gets the frame time capture status
  45472. */
  45473. /**
  45474. * Enable or disable the frame time capture
  45475. */
  45476. captureFrameTime: boolean;
  45477. /**
  45478. * Gets the perf counter used for inter-frames time capture
  45479. */
  45480. readonly interFrameTimeCounter: PerfCounter;
  45481. /**
  45482. * Gets the inter-frames time capture status
  45483. */
  45484. /**
  45485. * Enable or disable the inter-frames time capture
  45486. */
  45487. captureInterFrameTime: boolean;
  45488. /**
  45489. * Gets the perf counter used for render time capture
  45490. */
  45491. readonly renderTimeCounter: PerfCounter;
  45492. /**
  45493. * Gets the render time capture status
  45494. */
  45495. /**
  45496. * Enable or disable the render time capture
  45497. */
  45498. captureRenderTime: boolean;
  45499. /**
  45500. * Gets the perf counter used for camera render time capture
  45501. */
  45502. readonly cameraRenderTimeCounter: PerfCounter;
  45503. /**
  45504. * Gets the camera render time capture status
  45505. */
  45506. /**
  45507. * Enable or disable the camera render time capture
  45508. */
  45509. captureCameraRenderTime: boolean;
  45510. /**
  45511. * Gets the perf counter used for draw calls
  45512. */
  45513. readonly drawCallsCounter: PerfCounter;
  45514. /**
  45515. * Gets the perf counter used for texture collisions
  45516. */
  45517. readonly textureCollisionsCounter: PerfCounter;
  45518. /**
  45519. * Instantiates a new scene instrumentation.
  45520. * This class can be used to get instrumentation data from a Babylon engine
  45521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45522. * @param scene Defines the scene to instrument
  45523. */
  45524. constructor(
  45525. /**
  45526. * Defines the scene to instrument
  45527. */
  45528. scene: Scene);
  45529. /**
  45530. * Dispose and release associated resources.
  45531. */
  45532. dispose(): void;
  45533. }
  45534. }
  45535. declare module "babylonjs/Instrumentation/index" {
  45536. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45537. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45538. export * from "babylonjs/Instrumentation/timeToken";
  45539. }
  45540. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45541. /** @hidden */
  45542. export var glowMapGenerationPixelShader: {
  45543. name: string;
  45544. shader: string;
  45545. };
  45546. }
  45547. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45548. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45551. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45555. /** @hidden */
  45556. export var glowMapGenerationVertexShader: {
  45557. name: string;
  45558. shader: string;
  45559. };
  45560. }
  45561. declare module "babylonjs/Layers/effectLayer" {
  45562. import { Observable } from "babylonjs/Misc/observable";
  45563. import { Nullable } from "babylonjs/types";
  45564. import { Camera } from "babylonjs/Cameras/camera";
  45565. import { Scene } from "babylonjs/scene";
  45566. import { Color4, ISize } from "babylonjs/Maths/math";
  45567. import { Engine } from "babylonjs/Engines/engine";
  45568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45570. import { Mesh } from "babylonjs/Meshes/mesh";
  45571. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45574. import { Effect } from "babylonjs/Materials/effect";
  45575. import { Material } from "babylonjs/Materials/material";
  45576. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45577. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45578. /**
  45579. * Effect layer options. This helps customizing the behaviour
  45580. * of the effect layer.
  45581. */
  45582. export interface IEffectLayerOptions {
  45583. /**
  45584. * Multiplication factor apply to the canvas size to compute the render target size
  45585. * used to generated the objects (the smaller the faster).
  45586. */
  45587. mainTextureRatio: number;
  45588. /**
  45589. * Enforces a fixed size texture to ensure effect stability across devices.
  45590. */
  45591. mainTextureFixedSize?: number;
  45592. /**
  45593. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45594. */
  45595. alphaBlendingMode: number;
  45596. /**
  45597. * The camera attached to the layer.
  45598. */
  45599. camera: Nullable<Camera>;
  45600. /**
  45601. * The rendering group to draw the layer in.
  45602. */
  45603. renderingGroupId: number;
  45604. }
  45605. /**
  45606. * The effect layer Helps adding post process effect blended with the main pass.
  45607. *
  45608. * This can be for instance use to generate glow or higlight effects on the scene.
  45609. *
  45610. * The effect layer class can not be used directly and is intented to inherited from to be
  45611. * customized per effects.
  45612. */
  45613. export abstract class EffectLayer {
  45614. private _vertexBuffers;
  45615. private _indexBuffer;
  45616. private _cachedDefines;
  45617. private _effectLayerMapGenerationEffect;
  45618. private _effectLayerOptions;
  45619. private _mergeEffect;
  45620. protected _scene: Scene;
  45621. protected _engine: Engine;
  45622. protected _maxSize: number;
  45623. protected _mainTextureDesiredSize: ISize;
  45624. protected _mainTexture: RenderTargetTexture;
  45625. protected _shouldRender: boolean;
  45626. protected _postProcesses: PostProcess[];
  45627. protected _textures: BaseTexture[];
  45628. protected _emissiveTextureAndColor: {
  45629. texture: Nullable<BaseTexture>;
  45630. color: Color4;
  45631. };
  45632. /**
  45633. * The name of the layer
  45634. */
  45635. name: string;
  45636. /**
  45637. * The clear color of the texture used to generate the glow map.
  45638. */
  45639. neutralColor: Color4;
  45640. /**
  45641. * Specifies wether the highlight layer is enabled or not.
  45642. */
  45643. isEnabled: boolean;
  45644. /**
  45645. * Gets the camera attached to the layer.
  45646. */
  45647. readonly camera: Nullable<Camera>;
  45648. /**
  45649. * Gets the rendering group id the layer should render in.
  45650. */
  45651. readonly renderingGroupId: number;
  45652. /**
  45653. * An event triggered when the effect layer has been disposed.
  45654. */
  45655. onDisposeObservable: Observable<EffectLayer>;
  45656. /**
  45657. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45658. */
  45659. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45660. /**
  45661. * An event triggered when the generated texture is being merged in the scene.
  45662. */
  45663. onBeforeComposeObservable: Observable<EffectLayer>;
  45664. /**
  45665. * An event triggered when the generated texture has been merged in the scene.
  45666. */
  45667. onAfterComposeObservable: Observable<EffectLayer>;
  45668. /**
  45669. * An event triggered when the efffect layer changes its size.
  45670. */
  45671. onSizeChangedObservable: Observable<EffectLayer>;
  45672. /** @hidden */
  45673. static _SceneComponentInitialization: (scene: Scene) => void;
  45674. /**
  45675. * Instantiates a new effect Layer and references it in the scene.
  45676. * @param name The name of the layer
  45677. * @param scene The scene to use the layer in
  45678. */
  45679. constructor(
  45680. /** The Friendly of the effect in the scene */
  45681. name: string, scene: Scene);
  45682. /**
  45683. * Get the effect name of the layer.
  45684. * @return The effect name
  45685. */
  45686. abstract getEffectName(): string;
  45687. /**
  45688. * Checks for the readiness of the element composing the layer.
  45689. * @param subMesh the mesh to check for
  45690. * @param useInstances specify wether or not to use instances to render the mesh
  45691. * @return true if ready otherwise, false
  45692. */
  45693. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45694. /**
  45695. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45696. * @returns true if the effect requires stencil during the main canvas render pass.
  45697. */
  45698. abstract needStencil(): boolean;
  45699. /**
  45700. * Create the merge effect. This is the shader use to blit the information back
  45701. * to the main canvas at the end of the scene rendering.
  45702. * @returns The effect containing the shader used to merge the effect on the main canvas
  45703. */
  45704. protected abstract _createMergeEffect(): Effect;
  45705. /**
  45706. * Creates the render target textures and post processes used in the effect layer.
  45707. */
  45708. protected abstract _createTextureAndPostProcesses(): void;
  45709. /**
  45710. * Implementation specific of rendering the generating effect on the main canvas.
  45711. * @param effect The effect used to render through
  45712. */
  45713. protected abstract _internalRender(effect: Effect): void;
  45714. /**
  45715. * Sets the required values for both the emissive texture and and the main color.
  45716. */
  45717. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45718. /**
  45719. * Free any resources and references associated to a mesh.
  45720. * Internal use
  45721. * @param mesh The mesh to free.
  45722. */
  45723. abstract _disposeMesh(mesh: Mesh): void;
  45724. /**
  45725. * Serializes this layer (Glow or Highlight for example)
  45726. * @returns a serialized layer object
  45727. */
  45728. abstract serialize?(): any;
  45729. /**
  45730. * Initializes the effect layer with the required options.
  45731. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45732. */
  45733. protected _init(options: Partial<IEffectLayerOptions>): void;
  45734. /**
  45735. * Generates the index buffer of the full screen quad blending to the main canvas.
  45736. */
  45737. private _generateIndexBuffer;
  45738. /**
  45739. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45740. */
  45741. private _genrateVertexBuffer;
  45742. /**
  45743. * Sets the main texture desired size which is the closest power of two
  45744. * of the engine canvas size.
  45745. */
  45746. private _setMainTextureSize;
  45747. /**
  45748. * Creates the main texture for the effect layer.
  45749. */
  45750. protected _createMainTexture(): void;
  45751. /**
  45752. * Adds specific effects defines.
  45753. * @param defines The defines to add specifics to.
  45754. */
  45755. protected _addCustomEffectDefines(defines: string[]): void;
  45756. /**
  45757. * Checks for the readiness of the element composing the layer.
  45758. * @param subMesh the mesh to check for
  45759. * @param useInstances specify wether or not to use instances to render the mesh
  45760. * @param emissiveTexture the associated emissive texture used to generate the glow
  45761. * @return true if ready otherwise, false
  45762. */
  45763. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45764. /**
  45765. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45766. */
  45767. render(): void;
  45768. /**
  45769. * Determine if a given mesh will be used in the current effect.
  45770. * @param mesh mesh to test
  45771. * @returns true if the mesh will be used
  45772. */
  45773. hasMesh(mesh: AbstractMesh): boolean;
  45774. /**
  45775. * Returns true if the layer contains information to display, otherwise false.
  45776. * @returns true if the glow layer should be rendered
  45777. */
  45778. shouldRender(): boolean;
  45779. /**
  45780. * Returns true if the mesh should render, otherwise false.
  45781. * @param mesh The mesh to render
  45782. * @returns true if it should render otherwise false
  45783. */
  45784. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45785. /**
  45786. * Returns true if the mesh can be rendered, otherwise false.
  45787. * @param mesh The mesh to render
  45788. * @param material The material used on the mesh
  45789. * @returns true if it can be rendered otherwise false
  45790. */
  45791. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45792. /**
  45793. * Returns true if the mesh should render, otherwise false.
  45794. * @param mesh The mesh to render
  45795. * @returns true if it should render otherwise false
  45796. */
  45797. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45798. /**
  45799. * Renders the submesh passed in parameter to the generation map.
  45800. */
  45801. protected _renderSubMesh(subMesh: SubMesh): void;
  45802. /**
  45803. * Rebuild the required buffers.
  45804. * @hidden Internal use only.
  45805. */
  45806. _rebuild(): void;
  45807. /**
  45808. * Dispose only the render target textures and post process.
  45809. */
  45810. private _disposeTextureAndPostProcesses;
  45811. /**
  45812. * Dispose the highlight layer and free resources.
  45813. */
  45814. dispose(): void;
  45815. /**
  45816. * Gets the class name of the effect layer
  45817. * @returns the string with the class name of the effect layer
  45818. */
  45819. getClassName(): string;
  45820. /**
  45821. * Creates an effect layer from parsed effect layer data
  45822. * @param parsedEffectLayer defines effect layer data
  45823. * @param scene defines the current scene
  45824. * @param rootUrl defines the root URL containing the effect layer information
  45825. * @returns a parsed effect Layer
  45826. */
  45827. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45828. }
  45829. }
  45830. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45831. import { Scene } from "babylonjs/scene";
  45832. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45833. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45834. import { AbstractScene } from "babylonjs/abstractScene";
  45835. module "babylonjs/abstractScene" {
  45836. interface AbstractScene {
  45837. /**
  45838. * The list of effect layers (highlights/glow) added to the scene
  45839. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45840. * @see http://doc.babylonjs.com/how_to/glow_layer
  45841. */
  45842. effectLayers: Array<EffectLayer>;
  45843. /**
  45844. * Removes the given effect layer from this scene.
  45845. * @param toRemove defines the effect layer to remove
  45846. * @returns the index of the removed effect layer
  45847. */
  45848. removeEffectLayer(toRemove: EffectLayer): number;
  45849. /**
  45850. * Adds the given effect layer to this scene
  45851. * @param newEffectLayer defines the effect layer to add
  45852. */
  45853. addEffectLayer(newEffectLayer: EffectLayer): void;
  45854. }
  45855. }
  45856. /**
  45857. * Defines the layer scene component responsible to manage any effect layers
  45858. * in a given scene.
  45859. */
  45860. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45861. /**
  45862. * The component name helpfull to identify the component in the list of scene components.
  45863. */
  45864. readonly name: string;
  45865. /**
  45866. * The scene the component belongs to.
  45867. */
  45868. scene: Scene;
  45869. private _engine;
  45870. private _renderEffects;
  45871. private _needStencil;
  45872. private _previousStencilState;
  45873. /**
  45874. * Creates a new instance of the component for the given scene
  45875. * @param scene Defines the scene to register the component in
  45876. */
  45877. constructor(scene: Scene);
  45878. /**
  45879. * Registers the component in a given scene
  45880. */
  45881. register(): void;
  45882. /**
  45883. * Rebuilds the elements related to this component in case of
  45884. * context lost for instance.
  45885. */
  45886. rebuild(): void;
  45887. /**
  45888. * Serializes the component data to the specified json object
  45889. * @param serializationObject The object to serialize to
  45890. */
  45891. serialize(serializationObject: any): void;
  45892. /**
  45893. * Adds all the element from the container to the scene
  45894. * @param container the container holding the elements
  45895. */
  45896. addFromContainer(container: AbstractScene): void;
  45897. /**
  45898. * Removes all the elements in the container from the scene
  45899. * @param container contains the elements to remove
  45900. */
  45901. removeFromContainer(container: AbstractScene): void;
  45902. /**
  45903. * Disposes the component and the associated ressources.
  45904. */
  45905. dispose(): void;
  45906. private _isReadyForMesh;
  45907. private _renderMainTexture;
  45908. private _setStencil;
  45909. private _setStencilBack;
  45910. private _draw;
  45911. private _drawCamera;
  45912. private _drawRenderingGroup;
  45913. }
  45914. }
  45915. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45916. /** @hidden */
  45917. export var glowMapMergePixelShader: {
  45918. name: string;
  45919. shader: string;
  45920. };
  45921. }
  45922. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45923. /** @hidden */
  45924. export var glowMapMergeVertexShader: {
  45925. name: string;
  45926. shader: string;
  45927. };
  45928. }
  45929. declare module "babylonjs/Layers/glowLayer" {
  45930. import { Nullable } from "babylonjs/types";
  45931. import { Camera } from "babylonjs/Cameras/camera";
  45932. import { Scene } from "babylonjs/scene";
  45933. import { Color4 } from "babylonjs/Maths/math";
  45934. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45936. import { Mesh } from "babylonjs/Meshes/mesh";
  45937. import { Texture } from "babylonjs/Materials/Textures/texture";
  45938. import { Effect } from "babylonjs/Materials/effect";
  45939. import { Material } from "babylonjs/Materials/material";
  45940. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45941. import "babylonjs/Shaders/glowMapMerge.fragment";
  45942. import "babylonjs/Shaders/glowMapMerge.vertex";
  45943. module "babylonjs/abstractScene" {
  45944. interface AbstractScene {
  45945. /**
  45946. * Return a the first highlight layer of the scene with a given name.
  45947. * @param name The name of the highlight layer to look for.
  45948. * @return The highlight layer if found otherwise null.
  45949. */
  45950. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45951. }
  45952. }
  45953. /**
  45954. * Glow layer options. This helps customizing the behaviour
  45955. * of the glow layer.
  45956. */
  45957. export interface IGlowLayerOptions {
  45958. /**
  45959. * Multiplication factor apply to the canvas size to compute the render target size
  45960. * used to generated the glowing objects (the smaller the faster).
  45961. */
  45962. mainTextureRatio: number;
  45963. /**
  45964. * Enforces a fixed size texture to ensure resize independant blur.
  45965. */
  45966. mainTextureFixedSize?: number;
  45967. /**
  45968. * How big is the kernel of the blur texture.
  45969. */
  45970. blurKernelSize: number;
  45971. /**
  45972. * The camera attached to the layer.
  45973. */
  45974. camera: Nullable<Camera>;
  45975. /**
  45976. * Enable MSAA by chosing the number of samples.
  45977. */
  45978. mainTextureSamples?: number;
  45979. /**
  45980. * The rendering group to draw the layer in.
  45981. */
  45982. renderingGroupId: number;
  45983. }
  45984. /**
  45985. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45986. *
  45987. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45988. * glowy meshes to your scene.
  45989. *
  45990. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45991. */
  45992. export class GlowLayer extends EffectLayer {
  45993. /**
  45994. * Effect Name of the layer.
  45995. */
  45996. static readonly EffectName: string;
  45997. /**
  45998. * The default blur kernel size used for the glow.
  45999. */
  46000. static DefaultBlurKernelSize: number;
  46001. /**
  46002. * The default texture size ratio used for the glow.
  46003. */
  46004. static DefaultTextureRatio: number;
  46005. /**
  46006. * Sets the kernel size of the blur.
  46007. */
  46008. /**
  46009. * Gets the kernel size of the blur.
  46010. */
  46011. blurKernelSize: number;
  46012. /**
  46013. * Sets the glow intensity.
  46014. */
  46015. /**
  46016. * Gets the glow intensity.
  46017. */
  46018. intensity: number;
  46019. private _options;
  46020. private _intensity;
  46021. private _horizontalBlurPostprocess1;
  46022. private _verticalBlurPostprocess1;
  46023. private _horizontalBlurPostprocess2;
  46024. private _verticalBlurPostprocess2;
  46025. private _blurTexture1;
  46026. private _blurTexture2;
  46027. private _postProcesses1;
  46028. private _postProcesses2;
  46029. private _includedOnlyMeshes;
  46030. private _excludedMeshes;
  46031. /**
  46032. * Callback used to let the user override the color selection on a per mesh basis
  46033. */
  46034. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46035. /**
  46036. * Callback used to let the user override the texture selection on a per mesh basis
  46037. */
  46038. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46039. /**
  46040. * Instantiates a new glow Layer and references it to the scene.
  46041. * @param name The name of the layer
  46042. * @param scene The scene to use the layer in
  46043. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46044. */
  46045. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46046. /**
  46047. * Get the effect name of the layer.
  46048. * @return The effect name
  46049. */
  46050. getEffectName(): string;
  46051. /**
  46052. * Create the merge effect. This is the shader use to blit the information back
  46053. * to the main canvas at the end of the scene rendering.
  46054. */
  46055. protected _createMergeEffect(): Effect;
  46056. /**
  46057. * Creates the render target textures and post processes used in the glow layer.
  46058. */
  46059. protected _createTextureAndPostProcesses(): void;
  46060. /**
  46061. * Checks for the readiness of the element composing the layer.
  46062. * @param subMesh the mesh to check for
  46063. * @param useInstances specify wether or not to use instances to render the mesh
  46064. * @param emissiveTexture the associated emissive texture used to generate the glow
  46065. * @return true if ready otherwise, false
  46066. */
  46067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46068. /**
  46069. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46070. */
  46071. needStencil(): boolean;
  46072. /**
  46073. * Returns true if the mesh can be rendered, otherwise false.
  46074. * @param mesh The mesh to render
  46075. * @param material The material used on the mesh
  46076. * @returns true if it can be rendered otherwise false
  46077. */
  46078. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46079. /**
  46080. * Implementation specific of rendering the generating effect on the main canvas.
  46081. * @param effect The effect used to render through
  46082. */
  46083. protected _internalRender(effect: Effect): void;
  46084. /**
  46085. * Sets the required values for both the emissive texture and and the main color.
  46086. */
  46087. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46088. /**
  46089. * Returns true if the mesh should render, otherwise false.
  46090. * @param mesh The mesh to render
  46091. * @returns true if it should render otherwise false
  46092. */
  46093. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46094. /**
  46095. * Adds specific effects defines.
  46096. * @param defines The defines to add specifics to.
  46097. */
  46098. protected _addCustomEffectDefines(defines: string[]): void;
  46099. /**
  46100. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46101. * @param mesh The mesh to exclude from the glow layer
  46102. */
  46103. addExcludedMesh(mesh: Mesh): void;
  46104. /**
  46105. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46106. * @param mesh The mesh to remove
  46107. */
  46108. removeExcludedMesh(mesh: Mesh): void;
  46109. /**
  46110. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46111. * @param mesh The mesh to include in the glow layer
  46112. */
  46113. addIncludedOnlyMesh(mesh: Mesh): void;
  46114. /**
  46115. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46116. * @param mesh The mesh to remove
  46117. */
  46118. removeIncludedOnlyMesh(mesh: Mesh): void;
  46119. /**
  46120. * Determine if a given mesh will be used in the glow layer
  46121. * @param mesh The mesh to test
  46122. * @returns true if the mesh will be highlighted by the current glow layer
  46123. */
  46124. hasMesh(mesh: AbstractMesh): boolean;
  46125. /**
  46126. * Free any resources and references associated to a mesh.
  46127. * Internal use
  46128. * @param mesh The mesh to free.
  46129. * @hidden
  46130. */
  46131. _disposeMesh(mesh: Mesh): void;
  46132. /**
  46133. * Gets the class name of the effect layer
  46134. * @returns the string with the class name of the effect layer
  46135. */
  46136. getClassName(): string;
  46137. /**
  46138. * Serializes this glow layer
  46139. * @returns a serialized glow layer object
  46140. */
  46141. serialize(): any;
  46142. /**
  46143. * Creates a Glow Layer from parsed glow layer data
  46144. * @param parsedGlowLayer defines glow layer data
  46145. * @param scene defines the current scene
  46146. * @param rootUrl defines the root URL containing the glow layer information
  46147. * @returns a parsed Glow Layer
  46148. */
  46149. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46150. }
  46151. }
  46152. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46153. /** @hidden */
  46154. export var glowBlurPostProcessPixelShader: {
  46155. name: string;
  46156. shader: string;
  46157. };
  46158. }
  46159. declare module "babylonjs/Layers/highlightLayer" {
  46160. import { Observable } from "babylonjs/Misc/observable";
  46161. import { Nullable } from "babylonjs/types";
  46162. import { Camera } from "babylonjs/Cameras/camera";
  46163. import { Scene } from "babylonjs/scene";
  46164. import { Color3, Color4 } from "babylonjs/Maths/math";
  46165. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46167. import { Mesh } from "babylonjs/Meshes/mesh";
  46168. import { Effect } from "babylonjs/Materials/effect";
  46169. import { Material } from "babylonjs/Materials/material";
  46170. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46171. import "babylonjs/Shaders/glowMapMerge.fragment";
  46172. import "babylonjs/Shaders/glowMapMerge.vertex";
  46173. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46174. module "babylonjs/abstractScene" {
  46175. interface AbstractScene {
  46176. /**
  46177. * Return a the first highlight layer of the scene with a given name.
  46178. * @param name The name of the highlight layer to look for.
  46179. * @return The highlight layer if found otherwise null.
  46180. */
  46181. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46182. }
  46183. }
  46184. /**
  46185. * Highlight layer options. This helps customizing the behaviour
  46186. * of the highlight layer.
  46187. */
  46188. export interface IHighlightLayerOptions {
  46189. /**
  46190. * Multiplication factor apply to the canvas size to compute the render target size
  46191. * used to generated the glowing objects (the smaller the faster).
  46192. */
  46193. mainTextureRatio: number;
  46194. /**
  46195. * Enforces a fixed size texture to ensure resize independant blur.
  46196. */
  46197. mainTextureFixedSize?: number;
  46198. /**
  46199. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46200. * of the picture to blur (the smaller the faster).
  46201. */
  46202. blurTextureSizeRatio: number;
  46203. /**
  46204. * How big in texel of the blur texture is the vertical blur.
  46205. */
  46206. blurVerticalSize: number;
  46207. /**
  46208. * How big in texel of the blur texture is the horizontal blur.
  46209. */
  46210. blurHorizontalSize: number;
  46211. /**
  46212. * Alpha blending mode used to apply the blur. Default is combine.
  46213. */
  46214. alphaBlendingMode: number;
  46215. /**
  46216. * The camera attached to the layer.
  46217. */
  46218. camera: Nullable<Camera>;
  46219. /**
  46220. * Should we display highlight as a solid stroke?
  46221. */
  46222. isStroke?: boolean;
  46223. /**
  46224. * The rendering group to draw the layer in.
  46225. */
  46226. renderingGroupId: number;
  46227. }
  46228. /**
  46229. * The highlight layer Helps adding a glow effect around a mesh.
  46230. *
  46231. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46232. * glowy meshes to your scene.
  46233. *
  46234. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46235. */
  46236. export class HighlightLayer extends EffectLayer {
  46237. name: string;
  46238. /**
  46239. * Effect Name of the highlight layer.
  46240. */
  46241. static readonly EffectName: string;
  46242. /**
  46243. * The neutral color used during the preparation of the glow effect.
  46244. * This is black by default as the blend operation is a blend operation.
  46245. */
  46246. static NeutralColor: Color4;
  46247. /**
  46248. * Stencil value used for glowing meshes.
  46249. */
  46250. static GlowingMeshStencilReference: number;
  46251. /**
  46252. * Stencil value used for the other meshes in the scene.
  46253. */
  46254. static NormalMeshStencilReference: number;
  46255. /**
  46256. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46257. */
  46258. innerGlow: boolean;
  46259. /**
  46260. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46261. */
  46262. outerGlow: boolean;
  46263. /**
  46264. * Specifies the horizontal size of the blur.
  46265. */
  46266. /**
  46267. * Gets the horizontal size of the blur.
  46268. */
  46269. blurHorizontalSize: number;
  46270. /**
  46271. * Specifies the vertical size of the blur.
  46272. */
  46273. /**
  46274. * Gets the vertical size of the blur.
  46275. */
  46276. blurVerticalSize: number;
  46277. /**
  46278. * An event triggered when the highlight layer is being blurred.
  46279. */
  46280. onBeforeBlurObservable: Observable<HighlightLayer>;
  46281. /**
  46282. * An event triggered when the highlight layer has been blurred.
  46283. */
  46284. onAfterBlurObservable: Observable<HighlightLayer>;
  46285. private _instanceGlowingMeshStencilReference;
  46286. private _options;
  46287. private _downSamplePostprocess;
  46288. private _horizontalBlurPostprocess;
  46289. private _verticalBlurPostprocess;
  46290. private _blurTexture;
  46291. private _meshes;
  46292. private _excludedMeshes;
  46293. /**
  46294. * Instantiates a new highlight Layer and references it to the scene..
  46295. * @param name The name of the layer
  46296. * @param scene The scene to use the layer in
  46297. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46298. */
  46299. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46300. /**
  46301. * Get the effect name of the layer.
  46302. * @return The effect name
  46303. */
  46304. getEffectName(): string;
  46305. /**
  46306. * Create the merge effect. This is the shader use to blit the information back
  46307. * to the main canvas at the end of the scene rendering.
  46308. */
  46309. protected _createMergeEffect(): Effect;
  46310. /**
  46311. * Creates the render target textures and post processes used in the highlight layer.
  46312. */
  46313. protected _createTextureAndPostProcesses(): void;
  46314. /**
  46315. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46316. */
  46317. needStencil(): boolean;
  46318. /**
  46319. * Checks for the readiness of the element composing the layer.
  46320. * @param subMesh the mesh to check for
  46321. * @param useInstances specify wether or not to use instances to render the mesh
  46322. * @param emissiveTexture the associated emissive texture used to generate the glow
  46323. * @return true if ready otherwise, false
  46324. */
  46325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46326. /**
  46327. * Implementation specific of rendering the generating effect on the main canvas.
  46328. * @param effect The effect used to render through
  46329. */
  46330. protected _internalRender(effect: Effect): void;
  46331. /**
  46332. * Returns true if the layer contains information to display, otherwise false.
  46333. */
  46334. shouldRender(): boolean;
  46335. /**
  46336. * Returns true if the mesh should render, otherwise false.
  46337. * @param mesh The mesh to render
  46338. * @returns true if it should render otherwise false
  46339. */
  46340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46341. /**
  46342. * Sets the required values for both the emissive texture and and the main color.
  46343. */
  46344. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46345. /**
  46346. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46347. * @param mesh The mesh to exclude from the highlight layer
  46348. */
  46349. addExcludedMesh(mesh: Mesh): void;
  46350. /**
  46351. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46352. * @param mesh The mesh to highlight
  46353. */
  46354. removeExcludedMesh(mesh: Mesh): void;
  46355. /**
  46356. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46357. * @param mesh mesh to test
  46358. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46359. */
  46360. hasMesh(mesh: AbstractMesh): boolean;
  46361. /**
  46362. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46363. * @param mesh The mesh to highlight
  46364. * @param color The color of the highlight
  46365. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46366. */
  46367. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46368. /**
  46369. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46370. * @param mesh The mesh to highlight
  46371. */
  46372. removeMesh(mesh: Mesh): void;
  46373. /**
  46374. * Force the stencil to the normal expected value for none glowing parts
  46375. */
  46376. private _defaultStencilReference;
  46377. /**
  46378. * Free any resources and references associated to a mesh.
  46379. * Internal use
  46380. * @param mesh The mesh to free.
  46381. * @hidden
  46382. */
  46383. _disposeMesh(mesh: Mesh): void;
  46384. /**
  46385. * Dispose the highlight layer and free resources.
  46386. */
  46387. dispose(): void;
  46388. /**
  46389. * Gets the class name of the effect layer
  46390. * @returns the string with the class name of the effect layer
  46391. */
  46392. getClassName(): string;
  46393. /**
  46394. * Serializes this Highlight layer
  46395. * @returns a serialized Highlight layer object
  46396. */
  46397. serialize(): any;
  46398. /**
  46399. * Creates a Highlight layer from parsed Highlight layer data
  46400. * @param parsedHightlightLayer defines the Highlight layer data
  46401. * @param scene defines the current scene
  46402. * @param rootUrl defines the root URL containing the Highlight layer information
  46403. * @returns a parsed Highlight layer
  46404. */
  46405. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46406. }
  46407. }
  46408. declare module "babylonjs/Layers/index" {
  46409. export * from "babylonjs/Layers/effectLayer";
  46410. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46411. export * from "babylonjs/Layers/glowLayer";
  46412. export * from "babylonjs/Layers/highlightLayer";
  46413. export * from "babylonjs/Layers/layer";
  46414. export * from "babylonjs/Layers/layerSceneComponent";
  46415. }
  46416. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46417. /** @hidden */
  46418. export var lensFlarePixelShader: {
  46419. name: string;
  46420. shader: string;
  46421. };
  46422. }
  46423. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46424. /** @hidden */
  46425. export var lensFlareVertexShader: {
  46426. name: string;
  46427. shader: string;
  46428. };
  46429. }
  46430. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46431. import { Scene } from "babylonjs/scene";
  46432. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46434. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46435. import "babylonjs/Shaders/lensFlare.fragment";
  46436. import "babylonjs/Shaders/lensFlare.vertex";
  46437. /**
  46438. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46439. * It is usually composed of several `lensFlare`.
  46440. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46441. */
  46442. export class LensFlareSystem {
  46443. /**
  46444. * Define the name of the lens flare system
  46445. */
  46446. name: string;
  46447. /**
  46448. * List of lens flares used in this system.
  46449. */
  46450. lensFlares: LensFlare[];
  46451. /**
  46452. * Define a limit from the border the lens flare can be visible.
  46453. */
  46454. borderLimit: number;
  46455. /**
  46456. * Define a viewport border we do not want to see the lens flare in.
  46457. */
  46458. viewportBorder: number;
  46459. /**
  46460. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46461. */
  46462. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46463. /**
  46464. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46465. */
  46466. layerMask: number;
  46467. /**
  46468. * Define the id of the lens flare system in the scene.
  46469. * (equal to name by default)
  46470. */
  46471. id: string;
  46472. private _scene;
  46473. private _emitter;
  46474. private _vertexBuffers;
  46475. private _indexBuffer;
  46476. private _effect;
  46477. private _positionX;
  46478. private _positionY;
  46479. private _isEnabled;
  46480. /** @hidden */
  46481. static _SceneComponentInitialization: (scene: Scene) => void;
  46482. /**
  46483. * Instantiates a lens flare system.
  46484. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46485. * It is usually composed of several `lensFlare`.
  46486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46487. * @param name Define the name of the lens flare system in the scene
  46488. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46489. * @param scene Define the scene the lens flare system belongs to
  46490. */
  46491. constructor(
  46492. /**
  46493. * Define the name of the lens flare system
  46494. */
  46495. name: string, emitter: any, scene: Scene);
  46496. /**
  46497. * Define if the lens flare system is enabled.
  46498. */
  46499. isEnabled: boolean;
  46500. /**
  46501. * Get the scene the effects belongs to.
  46502. * @returns the scene holding the lens flare system
  46503. */
  46504. getScene(): Scene;
  46505. /**
  46506. * Get the emitter of the lens flare system.
  46507. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46508. * @returns the emitter of the lens flare system
  46509. */
  46510. getEmitter(): any;
  46511. /**
  46512. * Set the emitter of the lens flare system.
  46513. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46514. * @param newEmitter Define the new emitter of the system
  46515. */
  46516. setEmitter(newEmitter: any): void;
  46517. /**
  46518. * Get the lens flare system emitter position.
  46519. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46520. * @returns the position
  46521. */
  46522. getEmitterPosition(): Vector3;
  46523. /**
  46524. * @hidden
  46525. */
  46526. computeEffectivePosition(globalViewport: Viewport): boolean;
  46527. /** @hidden */
  46528. _isVisible(): boolean;
  46529. /**
  46530. * @hidden
  46531. */
  46532. render(): boolean;
  46533. /**
  46534. * Dispose and release the lens flare with its associated resources.
  46535. */
  46536. dispose(): void;
  46537. /**
  46538. * Parse a lens flare system from a JSON repressentation
  46539. * @param parsedLensFlareSystem Define the JSON to parse
  46540. * @param scene Define the scene the parsed system should be instantiated in
  46541. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46542. * @returns the parsed system
  46543. */
  46544. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46545. /**
  46546. * Serialize the current Lens Flare System into a JSON representation.
  46547. * @returns the serialized JSON
  46548. */
  46549. serialize(): any;
  46550. }
  46551. }
  46552. declare module "babylonjs/LensFlares/lensFlare" {
  46553. import { Nullable } from "babylonjs/types";
  46554. import { Color3 } from "babylonjs/Maths/math";
  46555. import { Texture } from "babylonjs/Materials/Textures/texture";
  46556. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46557. /**
  46558. * This represents one of the lens effect in a `lensFlareSystem`.
  46559. * It controls one of the indiviual texture used in the effect.
  46560. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46561. */
  46562. export class LensFlare {
  46563. /**
  46564. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46565. */
  46566. size: number;
  46567. /**
  46568. * 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.
  46569. */
  46570. position: number;
  46571. /**
  46572. * Define the lens color.
  46573. */
  46574. color: Color3;
  46575. /**
  46576. * Define the lens texture.
  46577. */
  46578. texture: Nullable<Texture>;
  46579. /**
  46580. * Define the alpha mode to render this particular lens.
  46581. */
  46582. alphaMode: number;
  46583. private _system;
  46584. /**
  46585. * Creates a new Lens Flare.
  46586. * This represents one of the lens effect in a `lensFlareSystem`.
  46587. * It controls one of the indiviual texture used in the effect.
  46588. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46589. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46590. * @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.
  46591. * @param color Define the lens color
  46592. * @param imgUrl Define the lens texture url
  46593. * @param system Define the `lensFlareSystem` this flare is part of
  46594. * @returns The newly created Lens Flare
  46595. */
  46596. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46597. /**
  46598. * Instantiates a new Lens Flare.
  46599. * This represents one of the lens effect in a `lensFlareSystem`.
  46600. * It controls one of the indiviual texture used in the effect.
  46601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46602. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46603. * @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.
  46604. * @param color Define the lens color
  46605. * @param imgUrl Define the lens texture url
  46606. * @param system Define the `lensFlareSystem` this flare is part of
  46607. */
  46608. constructor(
  46609. /**
  46610. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46611. */
  46612. size: number,
  46613. /**
  46614. * 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.
  46615. */
  46616. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46617. /**
  46618. * Dispose and release the lens flare with its associated resources.
  46619. */
  46620. dispose(): void;
  46621. }
  46622. }
  46623. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46624. import { Nullable } from "babylonjs/types";
  46625. import { Scene } from "babylonjs/scene";
  46626. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46627. import { AbstractScene } from "babylonjs/abstractScene";
  46628. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46629. module "babylonjs/abstractScene" {
  46630. interface AbstractScene {
  46631. /**
  46632. * The list of lens flare system added to the scene
  46633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46634. */
  46635. lensFlareSystems: Array<LensFlareSystem>;
  46636. /**
  46637. * Removes the given lens flare system from this scene.
  46638. * @param toRemove The lens flare system to remove
  46639. * @returns The index of the removed lens flare system
  46640. */
  46641. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46642. /**
  46643. * Adds the given lens flare system to this scene
  46644. * @param newLensFlareSystem The lens flare system to add
  46645. */
  46646. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46647. /**
  46648. * Gets a lens flare system using its name
  46649. * @param name defines the name to look for
  46650. * @returns the lens flare system or null if not found
  46651. */
  46652. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46653. /**
  46654. * Gets a lens flare system using its id
  46655. * @param id defines the id to look for
  46656. * @returns the lens flare system or null if not found
  46657. */
  46658. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46659. }
  46660. }
  46661. /**
  46662. * Defines the lens flare scene component responsible to manage any lens flares
  46663. * in a given scene.
  46664. */
  46665. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46666. /**
  46667. * The component name helpfull to identify the component in the list of scene components.
  46668. */
  46669. readonly name: string;
  46670. /**
  46671. * The scene the component belongs to.
  46672. */
  46673. scene: Scene;
  46674. /**
  46675. * Creates a new instance of the component for the given scene
  46676. * @param scene Defines the scene to register the component in
  46677. */
  46678. constructor(scene: Scene);
  46679. /**
  46680. * Registers the component in a given scene
  46681. */
  46682. register(): void;
  46683. /**
  46684. * Rebuilds the elements related to this component in case of
  46685. * context lost for instance.
  46686. */
  46687. rebuild(): void;
  46688. /**
  46689. * Adds all the element from the container to the scene
  46690. * @param container the container holding the elements
  46691. */
  46692. addFromContainer(container: AbstractScene): void;
  46693. /**
  46694. * Removes all the elements in the container from the scene
  46695. * @param container contains the elements to remove
  46696. */
  46697. removeFromContainer(container: AbstractScene): void;
  46698. /**
  46699. * Serializes the component data to the specified json object
  46700. * @param serializationObject The object to serialize to
  46701. */
  46702. serialize(serializationObject: any): void;
  46703. /**
  46704. * Disposes the component and the associated ressources.
  46705. */
  46706. dispose(): void;
  46707. private _draw;
  46708. }
  46709. }
  46710. declare module "babylonjs/LensFlares/index" {
  46711. export * from "babylonjs/LensFlares/lensFlare";
  46712. export * from "babylonjs/LensFlares/lensFlareSystem";
  46713. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46714. }
  46715. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46716. import { Scene } from "babylonjs/scene";
  46717. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46718. import { AbstractScene } from "babylonjs/abstractScene";
  46719. /**
  46720. * Defines the shadow generator component responsible to manage any shadow generators
  46721. * in a given scene.
  46722. */
  46723. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46724. /**
  46725. * The component name helpfull to identify the component in the list of scene components.
  46726. */
  46727. readonly name: string;
  46728. /**
  46729. * The scene the component belongs to.
  46730. */
  46731. scene: Scene;
  46732. /**
  46733. * Creates a new instance of the component for the given scene
  46734. * @param scene Defines the scene to register the component in
  46735. */
  46736. constructor(scene: Scene);
  46737. /**
  46738. * Registers the component in a given scene
  46739. */
  46740. register(): void;
  46741. /**
  46742. * Rebuilds the elements related to this component in case of
  46743. * context lost for instance.
  46744. */
  46745. rebuild(): void;
  46746. /**
  46747. * Serializes the component data to the specified json object
  46748. * @param serializationObject The object to serialize to
  46749. */
  46750. serialize(serializationObject: any): void;
  46751. /**
  46752. * Adds all the element from the container to the scene
  46753. * @param container the container holding the elements
  46754. */
  46755. addFromContainer(container: AbstractScene): void;
  46756. /**
  46757. * Removes all the elements in the container from the scene
  46758. * @param container contains the elements to remove
  46759. */
  46760. removeFromContainer(container: AbstractScene): void;
  46761. /**
  46762. * Rebuilds the elements related to this component in case of
  46763. * context lost for instance.
  46764. */
  46765. dispose(): void;
  46766. private _gatherRenderTargets;
  46767. }
  46768. }
  46769. declare module "babylonjs/Lights/Shadows/index" {
  46770. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46771. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46772. }
  46773. declare module "babylonjs/Lights/directionalLight" {
  46774. import { Camera } from "babylonjs/Cameras/camera";
  46775. import { Scene } from "babylonjs/scene";
  46776. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46778. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46779. import { Effect } from "babylonjs/Materials/effect";
  46780. /**
  46781. * A directional light is defined by a direction (what a surprise!).
  46782. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46783. * 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.
  46784. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46785. */
  46786. export class DirectionalLight extends ShadowLight {
  46787. private _shadowFrustumSize;
  46788. /**
  46789. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46790. */
  46791. /**
  46792. * Specifies a fix frustum size for the shadow generation.
  46793. */
  46794. shadowFrustumSize: number;
  46795. private _shadowOrthoScale;
  46796. /**
  46797. * Gets the shadow projection scale against the optimal computed one.
  46798. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46799. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46800. */
  46801. /**
  46802. * Sets the shadow projection scale against the optimal computed one.
  46803. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46804. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46805. */
  46806. shadowOrthoScale: number;
  46807. /**
  46808. * Automatically compute the projection matrix to best fit (including all the casters)
  46809. * on each frame.
  46810. */
  46811. autoUpdateExtends: boolean;
  46812. private _orthoLeft;
  46813. private _orthoRight;
  46814. private _orthoTop;
  46815. private _orthoBottom;
  46816. /**
  46817. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46818. * The directional light is emitted from everywhere in the given direction.
  46819. * It can cast shadows.
  46820. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46821. * @param name The friendly name of the light
  46822. * @param direction The direction of the light
  46823. * @param scene The scene the light belongs to
  46824. */
  46825. constructor(name: string, direction: Vector3, scene: Scene);
  46826. /**
  46827. * Returns the string "DirectionalLight".
  46828. * @return The class name
  46829. */
  46830. getClassName(): string;
  46831. /**
  46832. * Returns the integer 1.
  46833. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46834. */
  46835. getTypeID(): number;
  46836. /**
  46837. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46838. * Returns the DirectionalLight Shadow projection matrix.
  46839. */
  46840. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46841. /**
  46842. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46843. * Returns the DirectionalLight Shadow projection matrix.
  46844. */
  46845. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46846. /**
  46847. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46848. * Returns the DirectionalLight Shadow projection matrix.
  46849. */
  46850. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46851. protected _buildUniformLayout(): void;
  46852. /**
  46853. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46854. * @param effect The effect to update
  46855. * @param lightIndex The index of the light in the effect to update
  46856. * @returns The directional light
  46857. */
  46858. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46859. /**
  46860. * Gets the minZ used for shadow according to both the scene and the light.
  46861. *
  46862. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46863. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46864. * @param activeCamera The camera we are returning the min for
  46865. * @returns the depth min z
  46866. */
  46867. getDepthMinZ(activeCamera: Camera): number;
  46868. /**
  46869. * Gets the maxZ used for shadow according to both the scene and the light.
  46870. *
  46871. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46872. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46873. * @param activeCamera The camera we are returning the max for
  46874. * @returns the depth max z
  46875. */
  46876. getDepthMaxZ(activeCamera: Camera): number;
  46877. /**
  46878. * Prepares the list of defines specific to the light type.
  46879. * @param defines the list of defines
  46880. * @param lightIndex defines the index of the light for the effect
  46881. */
  46882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46883. }
  46884. }
  46885. declare module "babylonjs/Lights/pointLight" {
  46886. import { Scene } from "babylonjs/scene";
  46887. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46889. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46890. import { Effect } from "babylonjs/Materials/effect";
  46891. /**
  46892. * A point light is a light defined by an unique point in world space.
  46893. * The light is emitted in every direction from this point.
  46894. * A good example of a point light is a standard light bulb.
  46895. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46896. */
  46897. export class PointLight extends ShadowLight {
  46898. private _shadowAngle;
  46899. /**
  46900. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46901. * This specifies what angle the shadow will use to be created.
  46902. *
  46903. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46904. */
  46905. /**
  46906. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46907. * This specifies what angle the shadow will use to be created.
  46908. *
  46909. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46910. */
  46911. shadowAngle: number;
  46912. /**
  46913. * Gets the direction if it has been set.
  46914. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46915. */
  46916. /**
  46917. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46918. */
  46919. direction: Vector3;
  46920. /**
  46921. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46922. * A PointLight emits the light in every direction.
  46923. * It can cast shadows.
  46924. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46925. * ```javascript
  46926. * var pointLight = new PointLight("pl", camera.position, scene);
  46927. * ```
  46928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46929. * @param name The light friendly name
  46930. * @param position The position of the point light in the scene
  46931. * @param scene The scene the lights belongs to
  46932. */
  46933. constructor(name: string, position: Vector3, scene: Scene);
  46934. /**
  46935. * Returns the string "PointLight"
  46936. * @returns the class name
  46937. */
  46938. getClassName(): string;
  46939. /**
  46940. * Returns the integer 0.
  46941. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46942. */
  46943. getTypeID(): number;
  46944. /**
  46945. * Specifies wether or not the shadowmap should be a cube texture.
  46946. * @returns true if the shadowmap needs to be a cube texture.
  46947. */
  46948. needCube(): boolean;
  46949. /**
  46950. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46951. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46952. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46953. */
  46954. getShadowDirection(faceIndex?: number): Vector3;
  46955. /**
  46956. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46957. * - fov = PI / 2
  46958. * - aspect ratio : 1.0
  46959. * - z-near and far equal to the active camera minZ and maxZ.
  46960. * Returns the PointLight.
  46961. */
  46962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46963. protected _buildUniformLayout(): void;
  46964. /**
  46965. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46966. * @param effect The effect to update
  46967. * @param lightIndex The index of the light in the effect to update
  46968. * @returns The point light
  46969. */
  46970. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46971. /**
  46972. * Prepares the list of defines specific to the light type.
  46973. * @param defines the list of defines
  46974. * @param lightIndex defines the index of the light for the effect
  46975. */
  46976. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46977. }
  46978. }
  46979. declare module "babylonjs/Lights/spotLight" {
  46980. import { Nullable } from "babylonjs/types";
  46981. import { Scene } from "babylonjs/scene";
  46982. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46984. import { Effect } from "babylonjs/Materials/effect";
  46985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46986. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46987. /**
  46988. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46989. * These values define a cone of light starting from the position, emitting toward the direction.
  46990. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46991. * and the exponent defines the speed of the decay of the light with distance (reach).
  46992. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46993. */
  46994. export class SpotLight extends ShadowLight {
  46995. private _angle;
  46996. private _innerAngle;
  46997. private _cosHalfAngle;
  46998. private _lightAngleScale;
  46999. private _lightAngleOffset;
  47000. /**
  47001. * Gets the cone angle of the spot light in Radians.
  47002. */
  47003. /**
  47004. * Sets the cone angle of the spot light in Radians.
  47005. */
  47006. angle: number;
  47007. /**
  47008. * Only used in gltf falloff mode, this defines the angle where
  47009. * the directional falloff will start before cutting at angle which could be seen
  47010. * as outer angle.
  47011. */
  47012. /**
  47013. * Only used in gltf falloff mode, this defines the angle where
  47014. * the directional falloff will start before cutting at angle which could be seen
  47015. * as outer angle.
  47016. */
  47017. innerAngle: number;
  47018. private _shadowAngleScale;
  47019. /**
  47020. * Allows scaling the angle of the light for shadow generation only.
  47021. */
  47022. /**
  47023. * Allows scaling the angle of the light for shadow generation only.
  47024. */
  47025. shadowAngleScale: number;
  47026. /**
  47027. * The light decay speed with the distance from the emission spot.
  47028. */
  47029. exponent: number;
  47030. private _projectionTextureMatrix;
  47031. /**
  47032. * Allows reading the projecton texture
  47033. */
  47034. readonly projectionTextureMatrix: Matrix;
  47035. protected _projectionTextureLightNear: number;
  47036. /**
  47037. * Gets the near clip of the Spotlight for texture projection.
  47038. */
  47039. /**
  47040. * Sets the near clip of the Spotlight for texture projection.
  47041. */
  47042. projectionTextureLightNear: number;
  47043. protected _projectionTextureLightFar: number;
  47044. /**
  47045. * Gets the far clip of the Spotlight for texture projection.
  47046. */
  47047. /**
  47048. * Sets the far clip of the Spotlight for texture projection.
  47049. */
  47050. projectionTextureLightFar: number;
  47051. protected _projectionTextureUpDirection: Vector3;
  47052. /**
  47053. * Gets the Up vector of the Spotlight for texture projection.
  47054. */
  47055. /**
  47056. * Sets the Up vector of the Spotlight for texture projection.
  47057. */
  47058. projectionTextureUpDirection: Vector3;
  47059. private _projectionTexture;
  47060. /**
  47061. * Gets the projection texture of the light.
  47062. */
  47063. /**
  47064. * Sets the projection texture of the light.
  47065. */
  47066. projectionTexture: Nullable<BaseTexture>;
  47067. private _projectionTextureViewLightDirty;
  47068. private _projectionTextureProjectionLightDirty;
  47069. private _projectionTextureDirty;
  47070. private _projectionTextureViewTargetVector;
  47071. private _projectionTextureViewLightMatrix;
  47072. private _projectionTextureProjectionLightMatrix;
  47073. private _projectionTextureScalingMatrix;
  47074. /**
  47075. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47076. * It can cast shadows.
  47077. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47078. * @param name The light friendly name
  47079. * @param position The position of the spot light in the scene
  47080. * @param direction The direction of the light in the scene
  47081. * @param angle The cone angle of the light in Radians
  47082. * @param exponent The light decay speed with the distance from the emission spot
  47083. * @param scene The scene the lights belongs to
  47084. */
  47085. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47086. /**
  47087. * Returns the string "SpotLight".
  47088. * @returns the class name
  47089. */
  47090. getClassName(): string;
  47091. /**
  47092. * Returns the integer 2.
  47093. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47094. */
  47095. getTypeID(): number;
  47096. /**
  47097. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47098. */
  47099. protected _setDirection(value: Vector3): void;
  47100. /**
  47101. * Overrides the position setter to recompute the projection texture view light Matrix.
  47102. */
  47103. protected _setPosition(value: Vector3): void;
  47104. /**
  47105. * 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.
  47106. * Returns the SpotLight.
  47107. */
  47108. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47109. protected _computeProjectionTextureViewLightMatrix(): void;
  47110. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47111. /**
  47112. * Main function for light texture projection matrix computing.
  47113. */
  47114. protected _computeProjectionTextureMatrix(): void;
  47115. protected _buildUniformLayout(): void;
  47116. private _computeAngleValues;
  47117. /**
  47118. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47119. * @param effect The effect to update
  47120. * @param lightIndex The index of the light in the effect to update
  47121. * @returns The spot light
  47122. */
  47123. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47124. /**
  47125. * Disposes the light and the associated resources.
  47126. */
  47127. dispose(): void;
  47128. /**
  47129. * Prepares the list of defines specific to the light type.
  47130. * @param defines the list of defines
  47131. * @param lightIndex defines the index of the light for the effect
  47132. */
  47133. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47134. }
  47135. }
  47136. declare module "babylonjs/Lights/index" {
  47137. export * from "babylonjs/Lights/light";
  47138. export * from "babylonjs/Lights/shadowLight";
  47139. export * from "babylonjs/Lights/Shadows/index";
  47140. export * from "babylonjs/Lights/directionalLight";
  47141. export * from "babylonjs/Lights/hemisphericLight";
  47142. export * from "babylonjs/Lights/pointLight";
  47143. export * from "babylonjs/Lights/spotLight";
  47144. }
  47145. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47146. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47147. /**
  47148. * Header information of HDR texture files.
  47149. */
  47150. export interface HDRInfo {
  47151. /**
  47152. * The height of the texture in pixels.
  47153. */
  47154. height: number;
  47155. /**
  47156. * The width of the texture in pixels.
  47157. */
  47158. width: number;
  47159. /**
  47160. * The index of the beginning of the data in the binary file.
  47161. */
  47162. dataPosition: number;
  47163. }
  47164. /**
  47165. * This groups tools to convert HDR texture to native colors array.
  47166. */
  47167. export class HDRTools {
  47168. private static Ldexp;
  47169. private static Rgbe2float;
  47170. private static readStringLine;
  47171. /**
  47172. * Reads header information from an RGBE texture stored in a native array.
  47173. * More information on this format are available here:
  47174. * https://en.wikipedia.org/wiki/RGBE_image_format
  47175. *
  47176. * @param uint8array The binary file stored in native array.
  47177. * @return The header information.
  47178. */
  47179. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47180. /**
  47181. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47182. * This RGBE texture needs to store the information as a panorama.
  47183. *
  47184. * More information on this format are available here:
  47185. * https://en.wikipedia.org/wiki/RGBE_image_format
  47186. *
  47187. * @param buffer The binary file stored in an array buffer.
  47188. * @param size The expected size of the extracted cubemap.
  47189. * @return The Cube Map information.
  47190. */
  47191. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47192. /**
  47193. * Returns the pixels data extracted from an RGBE texture.
  47194. * This pixels will be stored left to right up to down in the R G B order in one array.
  47195. *
  47196. * More information on this format are available here:
  47197. * https://en.wikipedia.org/wiki/RGBE_image_format
  47198. *
  47199. * @param uint8array The binary file stored in an array buffer.
  47200. * @param hdrInfo The header information of the file.
  47201. * @return The pixels data in RGB right to left up to down order.
  47202. */
  47203. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47204. private static RGBE_ReadPixels_RLE;
  47205. }
  47206. }
  47207. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47208. import { Nullable } from "babylonjs/types";
  47209. import { Scene } from "babylonjs/scene";
  47210. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47212. /**
  47213. * This represents a texture coming from an HDR input.
  47214. *
  47215. * The only supported format is currently panorama picture stored in RGBE format.
  47216. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47217. */
  47218. export class HDRCubeTexture extends BaseTexture {
  47219. private static _facesMapping;
  47220. private _generateHarmonics;
  47221. private _noMipmap;
  47222. private _textureMatrix;
  47223. private _size;
  47224. private _onLoad;
  47225. private _onError;
  47226. /**
  47227. * The texture URL.
  47228. */
  47229. url: string;
  47230. /**
  47231. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47232. */
  47233. coordinatesMode: number;
  47234. protected _isBlocking: boolean;
  47235. /**
  47236. * Sets wether or not the texture is blocking during loading.
  47237. */
  47238. /**
  47239. * Gets wether or not the texture is blocking during loading.
  47240. */
  47241. isBlocking: boolean;
  47242. protected _rotationY: number;
  47243. /**
  47244. * Sets texture matrix rotation angle around Y axis in radians.
  47245. */
  47246. /**
  47247. * Gets texture matrix rotation angle around Y axis radians.
  47248. */
  47249. rotationY: number;
  47250. /**
  47251. * Gets or sets the center of the bounding box associated with the cube texture
  47252. * It must define where the camera used to render the texture was set
  47253. */
  47254. boundingBoxPosition: Vector3;
  47255. private _boundingBoxSize;
  47256. /**
  47257. * Gets or sets the size of the bounding box associated with the cube texture
  47258. * When defined, the cubemap will switch to local mode
  47259. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47260. * @example https://www.babylonjs-playground.com/#RNASML
  47261. */
  47262. boundingBoxSize: Vector3;
  47263. /**
  47264. * Instantiates an HDRTexture from the following parameters.
  47265. *
  47266. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47267. * @param scene The scene the texture will be used in
  47268. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47269. * @param noMipmap Forces to not generate the mipmap if true
  47270. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47271. * @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)
  47272. * @param reserved Reserved flag for internal use.
  47273. */
  47274. 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>);
  47275. /**
  47276. * Get the current class name of the texture useful for serialization or dynamic coding.
  47277. * @returns "HDRCubeTexture"
  47278. */
  47279. getClassName(): string;
  47280. /**
  47281. * Occurs when the file is raw .hdr file.
  47282. */
  47283. private loadTexture;
  47284. clone(): HDRCubeTexture;
  47285. delayLoad(): void;
  47286. /**
  47287. * Get the texture reflection matrix used to rotate/transform the reflection.
  47288. * @returns the reflection matrix
  47289. */
  47290. getReflectionTextureMatrix(): Matrix;
  47291. /**
  47292. * Set the texture reflection matrix used to rotate/transform the reflection.
  47293. * @param value Define the reflection matrix to set
  47294. */
  47295. setReflectionTextureMatrix(value: Matrix): void;
  47296. /**
  47297. * Parses a JSON representation of an HDR Texture in order to create the texture
  47298. * @param parsedTexture Define the JSON representation
  47299. * @param scene Define the scene the texture should be created in
  47300. * @param rootUrl Define the root url in case we need to load relative dependencies
  47301. * @returns the newly created texture after parsing
  47302. */
  47303. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47304. serialize(): any;
  47305. }
  47306. }
  47307. declare module "babylonjs/Physics/physicsEngine" {
  47308. import { Nullable } from "babylonjs/types";
  47309. import { Vector3 } from "babylonjs/Maths/math";
  47310. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47311. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47312. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47313. /**
  47314. * Class used to control physics engine
  47315. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47316. */
  47317. export class PhysicsEngine implements IPhysicsEngine {
  47318. private _physicsPlugin;
  47319. /**
  47320. * Global value used to control the smallest number supported by the simulation
  47321. */
  47322. static Epsilon: number;
  47323. private _impostors;
  47324. private _joints;
  47325. /**
  47326. * Gets the gravity vector used by the simulation
  47327. */
  47328. gravity: Vector3;
  47329. /**
  47330. * Factory used to create the default physics plugin.
  47331. * @returns The default physics plugin
  47332. */
  47333. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47334. /**
  47335. * Creates a new Physics Engine
  47336. * @param gravity defines the gravity vector used by the simulation
  47337. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47338. */
  47339. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47340. /**
  47341. * Sets the gravity vector used by the simulation
  47342. * @param gravity defines the gravity vector to use
  47343. */
  47344. setGravity(gravity: Vector3): void;
  47345. /**
  47346. * Set the time step of the physics engine.
  47347. * Default is 1/60.
  47348. * To slow it down, enter 1/600 for example.
  47349. * To speed it up, 1/30
  47350. * @param newTimeStep defines the new timestep to apply to this world.
  47351. */
  47352. setTimeStep(newTimeStep?: number): void;
  47353. /**
  47354. * Get the time step of the physics engine.
  47355. * @returns the current time step
  47356. */
  47357. getTimeStep(): number;
  47358. /**
  47359. * Release all resources
  47360. */
  47361. dispose(): void;
  47362. /**
  47363. * Gets the name of the current physics plugin
  47364. * @returns the name of the plugin
  47365. */
  47366. getPhysicsPluginName(): string;
  47367. /**
  47368. * Adding a new impostor for the impostor tracking.
  47369. * This will be done by the impostor itself.
  47370. * @param impostor the impostor to add
  47371. */
  47372. addImpostor(impostor: PhysicsImpostor): void;
  47373. /**
  47374. * Remove an impostor from the engine.
  47375. * This impostor and its mesh will not longer be updated by the physics engine.
  47376. * @param impostor the impostor to remove
  47377. */
  47378. removeImpostor(impostor: PhysicsImpostor): void;
  47379. /**
  47380. * Add a joint to the physics engine
  47381. * @param mainImpostor defines the main impostor to which the joint is added.
  47382. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47383. * @param joint defines the joint that will connect both impostors.
  47384. */
  47385. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47386. /**
  47387. * Removes a joint from the simulation
  47388. * @param mainImpostor defines the impostor used with the joint
  47389. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47390. * @param joint defines the joint to remove
  47391. */
  47392. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47393. /**
  47394. * Called by the scene. No need to call it.
  47395. * @param delta defines the timespam between frames
  47396. */
  47397. _step(delta: number): void;
  47398. /**
  47399. * Gets the current plugin used to run the simulation
  47400. * @returns current plugin
  47401. */
  47402. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47403. /**
  47404. * Gets the list of physic impostors
  47405. * @returns an array of PhysicsImpostor
  47406. */
  47407. getImpostors(): Array<PhysicsImpostor>;
  47408. /**
  47409. * Gets the impostor for a physics enabled object
  47410. * @param object defines the object impersonated by the impostor
  47411. * @returns the PhysicsImpostor or null if not found
  47412. */
  47413. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47414. /**
  47415. * Gets the impostor for a physics body object
  47416. * @param body defines physics body used by the impostor
  47417. * @returns the PhysicsImpostor or null if not found
  47418. */
  47419. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47420. }
  47421. }
  47422. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47423. import { Nullable } from "babylonjs/types";
  47424. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47426. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47427. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47428. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47429. /** @hidden */
  47430. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47431. private _useDeltaForWorldStep;
  47432. world: any;
  47433. name: string;
  47434. private _physicsMaterials;
  47435. private _fixedTimeStep;
  47436. BJSCANNON: any;
  47437. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47438. setGravity(gravity: Vector3): void;
  47439. setTimeStep(timeStep: number): void;
  47440. getTimeStep(): number;
  47441. executeStep(delta: number): void;
  47442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47445. private _processChildMeshes;
  47446. removePhysicsBody(impostor: PhysicsImpostor): void;
  47447. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47449. private _addMaterial;
  47450. private _checkWithEpsilon;
  47451. private _createShape;
  47452. private _createHeightmap;
  47453. private _minus90X;
  47454. private _plus90X;
  47455. private _tmpPosition;
  47456. private _tmpDeltaPosition;
  47457. private _tmpUnityRotation;
  47458. private _updatePhysicsBodyTransformation;
  47459. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47460. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47461. isSupported(): boolean;
  47462. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47463. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47464. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47465. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47466. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47467. getBodyMass(impostor: PhysicsImpostor): number;
  47468. getBodyFriction(impostor: PhysicsImpostor): number;
  47469. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47470. getBodyRestitution(impostor: PhysicsImpostor): number;
  47471. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47472. sleepBody(impostor: PhysicsImpostor): void;
  47473. wakeUpBody(impostor: PhysicsImpostor): void;
  47474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47475. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47476. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47477. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47478. getRadius(impostor: PhysicsImpostor): number;
  47479. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47480. dispose(): void;
  47481. private _extendNamespace;
  47482. }
  47483. }
  47484. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47485. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47486. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47487. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47489. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47490. import { Nullable } from "babylonjs/types";
  47491. /** @hidden */
  47492. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47493. world: any;
  47494. name: string;
  47495. BJSOIMO: any;
  47496. constructor(iterations?: number, oimoInjection?: any);
  47497. setGravity(gravity: Vector3): void;
  47498. setTimeStep(timeStep: number): void;
  47499. getTimeStep(): number;
  47500. private _tmpImpostorsArray;
  47501. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47503. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47504. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47505. private _tmpPositionVector;
  47506. removePhysicsBody(impostor: PhysicsImpostor): void;
  47507. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47508. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47509. isSupported(): boolean;
  47510. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47511. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47512. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47513. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47514. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47515. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47516. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47517. getBodyMass(impostor: PhysicsImpostor): number;
  47518. getBodyFriction(impostor: PhysicsImpostor): number;
  47519. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47520. getBodyRestitution(impostor: PhysicsImpostor): number;
  47521. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47522. sleepBody(impostor: PhysicsImpostor): void;
  47523. wakeUpBody(impostor: PhysicsImpostor): void;
  47524. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47525. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47526. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47527. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47528. getRadius(impostor: PhysicsImpostor): number;
  47529. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47530. dispose(): void;
  47531. }
  47532. }
  47533. declare module "babylonjs/Probes/reflectionProbe" {
  47534. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47535. import { Vector3 } from "babylonjs/Maths/math";
  47536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47537. import { Nullable } from "babylonjs/types";
  47538. import { Scene } from "babylonjs/scene";
  47539. module "babylonjs/abstractScene" {
  47540. interface AbstractScene {
  47541. /**
  47542. * The list of reflection probes added to the scene
  47543. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47544. */
  47545. reflectionProbes: Array<ReflectionProbe>;
  47546. /**
  47547. * Removes the given reflection probe from this scene.
  47548. * @param toRemove The reflection probe to remove
  47549. * @returns The index of the removed reflection probe
  47550. */
  47551. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47552. /**
  47553. * Adds the given reflection probe to this scene.
  47554. * @param newReflectionProbe The reflection probe to add
  47555. */
  47556. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47557. }
  47558. }
  47559. /**
  47560. * Class used to generate realtime reflection / refraction cube textures
  47561. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47562. */
  47563. export class ReflectionProbe {
  47564. /** defines the name of the probe */
  47565. name: string;
  47566. private _scene;
  47567. private _renderTargetTexture;
  47568. private _projectionMatrix;
  47569. private _viewMatrix;
  47570. private _target;
  47571. private _add;
  47572. private _attachedMesh;
  47573. private _invertYAxis;
  47574. /** Gets or sets probe position (center of the cube map) */
  47575. position: Vector3;
  47576. /**
  47577. * Creates a new reflection probe
  47578. * @param name defines the name of the probe
  47579. * @param size defines the texture resolution (for each face)
  47580. * @param scene defines the hosting scene
  47581. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47582. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47583. */
  47584. constructor(
  47585. /** defines the name of the probe */
  47586. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47587. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47588. samples: number;
  47589. /** Gets or sets the refresh rate to use (on every frame by default) */
  47590. refreshRate: number;
  47591. /**
  47592. * Gets the hosting scene
  47593. * @returns a Scene
  47594. */
  47595. getScene(): Scene;
  47596. /** Gets the internal CubeTexture used to render to */
  47597. readonly cubeTexture: RenderTargetTexture;
  47598. /** Gets the list of meshes to render */
  47599. readonly renderList: Nullable<AbstractMesh[]>;
  47600. /**
  47601. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47602. * @param mesh defines the mesh to attach to
  47603. */
  47604. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47605. /**
  47606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47607. * @param renderingGroupId The rendering group id corresponding to its index
  47608. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47609. */
  47610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47611. /**
  47612. * Clean all associated resources
  47613. */
  47614. dispose(): void;
  47615. /**
  47616. * Converts the reflection probe information to a readable string for debug purpose.
  47617. * @param fullDetails Supports for multiple levels of logging within scene loading
  47618. * @returns the human readable reflection probe info
  47619. */
  47620. toString(fullDetails?: boolean): string;
  47621. /**
  47622. * Get the class name of the relfection probe.
  47623. * @returns "ReflectionProbe"
  47624. */
  47625. getClassName(): string;
  47626. /**
  47627. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47628. * @returns The JSON representation of the texture
  47629. */
  47630. serialize(): any;
  47631. /**
  47632. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47633. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47634. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47635. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47636. * @returns The parsed reflection probe if successful
  47637. */
  47638. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47639. }
  47640. }
  47641. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47642. /** @hidden */
  47643. export var _BabylonLoaderRegistered: boolean;
  47644. }
  47645. declare module "babylonjs/Loading/Plugins/index" {
  47646. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47647. }
  47648. declare module "babylonjs/Loading/index" {
  47649. export * from "babylonjs/Loading/loadingScreen";
  47650. export * from "babylonjs/Loading/Plugins/index";
  47651. export * from "babylonjs/Loading/sceneLoader";
  47652. export * from "babylonjs/Loading/sceneLoaderFlags";
  47653. }
  47654. declare module "babylonjs/Materials/Background/index" {
  47655. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47656. }
  47657. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47658. import { Scene } from "babylonjs/scene";
  47659. import { Color3 } from "babylonjs/Maths/math";
  47660. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47662. /**
  47663. * The Physically based simple base material of BJS.
  47664. *
  47665. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47666. * It is used as the base class for both the specGloss and metalRough conventions.
  47667. */
  47668. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47669. /**
  47670. * Number of Simultaneous lights allowed on the material.
  47671. */
  47672. maxSimultaneousLights: number;
  47673. /**
  47674. * If sets to true, disables all the lights affecting the material.
  47675. */
  47676. disableLighting: boolean;
  47677. /**
  47678. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47679. */
  47680. environmentTexture: BaseTexture;
  47681. /**
  47682. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47683. */
  47684. invertNormalMapX: boolean;
  47685. /**
  47686. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47687. */
  47688. invertNormalMapY: boolean;
  47689. /**
  47690. * Normal map used in the model.
  47691. */
  47692. normalTexture: BaseTexture;
  47693. /**
  47694. * Emissivie color used to self-illuminate the model.
  47695. */
  47696. emissiveColor: Color3;
  47697. /**
  47698. * Emissivie texture used to self-illuminate the model.
  47699. */
  47700. emissiveTexture: BaseTexture;
  47701. /**
  47702. * Occlusion Channel Strenght.
  47703. */
  47704. occlusionStrength: number;
  47705. /**
  47706. * Occlusion Texture of the material (adding extra occlusion effects).
  47707. */
  47708. occlusionTexture: BaseTexture;
  47709. /**
  47710. * Defines the alpha limits in alpha test mode.
  47711. */
  47712. alphaCutOff: number;
  47713. /**
  47714. * Gets the current double sided mode.
  47715. */
  47716. /**
  47717. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47718. */
  47719. doubleSided: boolean;
  47720. /**
  47721. * Stores the pre-calculated light information of a mesh in a texture.
  47722. */
  47723. lightmapTexture: BaseTexture;
  47724. /**
  47725. * If true, the light map contains occlusion information instead of lighting info.
  47726. */
  47727. useLightmapAsShadowmap: boolean;
  47728. /**
  47729. * Instantiates a new PBRMaterial instance.
  47730. *
  47731. * @param name The material name
  47732. * @param scene The scene the material will be use in.
  47733. */
  47734. constructor(name: string, scene: Scene);
  47735. getClassName(): string;
  47736. }
  47737. }
  47738. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47739. import { Scene } from "babylonjs/scene";
  47740. import { Color3 } from "babylonjs/Maths/math";
  47741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47742. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47743. /**
  47744. * The PBR material of BJS following the metal roughness convention.
  47745. *
  47746. * This fits to the PBR convention in the GLTF definition:
  47747. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47748. */
  47749. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47750. /**
  47751. * The base color has two different interpretations depending on the value of metalness.
  47752. * When the material is a metal, the base color is the specific measured reflectance value
  47753. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47754. * of the material.
  47755. */
  47756. baseColor: Color3;
  47757. /**
  47758. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47759. * well as opacity information in the alpha channel.
  47760. */
  47761. baseTexture: BaseTexture;
  47762. /**
  47763. * Specifies the metallic scalar value of the material.
  47764. * Can also be used to scale the metalness values of the metallic texture.
  47765. */
  47766. metallic: number;
  47767. /**
  47768. * Specifies the roughness scalar value of the material.
  47769. * Can also be used to scale the roughness values of the metallic texture.
  47770. */
  47771. roughness: number;
  47772. /**
  47773. * Texture containing both the metallic value in the B channel and the
  47774. * roughness value in the G channel to keep better precision.
  47775. */
  47776. metallicRoughnessTexture: BaseTexture;
  47777. /**
  47778. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47779. *
  47780. * @param name The material name
  47781. * @param scene The scene the material will be use in.
  47782. */
  47783. constructor(name: string, scene: Scene);
  47784. /**
  47785. * Return the currrent class name of the material.
  47786. */
  47787. getClassName(): string;
  47788. /**
  47789. * Makes a duplicate of the current material.
  47790. * @param name - name to use for the new material.
  47791. */
  47792. clone(name: string): PBRMetallicRoughnessMaterial;
  47793. /**
  47794. * Serialize the material to a parsable JSON object.
  47795. */
  47796. serialize(): any;
  47797. /**
  47798. * Parses a JSON object correponding to the serialize function.
  47799. */
  47800. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47801. }
  47802. }
  47803. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47804. import { Scene } from "babylonjs/scene";
  47805. import { Color3 } from "babylonjs/Maths/math";
  47806. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47807. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47808. /**
  47809. * The PBR material of BJS following the specular glossiness convention.
  47810. *
  47811. * This fits to the PBR convention in the GLTF definition:
  47812. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47813. */
  47814. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47815. /**
  47816. * Specifies the diffuse color of the material.
  47817. */
  47818. diffuseColor: Color3;
  47819. /**
  47820. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47821. * channel.
  47822. */
  47823. diffuseTexture: BaseTexture;
  47824. /**
  47825. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47826. */
  47827. specularColor: Color3;
  47828. /**
  47829. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47830. */
  47831. glossiness: number;
  47832. /**
  47833. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47834. */
  47835. specularGlossinessTexture: BaseTexture;
  47836. /**
  47837. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47838. *
  47839. * @param name The material name
  47840. * @param scene The scene the material will be use in.
  47841. */
  47842. constructor(name: string, scene: Scene);
  47843. /**
  47844. * Return the currrent class name of the material.
  47845. */
  47846. getClassName(): string;
  47847. /**
  47848. * Makes a duplicate of the current material.
  47849. * @param name - name to use for the new material.
  47850. */
  47851. clone(name: string): PBRSpecularGlossinessMaterial;
  47852. /**
  47853. * Serialize the material to a parsable JSON object.
  47854. */
  47855. serialize(): any;
  47856. /**
  47857. * Parses a JSON object correponding to the serialize function.
  47858. */
  47859. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47860. }
  47861. }
  47862. declare module "babylonjs/Materials/PBR/index" {
  47863. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47864. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47865. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47866. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47867. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47868. }
  47869. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47870. import { Nullable } from "babylonjs/types";
  47871. import { Scene } from "babylonjs/scene";
  47872. import { Matrix } from "babylonjs/Maths/math";
  47873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47874. /**
  47875. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47876. * It can help converting any input color in a desired output one. This can then be used to create effects
  47877. * from sepia, black and white to sixties or futuristic rendering...
  47878. *
  47879. * The only supported format is currently 3dl.
  47880. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47881. */
  47882. export class ColorGradingTexture extends BaseTexture {
  47883. /**
  47884. * The current texture matrix. (will always be identity in color grading texture)
  47885. */
  47886. private _textureMatrix;
  47887. /**
  47888. * The texture URL.
  47889. */
  47890. url: string;
  47891. /**
  47892. * Empty line regex stored for GC.
  47893. */
  47894. private static _noneEmptyLineRegex;
  47895. private _engine;
  47896. /**
  47897. * Instantiates a ColorGradingTexture from the following parameters.
  47898. *
  47899. * @param url The location of the color gradind data (currently only supporting 3dl)
  47900. * @param scene The scene the texture will be used in
  47901. */
  47902. constructor(url: string, scene: Scene);
  47903. /**
  47904. * Returns the texture matrix used in most of the material.
  47905. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47906. */
  47907. getTextureMatrix(): Matrix;
  47908. /**
  47909. * Occurs when the file being loaded is a .3dl LUT file.
  47910. */
  47911. private load3dlTexture;
  47912. /**
  47913. * Starts the loading process of the texture.
  47914. */
  47915. private loadTexture;
  47916. /**
  47917. * Clones the color gradind texture.
  47918. */
  47919. clone(): ColorGradingTexture;
  47920. /**
  47921. * Called during delayed load for textures.
  47922. */
  47923. delayLoad(): void;
  47924. /**
  47925. * Parses a color grading texture serialized by Babylon.
  47926. * @param parsedTexture The texture information being parsedTexture
  47927. * @param scene The scene to load the texture in
  47928. * @param rootUrl The root url of the data assets to load
  47929. * @return A color gradind texture
  47930. */
  47931. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47932. /**
  47933. * Serializes the LUT texture to json format.
  47934. */
  47935. serialize(): any;
  47936. }
  47937. }
  47938. declare module "babylonjs/Misc/dds" {
  47939. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47940. import { Engine } from "babylonjs/Engines/engine";
  47941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47942. import { Nullable } from "babylonjs/types";
  47943. import { Scene } from "babylonjs/scene";
  47944. /**
  47945. * Direct draw surface info
  47946. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47947. */
  47948. export interface DDSInfo {
  47949. /**
  47950. * Width of the texture
  47951. */
  47952. width: number;
  47953. /**
  47954. * Width of the texture
  47955. */
  47956. height: number;
  47957. /**
  47958. * Number of Mipmaps for the texture
  47959. * @see https://en.wikipedia.org/wiki/Mipmap
  47960. */
  47961. mipmapCount: number;
  47962. /**
  47963. * If the textures format is a known fourCC format
  47964. * @see https://www.fourcc.org/
  47965. */
  47966. isFourCC: boolean;
  47967. /**
  47968. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47969. */
  47970. isRGB: boolean;
  47971. /**
  47972. * If the texture is a lumincance format
  47973. */
  47974. isLuminance: boolean;
  47975. /**
  47976. * If this is a cube texture
  47977. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47978. */
  47979. isCube: boolean;
  47980. /**
  47981. * If the texture is a compressed format eg. FOURCC_DXT1
  47982. */
  47983. isCompressed: boolean;
  47984. /**
  47985. * The dxgiFormat of the texture
  47986. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47987. */
  47988. dxgiFormat: number;
  47989. /**
  47990. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47991. */
  47992. textureType: number;
  47993. /**
  47994. * Sphericle polynomial created for the dds texture
  47995. */
  47996. sphericalPolynomial?: SphericalPolynomial;
  47997. }
  47998. /**
  47999. * Class used to provide DDS decompression tools
  48000. */
  48001. export class DDSTools {
  48002. /**
  48003. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48004. */
  48005. static StoreLODInAlphaChannel: boolean;
  48006. /**
  48007. * Gets DDS information from an array buffer
  48008. * @param arrayBuffer defines the array buffer to read data from
  48009. * @returns the DDS information
  48010. */
  48011. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48012. private static _FloatView;
  48013. private static _Int32View;
  48014. private static _ToHalfFloat;
  48015. private static _FromHalfFloat;
  48016. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48017. private static _GetHalfFloatRGBAArrayBuffer;
  48018. private static _GetFloatRGBAArrayBuffer;
  48019. private static _GetFloatAsUIntRGBAArrayBuffer;
  48020. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48021. private static _GetRGBAArrayBuffer;
  48022. private static _ExtractLongWordOrder;
  48023. private static _GetRGBArrayBuffer;
  48024. private static _GetLuminanceArrayBuffer;
  48025. /**
  48026. * Uploads DDS Levels to a Babylon Texture
  48027. * @hidden
  48028. */
  48029. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48030. }
  48031. module "babylonjs/Engines/engine" {
  48032. interface Engine {
  48033. /**
  48034. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48035. * @param rootUrl defines the url where the file to load is located
  48036. * @param scene defines the current scene
  48037. * @param lodScale defines scale to apply to the mip map selection
  48038. * @param lodOffset defines offset to apply to the mip map selection
  48039. * @param onLoad defines an optional callback raised when the texture is loaded
  48040. * @param onError defines an optional callback raised if there is an issue to load the texture
  48041. * @param format defines the format of the data
  48042. * @param forcedExtension defines the extension to use to pick the right loader
  48043. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48044. * @returns the cube texture as an InternalTexture
  48045. */
  48046. 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;
  48047. }
  48048. }
  48049. }
  48050. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48051. import { Nullable } from "babylonjs/types";
  48052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48053. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48054. /**
  48055. * Implementation of the DDS Texture Loader.
  48056. * @hidden
  48057. */
  48058. export class _DDSTextureLoader implements IInternalTextureLoader {
  48059. /**
  48060. * Defines wether the loader supports cascade loading the different faces.
  48061. */
  48062. readonly supportCascades: boolean;
  48063. /**
  48064. * This returns if the loader support the current file information.
  48065. * @param extension defines the file extension of the file being loaded
  48066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48067. * @param fallback defines the fallback internal texture if any
  48068. * @param isBase64 defines whether the texture is encoded as a base64
  48069. * @param isBuffer defines whether the texture data are stored as a buffer
  48070. * @returns true if the loader can load the specified file
  48071. */
  48072. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48073. /**
  48074. * Transform the url before loading if required.
  48075. * @param rootUrl the url of the texture
  48076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48077. * @returns the transformed texture
  48078. */
  48079. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48080. /**
  48081. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48082. * @param rootUrl the url of the texture
  48083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48084. * @returns the fallback texture
  48085. */
  48086. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48087. /**
  48088. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48089. * @param data contains the texture data
  48090. * @param texture defines the BabylonJS internal texture
  48091. * @param createPolynomials will be true if polynomials have been requested
  48092. * @param onLoad defines the callback to trigger once the texture is ready
  48093. * @param onError defines the callback to trigger in case of error
  48094. */
  48095. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48096. /**
  48097. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48098. * @param data contains the texture data
  48099. * @param texture defines the BabylonJS internal texture
  48100. * @param callback defines the method to call once ready to upload
  48101. */
  48102. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48103. }
  48104. }
  48105. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48107. /** @hidden */
  48108. export var rgbdEncodePixelShader: {
  48109. name: string;
  48110. shader: string;
  48111. };
  48112. }
  48113. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48114. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48115. /** @hidden */
  48116. export var rgbdDecodePixelShader: {
  48117. name: string;
  48118. shader: string;
  48119. };
  48120. }
  48121. declare module "babylonjs/Misc/environmentTextureTools" {
  48122. import { Nullable } from "babylonjs/types";
  48123. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48125. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48126. import "babylonjs/Shaders/rgbdEncode.fragment";
  48127. import "babylonjs/Shaders/rgbdDecode.fragment";
  48128. /**
  48129. * Raw texture data and descriptor sufficient for WebGL texture upload
  48130. */
  48131. export interface EnvironmentTextureInfo {
  48132. /**
  48133. * Version of the environment map
  48134. */
  48135. version: number;
  48136. /**
  48137. * Width of image
  48138. */
  48139. width: number;
  48140. /**
  48141. * Irradiance information stored in the file.
  48142. */
  48143. irradiance: any;
  48144. /**
  48145. * Specular information stored in the file.
  48146. */
  48147. specular: any;
  48148. }
  48149. /**
  48150. * Sets of helpers addressing the serialization and deserialization of environment texture
  48151. * stored in a BabylonJS env file.
  48152. * Those files are usually stored as .env files.
  48153. */
  48154. export class EnvironmentTextureTools {
  48155. /**
  48156. * Magic number identifying the env file.
  48157. */
  48158. private static _MagicBytes;
  48159. /**
  48160. * Gets the environment info from an env file.
  48161. * @param data The array buffer containing the .env bytes.
  48162. * @returns the environment file info (the json header) if successfully parsed.
  48163. */
  48164. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48165. /**
  48166. * Creates an environment texture from a loaded cube texture.
  48167. * @param texture defines the cube texture to convert in env file
  48168. * @return a promise containing the environment data if succesfull.
  48169. */
  48170. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48171. /**
  48172. * Creates a JSON representation of the spherical data.
  48173. * @param texture defines the texture containing the polynomials
  48174. * @return the JSON representation of the spherical info
  48175. */
  48176. private static _CreateEnvTextureIrradiance;
  48177. /**
  48178. * Uploads the texture info contained in the env file to the GPU.
  48179. * @param texture defines the internal texture to upload to
  48180. * @param arrayBuffer defines the buffer cotaining the data to load
  48181. * @param info defines the texture info retrieved through the GetEnvInfo method
  48182. * @returns a promise
  48183. */
  48184. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48185. /**
  48186. * Uploads the levels of image data to the GPU.
  48187. * @param texture defines the internal texture to upload to
  48188. * @param imageData defines the array buffer views of image data [mipmap][face]
  48189. * @returns a promise
  48190. */
  48191. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48192. /**
  48193. * Uploads spherical polynomials information to the texture.
  48194. * @param texture defines the texture we are trying to upload the information to
  48195. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48196. */
  48197. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48198. /** @hidden */
  48199. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48200. }
  48201. }
  48202. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48203. import { Nullable } from "babylonjs/types";
  48204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48205. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48206. /**
  48207. * Implementation of the ENV Texture Loader.
  48208. * @hidden
  48209. */
  48210. export class _ENVTextureLoader implements IInternalTextureLoader {
  48211. /**
  48212. * Defines wether the loader supports cascade loading the different faces.
  48213. */
  48214. readonly supportCascades: boolean;
  48215. /**
  48216. * This returns if the loader support the current file information.
  48217. * @param extension defines the file extension of the file being loaded
  48218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48219. * @param fallback defines the fallback internal texture if any
  48220. * @param isBase64 defines whether the texture is encoded as a base64
  48221. * @param isBuffer defines whether the texture data are stored as a buffer
  48222. * @returns true if the loader can load the specified file
  48223. */
  48224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48225. /**
  48226. * Transform the url before loading if required.
  48227. * @param rootUrl the url of the texture
  48228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48229. * @returns the transformed texture
  48230. */
  48231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48232. /**
  48233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48234. * @param rootUrl the url of the texture
  48235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48236. * @returns the fallback texture
  48237. */
  48238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48239. /**
  48240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48241. * @param data contains the texture data
  48242. * @param texture defines the BabylonJS internal texture
  48243. * @param createPolynomials will be true if polynomials have been requested
  48244. * @param onLoad defines the callback to trigger once the texture is ready
  48245. * @param onError defines the callback to trigger in case of error
  48246. */
  48247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48248. /**
  48249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48250. * @param data contains the texture data
  48251. * @param texture defines the BabylonJS internal texture
  48252. * @param callback defines the method to call once ready to upload
  48253. */
  48254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48255. }
  48256. }
  48257. declare module "babylonjs/Misc/khronosTextureContainer" {
  48258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48259. /**
  48260. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48261. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48262. */
  48263. export class KhronosTextureContainer {
  48264. /** contents of the KTX container file */
  48265. arrayBuffer: any;
  48266. private static HEADER_LEN;
  48267. private static COMPRESSED_2D;
  48268. private static COMPRESSED_3D;
  48269. private static TEX_2D;
  48270. private static TEX_3D;
  48271. /**
  48272. * Gets the openGL type
  48273. */
  48274. glType: number;
  48275. /**
  48276. * Gets the openGL type size
  48277. */
  48278. glTypeSize: number;
  48279. /**
  48280. * Gets the openGL format
  48281. */
  48282. glFormat: number;
  48283. /**
  48284. * Gets the openGL internal format
  48285. */
  48286. glInternalFormat: number;
  48287. /**
  48288. * Gets the base internal format
  48289. */
  48290. glBaseInternalFormat: number;
  48291. /**
  48292. * Gets image width in pixel
  48293. */
  48294. pixelWidth: number;
  48295. /**
  48296. * Gets image height in pixel
  48297. */
  48298. pixelHeight: number;
  48299. /**
  48300. * Gets image depth in pixels
  48301. */
  48302. pixelDepth: number;
  48303. /**
  48304. * Gets the number of array elements
  48305. */
  48306. numberOfArrayElements: number;
  48307. /**
  48308. * Gets the number of faces
  48309. */
  48310. numberOfFaces: number;
  48311. /**
  48312. * Gets the number of mipmap levels
  48313. */
  48314. numberOfMipmapLevels: number;
  48315. /**
  48316. * Gets the bytes of key value data
  48317. */
  48318. bytesOfKeyValueData: number;
  48319. /**
  48320. * Gets the load type
  48321. */
  48322. loadType: number;
  48323. /**
  48324. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48325. */
  48326. isInvalid: boolean;
  48327. /**
  48328. * Creates a new KhronosTextureContainer
  48329. * @param arrayBuffer contents of the KTX container file
  48330. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48331. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48332. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48333. */
  48334. constructor(
  48335. /** contents of the KTX container file */
  48336. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48337. /**
  48338. * Uploads KTX content to a Babylon Texture.
  48339. * It is assumed that the texture has already been created & is currently bound
  48340. * @hidden
  48341. */
  48342. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48343. private _upload2DCompressedLevels;
  48344. }
  48345. }
  48346. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48347. import { Nullable } from "babylonjs/types";
  48348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48349. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48350. /**
  48351. * Implementation of the KTX Texture Loader.
  48352. * @hidden
  48353. */
  48354. export class _KTXTextureLoader implements IInternalTextureLoader {
  48355. /**
  48356. * Defines wether the loader supports cascade loading the different faces.
  48357. */
  48358. readonly supportCascades: boolean;
  48359. /**
  48360. * This returns if the loader support the current file information.
  48361. * @param extension defines the file extension of the file being loaded
  48362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48363. * @param fallback defines the fallback internal texture if any
  48364. * @param isBase64 defines whether the texture is encoded as a base64
  48365. * @param isBuffer defines whether the texture data are stored as a buffer
  48366. * @returns true if the loader can load the specified file
  48367. */
  48368. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48369. /**
  48370. * Transform the url before loading if required.
  48371. * @param rootUrl the url of the texture
  48372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48373. * @returns the transformed texture
  48374. */
  48375. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48376. /**
  48377. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48378. * @param rootUrl the url of the texture
  48379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48380. * @returns the fallback texture
  48381. */
  48382. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48383. /**
  48384. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48385. * @param data contains the texture data
  48386. * @param texture defines the BabylonJS internal texture
  48387. * @param createPolynomials will be true if polynomials have been requested
  48388. * @param onLoad defines the callback to trigger once the texture is ready
  48389. * @param onError defines the callback to trigger in case of error
  48390. */
  48391. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48392. /**
  48393. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48394. * @param data contains the texture data
  48395. * @param texture defines the BabylonJS internal texture
  48396. * @param callback defines the method to call once ready to upload
  48397. */
  48398. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48399. }
  48400. }
  48401. declare module "babylonjs/Misc/tga" {
  48402. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48403. /**
  48404. * Based on jsTGALoader - Javascript loader for TGA file
  48405. * By Vincent Thibault
  48406. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48407. */
  48408. export class TGATools {
  48409. private static _TYPE_INDEXED;
  48410. private static _TYPE_RGB;
  48411. private static _TYPE_GREY;
  48412. private static _TYPE_RLE_INDEXED;
  48413. private static _TYPE_RLE_RGB;
  48414. private static _TYPE_RLE_GREY;
  48415. private static _ORIGIN_MASK;
  48416. private static _ORIGIN_SHIFT;
  48417. private static _ORIGIN_BL;
  48418. private static _ORIGIN_BR;
  48419. private static _ORIGIN_UL;
  48420. private static _ORIGIN_UR;
  48421. /**
  48422. * Gets the header of a TGA file
  48423. * @param data defines the TGA data
  48424. * @returns the header
  48425. */
  48426. static GetTGAHeader(data: Uint8Array): any;
  48427. /**
  48428. * Uploads TGA content to a Babylon Texture
  48429. * @hidden
  48430. */
  48431. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48432. /** @hidden */
  48433. 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;
  48434. /** @hidden */
  48435. 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;
  48436. /** @hidden */
  48437. 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;
  48438. /** @hidden */
  48439. 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;
  48440. /** @hidden */
  48441. 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;
  48442. /** @hidden */
  48443. 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;
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48449. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48450. /**
  48451. * Implementation of the TGA Texture Loader.
  48452. * @hidden
  48453. */
  48454. export class _TGATextureLoader implements IInternalTextureLoader {
  48455. /**
  48456. * Defines wether the loader supports cascade loading the different faces.
  48457. */
  48458. readonly supportCascades: boolean;
  48459. /**
  48460. * This returns if the loader support the current file information.
  48461. * @param extension defines the file extension of the file being loaded
  48462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48463. * @param fallback defines the fallback internal texture if any
  48464. * @param isBase64 defines whether the texture is encoded as a base64
  48465. * @param isBuffer defines whether the texture data are stored as a buffer
  48466. * @returns true if the loader can load the specified file
  48467. */
  48468. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48469. /**
  48470. * Transform the url before loading if required.
  48471. * @param rootUrl the url of the texture
  48472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48473. * @returns the transformed texture
  48474. */
  48475. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48476. /**
  48477. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48478. * @param rootUrl the url of the texture
  48479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48480. * @returns the fallback texture
  48481. */
  48482. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48483. /**
  48484. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48485. * @param data contains the texture data
  48486. * @param texture defines the BabylonJS internal texture
  48487. * @param createPolynomials will be true if polynomials have been requested
  48488. * @param onLoad defines the callback to trigger once the texture is ready
  48489. * @param onError defines the callback to trigger in case of error
  48490. */
  48491. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48492. /**
  48493. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48494. * @param data contains the texture data
  48495. * @param texture defines the BabylonJS internal texture
  48496. * @param callback defines the method to call once ready to upload
  48497. */
  48498. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48499. }
  48500. }
  48501. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48502. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48503. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48504. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48505. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48506. }
  48507. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48508. import { Scene } from "babylonjs/scene";
  48509. import { Texture } from "babylonjs/Materials/Textures/texture";
  48510. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48511. /**
  48512. * 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.
  48513. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48514. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48515. */
  48516. export class CustomProceduralTexture extends ProceduralTexture {
  48517. private _animate;
  48518. private _time;
  48519. private _config;
  48520. private _texturePath;
  48521. /**
  48522. * Instantiates a new Custom Procedural Texture.
  48523. * 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.
  48524. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48525. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48526. * @param name Define the name of the texture
  48527. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48528. * @param size Define the size of the texture to create
  48529. * @param scene Define the scene the texture belongs to
  48530. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48531. * @param generateMipMaps Define if the texture should creates mip maps or not
  48532. */
  48533. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48534. private _loadJson;
  48535. /**
  48536. * Is the texture ready to be used ? (rendered at least once)
  48537. * @returns true if ready, otherwise, false.
  48538. */
  48539. isReady(): boolean;
  48540. /**
  48541. * Render the texture to its associated render target.
  48542. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48543. */
  48544. render(useCameraPostProcess?: boolean): void;
  48545. /**
  48546. * Update the list of dependant textures samplers in the shader.
  48547. */
  48548. updateTextures(): void;
  48549. /**
  48550. * Update the uniform values of the procedural texture in the shader.
  48551. */
  48552. updateShaderUniforms(): void;
  48553. /**
  48554. * Define if the texture animates or not.
  48555. */
  48556. animate: boolean;
  48557. }
  48558. }
  48559. declare module "babylonjs/Shaders/noise.fragment" {
  48560. /** @hidden */
  48561. export var noisePixelShader: {
  48562. name: string;
  48563. shader: string;
  48564. };
  48565. }
  48566. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48567. import { Nullable } from "babylonjs/types";
  48568. import { Scene } from "babylonjs/scene";
  48569. import { Texture } from "babylonjs/Materials/Textures/texture";
  48570. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48571. import "babylonjs/Shaders/noise.fragment";
  48572. /**
  48573. * Class used to generate noise procedural textures
  48574. */
  48575. export class NoiseProceduralTexture extends ProceduralTexture {
  48576. private _time;
  48577. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48578. brightness: number;
  48579. /** Defines the number of octaves to process */
  48580. octaves: number;
  48581. /** Defines the level of persistence (0.8 by default) */
  48582. persistence: number;
  48583. /** Gets or sets animation speed factor (default is 1) */
  48584. animationSpeedFactor: number;
  48585. /**
  48586. * Creates a new NoiseProceduralTexture
  48587. * @param name defines the name fo the texture
  48588. * @param size defines the size of the texture (default is 256)
  48589. * @param scene defines the hosting scene
  48590. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48591. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48592. */
  48593. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48594. private _updateShaderUniforms;
  48595. protected _getDefines(): string;
  48596. /** Generate the current state of the procedural texture */
  48597. render(useCameraPostProcess?: boolean): void;
  48598. /**
  48599. * Serializes this noise procedural texture
  48600. * @returns a serialized noise procedural texture object
  48601. */
  48602. serialize(): any;
  48603. /**
  48604. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48605. * @param parsedTexture defines parsed texture data
  48606. * @param scene defines the current scene
  48607. * @param rootUrl defines the root URL containing noise procedural texture information
  48608. * @returns a parsed NoiseProceduralTexture
  48609. */
  48610. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48611. }
  48612. }
  48613. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48614. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48615. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48616. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48617. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48618. }
  48619. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48620. import { Nullable } from "babylonjs/types";
  48621. import { Scene } from "babylonjs/scene";
  48622. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48624. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48625. /**
  48626. * Raw cube texture where the raw buffers are passed in
  48627. */
  48628. export class RawCubeTexture extends CubeTexture {
  48629. /**
  48630. * Creates a cube texture where the raw buffers are passed in.
  48631. * @param scene defines the scene the texture is attached to
  48632. * @param data defines the array of data to use to create each face
  48633. * @param size defines the size of the textures
  48634. * @param format defines the format of the data
  48635. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48636. * @param generateMipMaps defines if the engine should generate the mip levels
  48637. * @param invertY defines if data must be stored with Y axis inverted
  48638. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48639. * @param compression defines the compression used (null by default)
  48640. */
  48641. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48642. /**
  48643. * Updates the raw cube texture.
  48644. * @param data defines the data to store
  48645. * @param format defines the data format
  48646. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48647. * @param invertY defines if data must be stored with Y axis inverted
  48648. * @param compression defines the compression used (null by default)
  48649. * @param level defines which level of the texture to update
  48650. */
  48651. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48652. /**
  48653. * Updates a raw cube texture with RGBD encoded data.
  48654. * @param data defines the array of data [mipmap][face] to use to create each face
  48655. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48656. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48657. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48658. * @returns a promsie that resolves when the operation is complete
  48659. */
  48660. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48661. /**
  48662. * Clones the raw cube texture.
  48663. * @return a new cube texture
  48664. */
  48665. clone(): CubeTexture;
  48666. /** @hidden */
  48667. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48668. }
  48669. }
  48670. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48671. import { Scene } from "babylonjs/scene";
  48672. import { Texture } from "babylonjs/Materials/Textures/texture";
  48673. /**
  48674. * Class used to store 3D textures containing user data
  48675. */
  48676. export class RawTexture3D extends Texture {
  48677. /** Gets or sets the texture format to use */
  48678. format: number;
  48679. private _engine;
  48680. /**
  48681. * Create a new RawTexture3D
  48682. * @param data defines the data of the texture
  48683. * @param width defines the width of the texture
  48684. * @param height defines the height of the texture
  48685. * @param depth defines the depth of the texture
  48686. * @param format defines the texture format to use
  48687. * @param scene defines the hosting scene
  48688. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48689. * @param invertY defines if texture must be stored with Y axis inverted
  48690. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48691. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48692. */
  48693. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48694. /** Gets or sets the texture format to use */
  48695. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48696. /**
  48697. * Update the texture with new data
  48698. * @param data defines the data to store in the texture
  48699. */
  48700. update(data: ArrayBufferView): void;
  48701. }
  48702. }
  48703. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48704. import { Scene } from "babylonjs/scene";
  48705. import { Plane } from "babylonjs/Maths/math";
  48706. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48707. /**
  48708. * Creates a refraction texture used by refraction channel of the standard material.
  48709. * It is like a mirror but to see through a material.
  48710. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48711. */
  48712. export class RefractionTexture extends RenderTargetTexture {
  48713. /**
  48714. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48715. * 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.
  48716. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48717. */
  48718. refractionPlane: Plane;
  48719. /**
  48720. * Define how deep under the surface we should see.
  48721. */
  48722. depth: number;
  48723. /**
  48724. * Creates a refraction texture used by refraction channel of the standard material.
  48725. * It is like a mirror but to see through a material.
  48726. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48727. * @param name Define the texture name
  48728. * @param size Define the size of the underlying texture
  48729. * @param scene Define the scene the refraction belongs to
  48730. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48731. */
  48732. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48733. /**
  48734. * Clone the refraction texture.
  48735. * @returns the cloned texture
  48736. */
  48737. clone(): RefractionTexture;
  48738. /**
  48739. * Serialize the texture to a JSON representation you could use in Parse later on
  48740. * @returns the serialized JSON representation
  48741. */
  48742. serialize(): any;
  48743. }
  48744. }
  48745. declare module "babylonjs/Materials/Textures/index" {
  48746. export * from "babylonjs/Materials/Textures/baseTexture";
  48747. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48748. export * from "babylonjs/Materials/Textures/cubeTexture";
  48749. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48750. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48751. export * from "babylonjs/Materials/Textures/internalTexture";
  48752. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48753. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48754. export * from "babylonjs/Materials/Textures/Loaders/index";
  48755. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48756. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48757. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48758. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48759. export * from "babylonjs/Materials/Textures/rawTexture";
  48760. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48761. export * from "babylonjs/Materials/Textures/refractionTexture";
  48762. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48763. export * from "babylonjs/Materials/Textures/texture";
  48764. export * from "babylonjs/Materials/Textures/videoTexture";
  48765. }
  48766. declare module "babylonjs/Materials/index" {
  48767. export * from "babylonjs/Materials/Background/index";
  48768. export * from "babylonjs/Materials/colorCurves";
  48769. export * from "babylonjs/Materials/effect";
  48770. export * from "babylonjs/Materials/fresnelParameters";
  48771. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48772. export * from "babylonjs/Materials/material";
  48773. export * from "babylonjs/Materials/materialDefines";
  48774. export * from "babylonjs/Materials/materialHelper";
  48775. export * from "babylonjs/Materials/multiMaterial";
  48776. export * from "babylonjs/Materials/PBR/index";
  48777. export * from "babylonjs/Materials/pushMaterial";
  48778. export * from "babylonjs/Materials/shaderMaterial";
  48779. export * from "babylonjs/Materials/standardMaterial";
  48780. export * from "babylonjs/Materials/Textures/index";
  48781. export * from "babylonjs/Materials/uniformBuffer";
  48782. export * from "babylonjs/Materials/materialFlags";
  48783. }
  48784. declare module "babylonjs/Maths/index" {
  48785. export * from "babylonjs/Maths/math.scalar";
  48786. export * from "babylonjs/Maths/math";
  48787. export * from "babylonjs/Maths/sphericalPolynomial";
  48788. }
  48789. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48790. import { IDisposable } from "babylonjs/scene";
  48791. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48792. /**
  48793. * Configuration for Draco compression
  48794. */
  48795. export interface IDracoCompressionConfiguration {
  48796. /**
  48797. * Configuration for the decoder.
  48798. */
  48799. decoder?: {
  48800. /**
  48801. * The url to the WebAssembly module.
  48802. */
  48803. wasmUrl?: string;
  48804. /**
  48805. * The url to the WebAssembly binary.
  48806. */
  48807. wasmBinaryUrl?: string;
  48808. /**
  48809. * The url to the fallback JavaScript module.
  48810. */
  48811. fallbackUrl?: string;
  48812. };
  48813. }
  48814. /**
  48815. * Draco compression (https://google.github.io/draco/)
  48816. *
  48817. * This class wraps the Draco module.
  48818. *
  48819. * **Encoder**
  48820. *
  48821. * The encoder is not currently implemented.
  48822. *
  48823. * **Decoder**
  48824. *
  48825. * 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.
  48826. *
  48827. * To update the configuration, use the following code:
  48828. * ```javascript
  48829. * DracoCompression.Configuration = {
  48830. * decoder: {
  48831. * wasmUrl: "<url to the WebAssembly library>",
  48832. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48833. * fallbackUrl: "<url to the fallback JavaScript library>",
  48834. * }
  48835. * };
  48836. * ```
  48837. *
  48838. * 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.
  48839. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48840. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48841. *
  48842. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48843. * ```javascript
  48844. * var dracoCompression = new DracoCompression();
  48845. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48846. * [VertexBuffer.PositionKind]: 0
  48847. * });
  48848. * ```
  48849. *
  48850. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48851. */
  48852. export class DracoCompression implements IDisposable {
  48853. private static _DecoderModulePromise;
  48854. /**
  48855. * The configuration. Defaults to the following urls:
  48856. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48857. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48858. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48859. */
  48860. static Configuration: IDracoCompressionConfiguration;
  48861. /**
  48862. * Returns true if the decoder is available.
  48863. */
  48864. static readonly DecoderAvailable: boolean;
  48865. /**
  48866. * Constructor
  48867. */
  48868. constructor();
  48869. /**
  48870. * Stop all async operations and release resources.
  48871. */
  48872. dispose(): void;
  48873. /**
  48874. * Decode Draco compressed mesh data to vertex data.
  48875. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48876. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48877. * @returns A promise that resolves with the decoded vertex data
  48878. */
  48879. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48880. [kind: string]: number;
  48881. }): Promise<VertexData>;
  48882. private static _GetDecoderModule;
  48883. private static _LoadScriptAsync;
  48884. private static _LoadFileAsync;
  48885. }
  48886. }
  48887. declare module "babylonjs/Meshes/Compression/index" {
  48888. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48889. }
  48890. declare module "babylonjs/Meshes/csg" {
  48891. import { Nullable } from "babylonjs/types";
  48892. import { Scene } from "babylonjs/scene";
  48893. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48894. import { Mesh } from "babylonjs/Meshes/mesh";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. /**
  48897. * Class for building Constructive Solid Geometry
  48898. */
  48899. export class CSG {
  48900. private polygons;
  48901. /**
  48902. * The world matrix
  48903. */
  48904. matrix: Matrix;
  48905. /**
  48906. * Stores the position
  48907. */
  48908. position: Vector3;
  48909. /**
  48910. * Stores the rotation
  48911. */
  48912. rotation: Vector3;
  48913. /**
  48914. * Stores the rotation quaternion
  48915. */
  48916. rotationQuaternion: Nullable<Quaternion>;
  48917. /**
  48918. * Stores the scaling vector
  48919. */
  48920. scaling: Vector3;
  48921. /**
  48922. * Convert the Mesh to CSG
  48923. * @param mesh The Mesh to convert to CSG
  48924. * @returns A new CSG from the Mesh
  48925. */
  48926. static FromMesh(mesh: Mesh): CSG;
  48927. /**
  48928. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48929. * @param polygons Polygons used to construct a CSG solid
  48930. */
  48931. private static FromPolygons;
  48932. /**
  48933. * Clones, or makes a deep copy, of the CSG
  48934. * @returns A new CSG
  48935. */
  48936. clone(): CSG;
  48937. /**
  48938. * Unions this CSG with another CSG
  48939. * @param csg The CSG to union against this CSG
  48940. * @returns The unioned CSG
  48941. */
  48942. union(csg: CSG): CSG;
  48943. /**
  48944. * Unions this CSG with another CSG in place
  48945. * @param csg The CSG to union against this CSG
  48946. */
  48947. unionInPlace(csg: CSG): void;
  48948. /**
  48949. * Subtracts this CSG with another CSG
  48950. * @param csg The CSG to subtract against this CSG
  48951. * @returns A new CSG
  48952. */
  48953. subtract(csg: CSG): CSG;
  48954. /**
  48955. * Subtracts this CSG with another CSG in place
  48956. * @param csg The CSG to subtact against this CSG
  48957. */
  48958. subtractInPlace(csg: CSG): void;
  48959. /**
  48960. * Intersect this CSG with another CSG
  48961. * @param csg The CSG to intersect against this CSG
  48962. * @returns A new CSG
  48963. */
  48964. intersect(csg: CSG): CSG;
  48965. /**
  48966. * Intersects this CSG with another CSG in place
  48967. * @param csg The CSG to intersect against this CSG
  48968. */
  48969. intersectInPlace(csg: CSG): void;
  48970. /**
  48971. * Return a new CSG solid with solid and empty space switched. This solid is
  48972. * not modified.
  48973. * @returns A new CSG solid with solid and empty space switched
  48974. */
  48975. inverse(): CSG;
  48976. /**
  48977. * Inverses the CSG in place
  48978. */
  48979. inverseInPlace(): void;
  48980. /**
  48981. * This is used to keep meshes transformations so they can be restored
  48982. * when we build back a Babylon Mesh
  48983. * NB : All CSG operations are performed in world coordinates
  48984. * @param csg The CSG to copy the transform attributes from
  48985. * @returns This CSG
  48986. */
  48987. copyTransformAttributes(csg: CSG): CSG;
  48988. /**
  48989. * Build Raw mesh from CSG
  48990. * Coordinates here are in world space
  48991. * @param name The name of the mesh geometry
  48992. * @param scene The Scene
  48993. * @param keepSubMeshes Specifies if the submeshes should be kept
  48994. * @returns A new Mesh
  48995. */
  48996. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48997. /**
  48998. * Build Mesh from CSG taking material and transforms into account
  48999. * @param name The name of the Mesh
  49000. * @param material The material of the Mesh
  49001. * @param scene The Scene
  49002. * @param keepSubMeshes Specifies if submeshes should be kept
  49003. * @returns The new Mesh
  49004. */
  49005. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49006. }
  49007. }
  49008. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49009. import { Nullable } from "babylonjs/types";
  49010. import { Scene } from "babylonjs/scene";
  49011. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49012. import { Mesh } from "babylonjs/Meshes/mesh";
  49013. /**
  49014. * Class containing static functions to help procedurally build meshes
  49015. */
  49016. export class RibbonBuilder {
  49017. /**
  49018. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49019. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49020. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49021. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49022. * * 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
  49023. * * 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
  49024. * * 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
  49025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49028. * * 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
  49029. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49030. * * 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
  49031. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49033. * @param name defines the name of the mesh
  49034. * @param options defines the options used to create the mesh
  49035. * @param scene defines the hosting scene
  49036. * @returns the ribbon mesh
  49037. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49039. */
  49040. static CreateRibbon(name: string, options: {
  49041. pathArray: Vector3[][];
  49042. closeArray?: boolean;
  49043. closePath?: boolean;
  49044. offset?: number;
  49045. updatable?: boolean;
  49046. sideOrientation?: number;
  49047. frontUVs?: Vector4;
  49048. backUVs?: Vector4;
  49049. instance?: Mesh;
  49050. invertUV?: boolean;
  49051. uvs?: Vector2[];
  49052. colors?: Color4[];
  49053. }, scene?: Nullable<Scene>): Mesh;
  49054. }
  49055. }
  49056. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49057. import { Vector4 } from "babylonjs/Maths/math";
  49058. import { Mesh } from "babylonjs/Meshes/mesh";
  49059. /**
  49060. * Class containing static functions to help procedurally build meshes
  49061. */
  49062. export class TorusKnotBuilder {
  49063. /**
  49064. * Creates a torus knot mesh
  49065. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49066. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49067. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49068. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49072. * @param name defines the name of the mesh
  49073. * @param options defines the options used to create the mesh
  49074. * @param scene defines the hosting scene
  49075. * @returns the torus knot mesh
  49076. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49077. */
  49078. static CreateTorusKnot(name: string, options: {
  49079. radius?: number;
  49080. tube?: number;
  49081. radialSegments?: number;
  49082. tubularSegments?: number;
  49083. p?: number;
  49084. q?: number;
  49085. updatable?: boolean;
  49086. sideOrientation?: number;
  49087. frontUVs?: Vector4;
  49088. backUVs?: Vector4;
  49089. }, scene: any): Mesh;
  49090. }
  49091. }
  49092. declare module "babylonjs/Meshes/polygonMesh" {
  49093. import { Scene } from "babylonjs/scene";
  49094. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49095. import { Mesh } from "babylonjs/Meshes/mesh";
  49096. /**
  49097. * Polygon
  49098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49099. */
  49100. export class Polygon {
  49101. /**
  49102. * Creates a rectangle
  49103. * @param xmin bottom X coord
  49104. * @param ymin bottom Y coord
  49105. * @param xmax top X coord
  49106. * @param ymax top Y coord
  49107. * @returns points that make the resulting rectation
  49108. */
  49109. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49110. /**
  49111. * Creates a circle
  49112. * @param radius radius of circle
  49113. * @param cx scale in x
  49114. * @param cy scale in y
  49115. * @param numberOfSides number of sides that make up the circle
  49116. * @returns points that make the resulting circle
  49117. */
  49118. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49119. /**
  49120. * Creates a polygon from input string
  49121. * @param input Input polygon data
  49122. * @returns the parsed points
  49123. */
  49124. static Parse(input: string): Vector2[];
  49125. /**
  49126. * Starts building a polygon from x and y coordinates
  49127. * @param x x coordinate
  49128. * @param y y coordinate
  49129. * @returns the started path2
  49130. */
  49131. static StartingAt(x: number, y: number): Path2;
  49132. }
  49133. /**
  49134. * Builds a polygon
  49135. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49136. */
  49137. export class PolygonMeshBuilder {
  49138. private _points;
  49139. private _outlinepoints;
  49140. private _holes;
  49141. private _name;
  49142. private _scene;
  49143. private _epoints;
  49144. private _eholes;
  49145. private _addToepoint;
  49146. /**
  49147. * Babylon reference to the earcut plugin.
  49148. */
  49149. bjsEarcut: any;
  49150. /**
  49151. * Creates a PolygonMeshBuilder
  49152. * @param name name of the builder
  49153. * @param contours Path of the polygon
  49154. * @param scene scene to add to
  49155. * @param earcutInjection can be used to inject your own earcut reference
  49156. */
  49157. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49158. /**
  49159. * Adds a whole within the polygon
  49160. * @param hole Array of points defining the hole
  49161. * @returns this
  49162. */
  49163. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49164. /**
  49165. * Creates the polygon
  49166. * @param updatable If the mesh should be updatable
  49167. * @param depth The depth of the mesh created
  49168. * @returns the created mesh
  49169. */
  49170. build(updatable?: boolean, depth?: number): Mesh;
  49171. /**
  49172. * Adds a side to the polygon
  49173. * @param positions points that make the polygon
  49174. * @param normals normals of the polygon
  49175. * @param uvs uvs of the polygon
  49176. * @param indices indices of the polygon
  49177. * @param bounds bounds of the polygon
  49178. * @param points points of the polygon
  49179. * @param depth depth of the polygon
  49180. * @param flip flip of the polygon
  49181. */
  49182. private addSide;
  49183. }
  49184. }
  49185. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49186. import { Scene } from "babylonjs/scene";
  49187. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49188. import { Mesh } from "babylonjs/Meshes/mesh";
  49189. /**
  49190. * Class containing static functions to help procedurally build meshes
  49191. */
  49192. export class PolygonBuilder {
  49193. /**
  49194. * Creates a polygon mesh
  49195. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49196. * * 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
  49197. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49200. * * Remember you can only change the shape positions, not their number when updating a polygon
  49201. * @param name defines the name of the mesh
  49202. * @param options defines the options used to create the mesh
  49203. * @param scene defines the hosting scene
  49204. * @param earcutInjection can be used to inject your own earcut reference
  49205. * @returns the polygon mesh
  49206. */
  49207. static CreatePolygon(name: string, options: {
  49208. shape: Vector3[];
  49209. holes?: Vector3[][];
  49210. depth?: number;
  49211. faceUV?: Vector4[];
  49212. faceColors?: Color4[];
  49213. updatable?: boolean;
  49214. sideOrientation?: number;
  49215. frontUVs?: Vector4;
  49216. backUVs?: Vector4;
  49217. }, scene: Scene, earcutInjection?: any): Mesh;
  49218. /**
  49219. * Creates an extruded polygon mesh, with depth in the Y direction.
  49220. * * 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)
  49221. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49222. * @param name defines the name of the mesh
  49223. * @param options defines the options used to create the mesh
  49224. * @param scene defines the hosting scene
  49225. * @param earcutInjection can be used to inject your own earcut reference
  49226. * @returns the polygon mesh
  49227. */
  49228. static ExtrudePolygon(name: string, options: {
  49229. shape: Vector3[];
  49230. holes?: Vector3[][];
  49231. depth?: number;
  49232. faceUV?: Vector4[];
  49233. faceColors?: Color4[];
  49234. updatable?: boolean;
  49235. sideOrientation?: number;
  49236. frontUVs?: Vector4;
  49237. backUVs?: Vector4;
  49238. }, scene: Scene, earcutInjection?: any): Mesh;
  49239. }
  49240. }
  49241. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49242. import { Nullable } from "babylonjs/types";
  49243. import { Scene } from "babylonjs/scene";
  49244. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49245. import { Mesh } from "babylonjs/Meshes/mesh";
  49246. /**
  49247. * Class containing static functions to help procedurally build meshes
  49248. */
  49249. export class ShapeBuilder {
  49250. /**
  49251. * 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.
  49252. * * 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.
  49253. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49254. * * 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.
  49255. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49256. * * 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
  49257. * * 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
  49258. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @returns the extruded shape mesh
  49267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49269. */
  49270. static ExtrudeShape(name: string, options: {
  49271. shape: Vector3[];
  49272. path: Vector3[];
  49273. scale?: number;
  49274. rotation?: number;
  49275. cap?: number;
  49276. updatable?: boolean;
  49277. sideOrientation?: number;
  49278. frontUVs?: Vector4;
  49279. backUVs?: Vector4;
  49280. instance?: Mesh;
  49281. invertUV?: boolean;
  49282. }, scene?: Nullable<Scene>): Mesh;
  49283. /**
  49284. * Creates an custom extruded shape mesh.
  49285. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49286. * * 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.
  49287. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49288. * * 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
  49289. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49290. * * 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
  49291. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49292. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49293. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49294. * * 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
  49295. * * 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
  49296. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49301. * @param name defines the name of the mesh
  49302. * @param options defines the options used to create the mesh
  49303. * @param scene defines the hosting scene
  49304. * @returns the custom extruded shape mesh
  49305. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49306. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49308. */
  49309. static ExtrudeShapeCustom(name: string, options: {
  49310. shape: Vector3[];
  49311. path: Vector3[];
  49312. scaleFunction?: any;
  49313. rotationFunction?: any;
  49314. ribbonCloseArray?: boolean;
  49315. ribbonClosePath?: boolean;
  49316. cap?: number;
  49317. updatable?: boolean;
  49318. sideOrientation?: number;
  49319. frontUVs?: Vector4;
  49320. backUVs?: Vector4;
  49321. instance?: Mesh;
  49322. invertUV?: boolean;
  49323. }, scene: Scene): Mesh;
  49324. private static _ExtrudeShapeGeneric;
  49325. }
  49326. }
  49327. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49328. import { Scene } from "babylonjs/scene";
  49329. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49330. import { Mesh } from "babylonjs/Meshes/mesh";
  49331. /**
  49332. * Class containing static functions to help procedurally build meshes
  49333. */
  49334. export class LatheBuilder {
  49335. /**
  49336. * Creates lathe mesh.
  49337. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49338. * * 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
  49339. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49340. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49341. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49342. * * 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
  49343. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49344. * * 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
  49345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49349. * @param name defines the name of the mesh
  49350. * @param options defines the options used to create the mesh
  49351. * @param scene defines the hosting scene
  49352. * @returns the lathe mesh
  49353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49354. */
  49355. static CreateLathe(name: string, options: {
  49356. shape: Vector3[];
  49357. radius?: number;
  49358. tessellation?: number;
  49359. clip?: number;
  49360. arc?: number;
  49361. closed?: boolean;
  49362. updatable?: boolean;
  49363. sideOrientation?: number;
  49364. frontUVs?: Vector4;
  49365. backUVs?: Vector4;
  49366. cap?: number;
  49367. invertUV?: boolean;
  49368. }, scene: Scene): Mesh;
  49369. }
  49370. }
  49371. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49372. import { Scene } from "babylonjs/scene";
  49373. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49374. import { Mesh } from "babylonjs/Meshes/mesh";
  49375. /**
  49376. * Class containing static functions to help procedurally build meshes
  49377. */
  49378. export class TubeBuilder {
  49379. /**
  49380. * Creates a tube mesh.
  49381. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49382. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49383. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49384. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49385. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49386. * * 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)
  49387. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49388. * * 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
  49389. * * 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
  49390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49394. * @param name defines the name of the mesh
  49395. * @param options defines the options used to create the mesh
  49396. * @param scene defines the hosting scene
  49397. * @returns the tube mesh
  49398. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49399. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49400. */
  49401. static CreateTube(name: string, options: {
  49402. path: Vector3[];
  49403. radius?: number;
  49404. tessellation?: number;
  49405. radiusFunction?: {
  49406. (i: number, distance: number): number;
  49407. };
  49408. cap?: number;
  49409. arc?: number;
  49410. updatable?: boolean;
  49411. sideOrientation?: number;
  49412. frontUVs?: Vector4;
  49413. backUVs?: Vector4;
  49414. instance?: Mesh;
  49415. invertUV?: boolean;
  49416. }, scene: Scene): Mesh;
  49417. }
  49418. }
  49419. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49420. import { Scene } from "babylonjs/scene";
  49421. import { Vector4 } from "babylonjs/Maths/math";
  49422. import { Mesh } from "babylonjs/Meshes/mesh";
  49423. /**
  49424. * Class containing static functions to help procedurally build meshes
  49425. */
  49426. export class IcoSphereBuilder {
  49427. /**
  49428. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49429. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49430. * * 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`)
  49431. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49432. * * 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
  49433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49436. * @param name defines the name of the mesh
  49437. * @param options defines the options used to create the mesh
  49438. * @param scene defines the hosting scene
  49439. * @returns the icosahedron mesh
  49440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49441. */
  49442. static CreateIcoSphere(name: string, options: {
  49443. radius?: number;
  49444. radiusX?: number;
  49445. radiusY?: number;
  49446. radiusZ?: number;
  49447. flat?: boolean;
  49448. subdivisions?: number;
  49449. sideOrientation?: number;
  49450. frontUVs?: Vector4;
  49451. backUVs?: Vector4;
  49452. updatable?: boolean;
  49453. }, scene: Scene): Mesh;
  49454. }
  49455. }
  49456. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49457. import { Vector3 } from "babylonjs/Maths/math";
  49458. import { Mesh } from "babylonjs/Meshes/mesh";
  49459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49460. /**
  49461. * Class containing static functions to help procedurally build meshes
  49462. */
  49463. export class DecalBuilder {
  49464. /**
  49465. * Creates a decal mesh.
  49466. * 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
  49467. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49468. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49469. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49470. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49471. * @param name defines the name of the mesh
  49472. * @param sourceMesh defines the mesh where the decal must be applied
  49473. * @param options defines the options used to create the mesh
  49474. * @param scene defines the hosting scene
  49475. * @returns the decal mesh
  49476. * @see https://doc.babylonjs.com/how_to/decals
  49477. */
  49478. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49479. position?: Vector3;
  49480. normal?: Vector3;
  49481. size?: Vector3;
  49482. angle?: number;
  49483. }): Mesh;
  49484. }
  49485. }
  49486. declare module "babylonjs/Meshes/meshBuilder" {
  49487. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49488. import { Nullable } from "babylonjs/types";
  49489. import { Scene } from "babylonjs/scene";
  49490. import { Mesh } from "babylonjs/Meshes/mesh";
  49491. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49492. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49494. /**
  49495. * Class containing static functions to help procedurally build meshes
  49496. */
  49497. export class MeshBuilder {
  49498. /**
  49499. * Creates a box mesh
  49500. * * The parameter `size` sets the size (float) of each box side (default 1)
  49501. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49502. * * 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)
  49503. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49507. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49508. * @param name defines the name of the mesh
  49509. * @param options defines the options used to create the mesh
  49510. * @param scene defines the hosting scene
  49511. * @returns the box mesh
  49512. */
  49513. static CreateBox(name: string, options: {
  49514. size?: number;
  49515. width?: number;
  49516. height?: number;
  49517. depth?: number;
  49518. faceUV?: Vector4[];
  49519. faceColors?: Color4[];
  49520. sideOrientation?: number;
  49521. frontUVs?: Vector4;
  49522. backUVs?: Vector4;
  49523. updatable?: boolean;
  49524. }, scene?: Nullable<Scene>): Mesh;
  49525. /**
  49526. * Creates a sphere mesh
  49527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49528. * * 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`)
  49529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49530. * * 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
  49531. * * 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)
  49532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49535. * @param name defines the name of the mesh
  49536. * @param options defines the options used to create the mesh
  49537. * @param scene defines the hosting scene
  49538. * @returns the sphere mesh
  49539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49540. */
  49541. static CreateSphere(name: string, options: {
  49542. segments?: number;
  49543. diameter?: number;
  49544. diameterX?: number;
  49545. diameterY?: number;
  49546. diameterZ?: number;
  49547. arc?: number;
  49548. slice?: number;
  49549. sideOrientation?: number;
  49550. frontUVs?: Vector4;
  49551. backUVs?: Vector4;
  49552. updatable?: boolean;
  49553. }, scene: any): Mesh;
  49554. /**
  49555. * Creates a plane polygonal mesh. By default, this is a disc
  49556. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49557. * * 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
  49558. * * 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
  49559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49562. * @param name defines the name of the mesh
  49563. * @param options defines the options used to create the mesh
  49564. * @param scene defines the hosting scene
  49565. * @returns the plane polygonal mesh
  49566. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49567. */
  49568. static CreateDisc(name: string, options: {
  49569. radius?: number;
  49570. tessellation?: number;
  49571. arc?: number;
  49572. updatable?: boolean;
  49573. sideOrientation?: number;
  49574. frontUVs?: Vector4;
  49575. backUVs?: Vector4;
  49576. }, scene?: Nullable<Scene>): Mesh;
  49577. /**
  49578. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49579. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49580. * * 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`)
  49581. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49582. * * 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
  49583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49586. * @param name defines the name of the mesh
  49587. * @param options defines the options used to create the mesh
  49588. * @param scene defines the hosting scene
  49589. * @returns the icosahedron mesh
  49590. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49591. */
  49592. static CreateIcoSphere(name: string, options: {
  49593. radius?: number;
  49594. radiusX?: number;
  49595. radiusY?: number;
  49596. radiusZ?: number;
  49597. flat?: boolean;
  49598. subdivisions?: number;
  49599. sideOrientation?: number;
  49600. frontUVs?: Vector4;
  49601. backUVs?: Vector4;
  49602. updatable?: boolean;
  49603. }, scene: Scene): Mesh;
  49604. /**
  49605. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49606. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49607. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49608. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49609. * * 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
  49610. * * 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
  49611. * * 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
  49612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49615. * * 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
  49616. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49617. * * 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
  49618. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49620. * @param name defines the name of the mesh
  49621. * @param options defines the options used to create the mesh
  49622. * @param scene defines the hosting scene
  49623. * @returns the ribbon mesh
  49624. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49626. */
  49627. static CreateRibbon(name: string, options: {
  49628. pathArray: Vector3[][];
  49629. closeArray?: boolean;
  49630. closePath?: boolean;
  49631. offset?: number;
  49632. updatable?: boolean;
  49633. sideOrientation?: number;
  49634. frontUVs?: Vector4;
  49635. backUVs?: Vector4;
  49636. instance?: Mesh;
  49637. invertUV?: boolean;
  49638. uvs?: Vector2[];
  49639. colors?: Color4[];
  49640. }, scene?: Nullable<Scene>): Mesh;
  49641. /**
  49642. * Creates a cylinder or a cone mesh
  49643. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49644. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49645. * * 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.
  49646. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49647. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49648. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49649. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49650. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49651. * * 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).
  49652. * * 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
  49653. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49654. * * 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
  49655. * * 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.
  49656. * * If `enclose` is false, a ring surface is one element.
  49657. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49658. * * 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
  49659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49662. * @param name defines the name of the mesh
  49663. * @param options defines the options used to create the mesh
  49664. * @param scene defines the hosting scene
  49665. * @returns the cylinder mesh
  49666. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49667. */
  49668. static CreateCylinder(name: string, options: {
  49669. height?: number;
  49670. diameterTop?: number;
  49671. diameterBottom?: number;
  49672. diameter?: number;
  49673. tessellation?: number;
  49674. subdivisions?: number;
  49675. arc?: number;
  49676. faceColors?: Color4[];
  49677. faceUV?: Vector4[];
  49678. updatable?: boolean;
  49679. hasRings?: boolean;
  49680. enclose?: boolean;
  49681. sideOrientation?: number;
  49682. frontUVs?: Vector4;
  49683. backUVs?: Vector4;
  49684. }, scene: any): Mesh;
  49685. /**
  49686. * Creates a torus mesh
  49687. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49688. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49689. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49693. * @param name defines the name of the mesh
  49694. * @param options defines the options used to create the mesh
  49695. * @param scene defines the hosting scene
  49696. * @returns the torus mesh
  49697. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49698. */
  49699. static CreateTorus(name: string, options: {
  49700. diameter?: number;
  49701. thickness?: number;
  49702. tessellation?: number;
  49703. updatable?: boolean;
  49704. sideOrientation?: number;
  49705. frontUVs?: Vector4;
  49706. backUVs?: Vector4;
  49707. }, scene: any): Mesh;
  49708. /**
  49709. * Creates a torus knot mesh
  49710. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49711. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49712. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49713. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49717. * @param name defines the name of the mesh
  49718. * @param options defines the options used to create the mesh
  49719. * @param scene defines the hosting scene
  49720. * @returns the torus knot mesh
  49721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49722. */
  49723. static CreateTorusKnot(name: string, options: {
  49724. radius?: number;
  49725. tube?: number;
  49726. radialSegments?: number;
  49727. tubularSegments?: number;
  49728. p?: number;
  49729. q?: number;
  49730. updatable?: boolean;
  49731. sideOrientation?: number;
  49732. frontUVs?: Vector4;
  49733. backUVs?: Vector4;
  49734. }, scene: any): Mesh;
  49735. /**
  49736. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49737. * * 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
  49738. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49739. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49740. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49741. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49742. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49743. * * 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
  49744. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49747. * @param name defines the name of the new line system
  49748. * @param options defines the options used to create the line system
  49749. * @param scene defines the hosting scene
  49750. * @returns a new line system mesh
  49751. */
  49752. static CreateLineSystem(name: string, options: {
  49753. lines: Vector3[][];
  49754. updatable?: boolean;
  49755. instance?: Nullable<LinesMesh>;
  49756. colors?: Nullable<Color4[][]>;
  49757. useVertexAlpha?: boolean;
  49758. }, scene: Nullable<Scene>): LinesMesh;
  49759. /**
  49760. * Creates a line mesh
  49761. * 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
  49762. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49763. * * The parameter `points` is an array successive Vector3
  49764. * * 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
  49765. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49766. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49767. * * When updating an instance, remember that only point positions can change, not the number of points
  49768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49770. * @param name defines the name of the new line system
  49771. * @param options defines the options used to create the line system
  49772. * @param scene defines the hosting scene
  49773. * @returns a new line mesh
  49774. */
  49775. static CreateLines(name: string, options: {
  49776. points: Vector3[];
  49777. updatable?: boolean;
  49778. instance?: Nullable<LinesMesh>;
  49779. colors?: Color4[];
  49780. useVertexAlpha?: boolean;
  49781. }, scene?: Nullable<Scene>): LinesMesh;
  49782. /**
  49783. * Creates a dashed line mesh
  49784. * * 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
  49785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49786. * * The parameter `points` is an array successive Vector3
  49787. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49788. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49789. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49790. * * 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
  49791. * * When updating an instance, remember that only point positions can change, not the number of points
  49792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49793. * @param name defines the name of the mesh
  49794. * @param options defines the options used to create the mesh
  49795. * @param scene defines the hosting scene
  49796. * @returns the dashed line mesh
  49797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49798. */
  49799. static CreateDashedLines(name: string, options: {
  49800. points: Vector3[];
  49801. dashSize?: number;
  49802. gapSize?: number;
  49803. dashNb?: number;
  49804. updatable?: boolean;
  49805. instance?: LinesMesh;
  49806. }, scene?: Nullable<Scene>): LinesMesh;
  49807. /**
  49808. * 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.
  49809. * * 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.
  49810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49811. * * 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.
  49812. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49813. * * 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
  49814. * * 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
  49815. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49820. * @param name defines the name of the mesh
  49821. * @param options defines the options used to create the mesh
  49822. * @param scene defines the hosting scene
  49823. * @returns the extruded shape mesh
  49824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49826. */
  49827. static ExtrudeShape(name: string, options: {
  49828. shape: Vector3[];
  49829. path: Vector3[];
  49830. scale?: number;
  49831. rotation?: number;
  49832. cap?: number;
  49833. updatable?: boolean;
  49834. sideOrientation?: number;
  49835. frontUVs?: Vector4;
  49836. backUVs?: Vector4;
  49837. instance?: Mesh;
  49838. invertUV?: boolean;
  49839. }, scene?: Nullable<Scene>): Mesh;
  49840. /**
  49841. * Creates an custom extruded shape mesh.
  49842. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49843. * * 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.
  49844. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49845. * * 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
  49846. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49847. * * 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
  49848. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49849. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49850. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49851. * * 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
  49852. * * 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
  49853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49858. * @param name defines the name of the mesh
  49859. * @param options defines the options used to create the mesh
  49860. * @param scene defines the hosting scene
  49861. * @returns the custom extruded shape mesh
  49862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49865. */
  49866. static ExtrudeShapeCustom(name: string, options: {
  49867. shape: Vector3[];
  49868. path: Vector3[];
  49869. scaleFunction?: any;
  49870. rotationFunction?: any;
  49871. ribbonCloseArray?: boolean;
  49872. ribbonClosePath?: boolean;
  49873. cap?: number;
  49874. updatable?: boolean;
  49875. sideOrientation?: number;
  49876. frontUVs?: Vector4;
  49877. backUVs?: Vector4;
  49878. instance?: Mesh;
  49879. invertUV?: boolean;
  49880. }, scene: Scene): Mesh;
  49881. /**
  49882. * Creates lathe mesh.
  49883. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49884. * * 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
  49885. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49886. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49887. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49888. * * 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
  49889. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49890. * * 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
  49891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49893. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49895. * @param name defines the name of the mesh
  49896. * @param options defines the options used to create the mesh
  49897. * @param scene defines the hosting scene
  49898. * @returns the lathe mesh
  49899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49900. */
  49901. static CreateLathe(name: string, options: {
  49902. shape: Vector3[];
  49903. radius?: number;
  49904. tessellation?: number;
  49905. clip?: number;
  49906. arc?: number;
  49907. closed?: boolean;
  49908. updatable?: boolean;
  49909. sideOrientation?: number;
  49910. frontUVs?: Vector4;
  49911. backUVs?: Vector4;
  49912. cap?: number;
  49913. invertUV?: boolean;
  49914. }, scene: Scene): Mesh;
  49915. /**
  49916. * Creates a plane mesh
  49917. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49918. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49919. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49923. * @param name defines the name of the mesh
  49924. * @param options defines the options used to create the mesh
  49925. * @param scene defines the hosting scene
  49926. * @returns the plane mesh
  49927. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49928. */
  49929. static CreatePlane(name: string, options: {
  49930. size?: number;
  49931. width?: number;
  49932. height?: number;
  49933. sideOrientation?: number;
  49934. frontUVs?: Vector4;
  49935. backUVs?: Vector4;
  49936. updatable?: boolean;
  49937. sourcePlane?: Plane;
  49938. }, scene: Scene): Mesh;
  49939. /**
  49940. * Creates a ground mesh
  49941. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49942. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49944. * @param name defines the name of the mesh
  49945. * @param options defines the options used to create the mesh
  49946. * @param scene defines the hosting scene
  49947. * @returns the ground mesh
  49948. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49949. */
  49950. static CreateGround(name: string, options: {
  49951. width?: number;
  49952. height?: number;
  49953. subdivisions?: number;
  49954. subdivisionsX?: number;
  49955. subdivisionsY?: number;
  49956. updatable?: boolean;
  49957. }, scene: any): Mesh;
  49958. /**
  49959. * Creates a tiled ground mesh
  49960. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49961. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49962. * * 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
  49963. * * 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
  49964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49965. * @param name defines the name of the mesh
  49966. * @param options defines the options used to create the mesh
  49967. * @param scene defines the hosting scene
  49968. * @returns the tiled ground mesh
  49969. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49970. */
  49971. static CreateTiledGround(name: string, options: {
  49972. xmin: number;
  49973. zmin: number;
  49974. xmax: number;
  49975. zmax: number;
  49976. subdivisions?: {
  49977. w: number;
  49978. h: number;
  49979. };
  49980. precision?: {
  49981. w: number;
  49982. h: number;
  49983. };
  49984. updatable?: boolean;
  49985. }, scene: Scene): Mesh;
  49986. /**
  49987. * Creates a ground mesh from a height map
  49988. * * The parameter `url` sets the URL of the height map image resource.
  49989. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49990. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49991. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49992. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49993. * * 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.
  49994. * * 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).
  49995. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49997. * @param name defines the name of the mesh
  49998. * @param url defines the url to the height map
  49999. * @param options defines the options used to create the mesh
  50000. * @param scene defines the hosting scene
  50001. * @returns the ground mesh
  50002. * @see https://doc.babylonjs.com/babylon101/height_map
  50003. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50004. */
  50005. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50006. width?: number;
  50007. height?: number;
  50008. subdivisions?: number;
  50009. minHeight?: number;
  50010. maxHeight?: number;
  50011. colorFilter?: Color3;
  50012. alphaFilter?: number;
  50013. updatable?: boolean;
  50014. onReady?: (mesh: GroundMesh) => void;
  50015. }, scene: Scene): GroundMesh;
  50016. /**
  50017. * Creates a polygon mesh
  50018. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50019. * * 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
  50020. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50023. * * Remember you can only change the shape positions, not their number when updating a polygon
  50024. * @param name defines the name of the mesh
  50025. * @param options defines the options used to create the mesh
  50026. * @param scene defines the hosting scene
  50027. * @param earcutInjection can be used to inject your own earcut reference
  50028. * @returns the polygon mesh
  50029. */
  50030. static CreatePolygon(name: string, options: {
  50031. shape: Vector3[];
  50032. holes?: Vector3[][];
  50033. depth?: number;
  50034. faceUV?: Vector4[];
  50035. faceColors?: Color4[];
  50036. updatable?: boolean;
  50037. sideOrientation?: number;
  50038. frontUVs?: Vector4;
  50039. backUVs?: Vector4;
  50040. }, scene: Scene, earcutInjection?: any): Mesh;
  50041. /**
  50042. * Creates an extruded polygon mesh, with depth in the Y direction.
  50043. * * 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)
  50044. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50045. * @param name defines the name of the mesh
  50046. * @param options defines the options used to create the mesh
  50047. * @param scene defines the hosting scene
  50048. * @param earcutInjection can be used to inject your own earcut reference
  50049. * @returns the polygon mesh
  50050. */
  50051. static ExtrudePolygon(name: string, options: {
  50052. shape: Vector3[];
  50053. holes?: Vector3[][];
  50054. depth?: number;
  50055. faceUV?: Vector4[];
  50056. faceColors?: Color4[];
  50057. updatable?: boolean;
  50058. sideOrientation?: number;
  50059. frontUVs?: Vector4;
  50060. backUVs?: Vector4;
  50061. }, scene: Scene, earcutInjection?: any): Mesh;
  50062. /**
  50063. * Creates a tube mesh.
  50064. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50065. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50066. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50067. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50068. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50069. * * 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)
  50070. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50071. * * 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
  50072. * * 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
  50073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50077. * @param name defines the name of the mesh
  50078. * @param options defines the options used to create the mesh
  50079. * @param scene defines the hosting scene
  50080. * @returns the tube mesh
  50081. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50082. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50083. */
  50084. static CreateTube(name: string, options: {
  50085. path: Vector3[];
  50086. radius?: number;
  50087. tessellation?: number;
  50088. radiusFunction?: {
  50089. (i: number, distance: number): number;
  50090. };
  50091. cap?: number;
  50092. arc?: number;
  50093. updatable?: boolean;
  50094. sideOrientation?: number;
  50095. frontUVs?: Vector4;
  50096. backUVs?: Vector4;
  50097. instance?: Mesh;
  50098. invertUV?: boolean;
  50099. }, scene: Scene): Mesh;
  50100. /**
  50101. * Creates a polyhedron mesh
  50102. * * 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
  50103. * * The parameter `size` (positive float, default 1) sets the polygon size
  50104. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50105. * * 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`
  50106. * * 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
  50107. * * 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)`)
  50108. * * 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
  50109. * * 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
  50110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50113. * @param name defines the name of the mesh
  50114. * @param options defines the options used to create the mesh
  50115. * @param scene defines the hosting scene
  50116. * @returns the polyhedron mesh
  50117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50118. */
  50119. static CreatePolyhedron(name: string, options: {
  50120. type?: number;
  50121. size?: number;
  50122. sizeX?: number;
  50123. sizeY?: number;
  50124. sizeZ?: number;
  50125. custom?: any;
  50126. faceUV?: Vector4[];
  50127. faceColors?: Color4[];
  50128. flat?: boolean;
  50129. updatable?: boolean;
  50130. sideOrientation?: number;
  50131. frontUVs?: Vector4;
  50132. backUVs?: Vector4;
  50133. }, scene: Scene): Mesh;
  50134. /**
  50135. * Creates a decal mesh.
  50136. * 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
  50137. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50138. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50139. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50140. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50141. * @param name defines the name of the mesh
  50142. * @param sourceMesh defines the mesh where the decal must be applied
  50143. * @param options defines the options used to create the mesh
  50144. * @param scene defines the hosting scene
  50145. * @returns the decal mesh
  50146. * @see https://doc.babylonjs.com/how_to/decals
  50147. */
  50148. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50149. position?: Vector3;
  50150. normal?: Vector3;
  50151. size?: Vector3;
  50152. angle?: number;
  50153. }): Mesh;
  50154. }
  50155. }
  50156. declare module "babylonjs/Meshes/meshSimplification" {
  50157. import { Mesh } from "babylonjs/Meshes/mesh";
  50158. /**
  50159. * A simplifier interface for future simplification implementations
  50160. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50161. */
  50162. export interface ISimplifier {
  50163. /**
  50164. * Simplification of a given mesh according to the given settings.
  50165. * Since this requires computation, it is assumed that the function runs async.
  50166. * @param settings The settings of the simplification, including quality and distance
  50167. * @param successCallback A callback that will be called after the mesh was simplified.
  50168. * @param errorCallback in case of an error, this callback will be called. optional.
  50169. */
  50170. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50171. }
  50172. /**
  50173. * Expected simplification settings.
  50174. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50175. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50176. */
  50177. export interface ISimplificationSettings {
  50178. /**
  50179. * Gets or sets the expected quality
  50180. */
  50181. quality: number;
  50182. /**
  50183. * Gets or sets the distance when this optimized version should be used
  50184. */
  50185. distance: number;
  50186. /**
  50187. * Gets an already optimized mesh
  50188. */
  50189. optimizeMesh?: boolean;
  50190. }
  50191. /**
  50192. * Class used to specify simplification options
  50193. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50194. */
  50195. export class SimplificationSettings implements ISimplificationSettings {
  50196. /** expected quality */
  50197. quality: number;
  50198. /** distance when this optimized version should be used */
  50199. distance: number;
  50200. /** already optimized mesh */
  50201. optimizeMesh?: boolean | undefined;
  50202. /**
  50203. * Creates a SimplificationSettings
  50204. * @param quality expected quality
  50205. * @param distance distance when this optimized version should be used
  50206. * @param optimizeMesh already optimized mesh
  50207. */
  50208. constructor(
  50209. /** expected quality */
  50210. quality: number,
  50211. /** distance when this optimized version should be used */
  50212. distance: number,
  50213. /** already optimized mesh */
  50214. optimizeMesh?: boolean | undefined);
  50215. }
  50216. /**
  50217. * Interface used to define a simplification task
  50218. */
  50219. export interface ISimplificationTask {
  50220. /**
  50221. * Array of settings
  50222. */
  50223. settings: Array<ISimplificationSettings>;
  50224. /**
  50225. * Simplification type
  50226. */
  50227. simplificationType: SimplificationType;
  50228. /**
  50229. * Mesh to simplify
  50230. */
  50231. mesh: Mesh;
  50232. /**
  50233. * Callback called on success
  50234. */
  50235. successCallback?: () => void;
  50236. /**
  50237. * Defines if parallel processing can be used
  50238. */
  50239. parallelProcessing: boolean;
  50240. }
  50241. /**
  50242. * Queue used to order the simplification tasks
  50243. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50244. */
  50245. export class SimplificationQueue {
  50246. private _simplificationArray;
  50247. /**
  50248. * Gets a boolean indicating that the process is still running
  50249. */
  50250. running: boolean;
  50251. /**
  50252. * Creates a new queue
  50253. */
  50254. constructor();
  50255. /**
  50256. * Adds a new simplification task
  50257. * @param task defines a task to add
  50258. */
  50259. addTask(task: ISimplificationTask): void;
  50260. /**
  50261. * Execute next task
  50262. */
  50263. executeNext(): void;
  50264. /**
  50265. * Execute a simplification task
  50266. * @param task defines the task to run
  50267. */
  50268. runSimplification(task: ISimplificationTask): void;
  50269. private getSimplifier;
  50270. }
  50271. /**
  50272. * The implemented types of simplification
  50273. * At the moment only Quadratic Error Decimation is implemented
  50274. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50275. */
  50276. export enum SimplificationType {
  50277. /** Quadratic error decimation */
  50278. QUADRATIC = 0
  50279. }
  50280. }
  50281. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50282. import { Scene } from "babylonjs/scene";
  50283. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50284. import { ISceneComponent } from "babylonjs/sceneComponent";
  50285. module "babylonjs/scene" {
  50286. interface Scene {
  50287. /** @hidden (Backing field) */
  50288. _simplificationQueue: SimplificationQueue;
  50289. /**
  50290. * Gets or sets the simplification queue attached to the scene
  50291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50292. */
  50293. simplificationQueue: SimplificationQueue;
  50294. }
  50295. }
  50296. module "babylonjs/Meshes/mesh" {
  50297. interface Mesh {
  50298. /**
  50299. * Simplify the mesh according to the given array of settings.
  50300. * Function will return immediately and will simplify async
  50301. * @param settings a collection of simplification settings
  50302. * @param parallelProcessing should all levels calculate parallel or one after the other
  50303. * @param simplificationType the type of simplification to run
  50304. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50305. * @returns the current mesh
  50306. */
  50307. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50308. }
  50309. }
  50310. /**
  50311. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50312. * created in a scene
  50313. */
  50314. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50315. /**
  50316. * The component name helpfull to identify the component in the list of scene components.
  50317. */
  50318. readonly name: string;
  50319. /**
  50320. * The scene the component belongs to.
  50321. */
  50322. scene: Scene;
  50323. /**
  50324. * Creates a new instance of the component for the given scene
  50325. * @param scene Defines the scene to register the component in
  50326. */
  50327. constructor(scene: Scene);
  50328. /**
  50329. * Registers the component in a given scene
  50330. */
  50331. register(): void;
  50332. /**
  50333. * Rebuilds the elements related to this component in case of
  50334. * context lost for instance.
  50335. */
  50336. rebuild(): void;
  50337. /**
  50338. * Disposes the component and the associated ressources
  50339. */
  50340. dispose(): void;
  50341. private _beforeCameraUpdate;
  50342. }
  50343. }
  50344. declare module "babylonjs/Meshes/Builders/index" {
  50345. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50346. export * from "babylonjs/Meshes/Builders/discBuilder";
  50347. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50348. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50349. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50350. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50351. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50352. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50353. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50354. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50355. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50356. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50357. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50358. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50359. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50360. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50361. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50362. }
  50363. declare module "babylonjs/Meshes/index" {
  50364. export * from "babylonjs/Meshes/abstractMesh";
  50365. export * from "babylonjs/Meshes/buffer";
  50366. export * from "babylonjs/Meshes/Compression/index";
  50367. export * from "babylonjs/Meshes/csg";
  50368. export * from "babylonjs/Meshes/geometry";
  50369. export * from "babylonjs/Meshes/groundMesh";
  50370. export * from "babylonjs/Meshes/instancedMesh";
  50371. export * from "babylonjs/Meshes/linesMesh";
  50372. export * from "babylonjs/Meshes/mesh";
  50373. export * from "babylonjs/Meshes/mesh.vertexData";
  50374. export * from "babylonjs/Meshes/meshBuilder";
  50375. export * from "babylonjs/Meshes/meshSimplification";
  50376. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50377. export * from "babylonjs/Meshes/polygonMesh";
  50378. export * from "babylonjs/Meshes/subMesh";
  50379. export * from "babylonjs/Meshes/transformNode";
  50380. export * from "babylonjs/Meshes/Builders/index";
  50381. }
  50382. declare module "babylonjs/Morph/index" {
  50383. export * from "babylonjs/Morph/morphTarget";
  50384. export * from "babylonjs/Morph/morphTargetManager";
  50385. }
  50386. declare module "babylonjs/Offline/database" {
  50387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50388. /**
  50389. * Class used to enable access to IndexedDB
  50390. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50391. */
  50392. export class Database implements IOfflineProvider {
  50393. private _callbackManifestChecked;
  50394. private _currentSceneUrl;
  50395. private _db;
  50396. private _enableSceneOffline;
  50397. private _enableTexturesOffline;
  50398. private _manifestVersionFound;
  50399. private _mustUpdateRessources;
  50400. private _hasReachedQuota;
  50401. private _isSupported;
  50402. private _idbFactory;
  50403. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50404. private static IsUASupportingBlobStorage;
  50405. /**
  50406. * Gets a boolean indicating if Database storate is enabled (off by default)
  50407. */
  50408. static IDBStorageEnabled: boolean;
  50409. /**
  50410. * Gets a boolean indicating if scene must be saved in the database
  50411. */
  50412. readonly enableSceneOffline: boolean;
  50413. /**
  50414. * Gets a boolean indicating if textures must be saved in the database
  50415. */
  50416. readonly enableTexturesOffline: boolean;
  50417. /**
  50418. * Creates a new Database
  50419. * @param urlToScene defines the url to load the scene
  50420. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50421. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50422. */
  50423. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50424. private static _ParseURL;
  50425. private static _ReturnFullUrlLocation;
  50426. private _checkManifestFile;
  50427. /**
  50428. * Open the database and make it available
  50429. * @param successCallback defines the callback to call on success
  50430. * @param errorCallback defines the callback to call on error
  50431. */
  50432. open(successCallback: () => void, errorCallback: () => void): void;
  50433. /**
  50434. * Loads an image from the database
  50435. * @param url defines the url to load from
  50436. * @param image defines the target DOM image
  50437. */
  50438. loadImage(url: string, image: HTMLImageElement): void;
  50439. private _loadImageFromDBAsync;
  50440. private _saveImageIntoDBAsync;
  50441. private _checkVersionFromDB;
  50442. private _loadVersionFromDBAsync;
  50443. private _saveVersionIntoDBAsync;
  50444. /**
  50445. * Loads a file from database
  50446. * @param url defines the URL to load from
  50447. * @param sceneLoaded defines a callback to call on success
  50448. * @param progressCallBack defines a callback to call when progress changed
  50449. * @param errorCallback defines a callback to call on error
  50450. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50451. */
  50452. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50453. private _loadFileAsync;
  50454. private _saveFileAsync;
  50455. /**
  50456. * Validates if xhr data is correct
  50457. * @param xhr defines the request to validate
  50458. * @param dataType defines the expected data type
  50459. * @returns true if data is correct
  50460. */
  50461. private static _ValidateXHRData;
  50462. }
  50463. }
  50464. declare module "babylonjs/Offline/index" {
  50465. export * from "babylonjs/Offline/database";
  50466. export * from "babylonjs/Offline/IOfflineProvider";
  50467. }
  50468. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50469. /** @hidden */
  50470. export var gpuUpdateParticlesPixelShader: {
  50471. name: string;
  50472. shader: string;
  50473. };
  50474. }
  50475. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50476. /** @hidden */
  50477. export var gpuUpdateParticlesVertexShader: {
  50478. name: string;
  50479. shader: string;
  50480. };
  50481. }
  50482. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50483. /** @hidden */
  50484. export var clipPlaneFragmentDeclaration2: {
  50485. name: string;
  50486. shader: string;
  50487. };
  50488. }
  50489. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50490. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50491. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50493. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50495. /** @hidden */
  50496. export var gpuRenderParticlesPixelShader: {
  50497. name: string;
  50498. shader: string;
  50499. };
  50500. }
  50501. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50502. /** @hidden */
  50503. export var clipPlaneVertexDeclaration2: {
  50504. name: string;
  50505. shader: string;
  50506. };
  50507. }
  50508. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50510. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50511. /** @hidden */
  50512. export var gpuRenderParticlesVertexShader: {
  50513. name: string;
  50514. shader: string;
  50515. };
  50516. }
  50517. declare module "babylonjs/Particles/gpuParticleSystem" {
  50518. import { Nullable } from "babylonjs/types";
  50519. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50520. import { Observable } from "babylonjs/Misc/observable";
  50521. import { Color4, Color3 } from "babylonjs/Maths/math";
  50522. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50523. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50524. import { Scene, IDisposable } from "babylonjs/scene";
  50525. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50526. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50527. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50528. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50529. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50530. /**
  50531. * This represents a GPU particle system in Babylon
  50532. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50533. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50534. */
  50535. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50536. /**
  50537. * The layer mask we are rendering the particles through.
  50538. */
  50539. layerMask: number;
  50540. private _capacity;
  50541. private _activeCount;
  50542. private _currentActiveCount;
  50543. private _accumulatedCount;
  50544. private _renderEffect;
  50545. private _updateEffect;
  50546. private _buffer0;
  50547. private _buffer1;
  50548. private _spriteBuffer;
  50549. private _updateVAO;
  50550. private _renderVAO;
  50551. private _targetIndex;
  50552. private _sourceBuffer;
  50553. private _targetBuffer;
  50554. private _engine;
  50555. private _currentRenderId;
  50556. private _started;
  50557. private _stopped;
  50558. private _timeDelta;
  50559. private _randomTexture;
  50560. private _randomTexture2;
  50561. private _attributesStrideSize;
  50562. private _updateEffectOptions;
  50563. private _randomTextureSize;
  50564. private _actualFrame;
  50565. private readonly _rawTextureWidth;
  50566. /**
  50567. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50568. */
  50569. static readonly IsSupported: boolean;
  50570. /**
  50571. * An event triggered when the system is disposed.
  50572. */
  50573. onDisposeObservable: Observable<GPUParticleSystem>;
  50574. /**
  50575. * Gets the maximum number of particles active at the same time.
  50576. * @returns The max number of active particles.
  50577. */
  50578. getCapacity(): number;
  50579. /**
  50580. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50581. * to override the particles.
  50582. */
  50583. forceDepthWrite: boolean;
  50584. /**
  50585. * Gets or set the number of active particles
  50586. */
  50587. activeParticleCount: number;
  50588. private _preWarmDone;
  50589. /**
  50590. * Is this system ready to be used/rendered
  50591. * @return true if the system is ready
  50592. */
  50593. isReady(): boolean;
  50594. /**
  50595. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50596. * @returns True if it has been started, otherwise false.
  50597. */
  50598. isStarted(): boolean;
  50599. /**
  50600. * Starts the particle system and begins to emit
  50601. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50602. */
  50603. start(delay?: number): void;
  50604. /**
  50605. * Stops the particle system.
  50606. */
  50607. stop(): void;
  50608. /**
  50609. * Remove all active particles
  50610. */
  50611. reset(): void;
  50612. /**
  50613. * Returns the string "GPUParticleSystem"
  50614. * @returns a string containing the class name
  50615. */
  50616. getClassName(): string;
  50617. private _colorGradientsTexture;
  50618. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50619. /**
  50620. * Adds a new color gradient
  50621. * @param gradient defines the gradient to use (between 0 and 1)
  50622. * @param color1 defines the color to affect to the specified gradient
  50623. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50624. * @returns the current particle system
  50625. */
  50626. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50627. /**
  50628. * Remove a specific color gradient
  50629. * @param gradient defines the gradient to remove
  50630. * @returns the current particle system
  50631. */
  50632. removeColorGradient(gradient: number): GPUParticleSystem;
  50633. private _angularSpeedGradientsTexture;
  50634. private _sizeGradientsTexture;
  50635. private _velocityGradientsTexture;
  50636. private _limitVelocityGradientsTexture;
  50637. private _dragGradientsTexture;
  50638. private _addFactorGradient;
  50639. /**
  50640. * Adds a new size gradient
  50641. * @param gradient defines the gradient to use (between 0 and 1)
  50642. * @param factor defines the size factor to affect to the specified gradient
  50643. * @returns the current particle system
  50644. */
  50645. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50646. /**
  50647. * Remove a specific size gradient
  50648. * @param gradient defines the gradient to remove
  50649. * @returns the current particle system
  50650. */
  50651. removeSizeGradient(gradient: number): GPUParticleSystem;
  50652. /**
  50653. * Adds a new angular speed gradient
  50654. * @param gradient defines the gradient to use (between 0 and 1)
  50655. * @param factor defines the angular speed to affect to the specified gradient
  50656. * @returns the current particle system
  50657. */
  50658. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50659. /**
  50660. * Remove a specific angular speed gradient
  50661. * @param gradient defines the gradient to remove
  50662. * @returns the current particle system
  50663. */
  50664. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50665. /**
  50666. * Adds a new velocity gradient
  50667. * @param gradient defines the gradient to use (between 0 and 1)
  50668. * @param factor defines the velocity to affect to the specified gradient
  50669. * @returns the current particle system
  50670. */
  50671. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50672. /**
  50673. * Remove a specific velocity gradient
  50674. * @param gradient defines the gradient to remove
  50675. * @returns the current particle system
  50676. */
  50677. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50678. /**
  50679. * Adds a new limit velocity gradient
  50680. * @param gradient defines the gradient to use (between 0 and 1)
  50681. * @param factor defines the limit velocity value to affect to the specified gradient
  50682. * @returns the current particle system
  50683. */
  50684. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50685. /**
  50686. * Remove a specific limit velocity gradient
  50687. * @param gradient defines the gradient to remove
  50688. * @returns the current particle system
  50689. */
  50690. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50691. /**
  50692. * Adds a new drag gradient
  50693. * @param gradient defines the gradient to use (between 0 and 1)
  50694. * @param factor defines the drag value to affect to the specified gradient
  50695. * @returns the current particle system
  50696. */
  50697. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50698. /**
  50699. * Remove a specific drag gradient
  50700. * @param gradient defines the gradient to remove
  50701. * @returns the current particle system
  50702. */
  50703. removeDragGradient(gradient: number): GPUParticleSystem;
  50704. /**
  50705. * Not supported by GPUParticleSystem
  50706. * @param gradient defines the gradient to use (between 0 and 1)
  50707. * @param factor defines the emit rate value to affect to the specified gradient
  50708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50709. * @returns the current particle system
  50710. */
  50711. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50712. /**
  50713. * Not supported by GPUParticleSystem
  50714. * @param gradient defines the gradient to remove
  50715. * @returns the current particle system
  50716. */
  50717. removeEmitRateGradient(gradient: number): IParticleSystem;
  50718. /**
  50719. * Not supported by GPUParticleSystem
  50720. * @param gradient defines the gradient to use (between 0 and 1)
  50721. * @param factor defines the start size value to affect to the specified gradient
  50722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50723. * @returns the current particle system
  50724. */
  50725. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50726. /**
  50727. * Not supported by GPUParticleSystem
  50728. * @param gradient defines the gradient to remove
  50729. * @returns the current particle system
  50730. */
  50731. removeStartSizeGradient(gradient: number): IParticleSystem;
  50732. /**
  50733. * Not supported by GPUParticleSystem
  50734. * @param gradient defines the gradient to use (between 0 and 1)
  50735. * @param min defines the color remap minimal range
  50736. * @param max defines the color remap maximal range
  50737. * @returns the current particle system
  50738. */
  50739. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50740. /**
  50741. * Not supported by GPUParticleSystem
  50742. * @param gradient defines the gradient to remove
  50743. * @returns the current particle system
  50744. */
  50745. removeColorRemapGradient(): IParticleSystem;
  50746. /**
  50747. * Not supported by GPUParticleSystem
  50748. * @param gradient defines the gradient to use (between 0 and 1)
  50749. * @param min defines the alpha remap minimal range
  50750. * @param max defines the alpha remap maximal range
  50751. * @returns the current particle system
  50752. */
  50753. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50754. /**
  50755. * Not supported by GPUParticleSystem
  50756. * @param gradient defines the gradient to remove
  50757. * @returns the current particle system
  50758. */
  50759. removeAlphaRemapGradient(): IParticleSystem;
  50760. /**
  50761. * Not supported by GPUParticleSystem
  50762. * @param gradient defines the gradient to use (between 0 and 1)
  50763. * @param color defines the color to affect to the specified gradient
  50764. * @returns the current particle system
  50765. */
  50766. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50767. /**
  50768. * Not supported by GPUParticleSystem
  50769. * @param gradient defines the gradient to remove
  50770. * @returns the current particle system
  50771. */
  50772. removeRampGradient(): IParticleSystem;
  50773. /**
  50774. * Not supported by GPUParticleSystem
  50775. * @returns the list of ramp gradients
  50776. */
  50777. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50778. /**
  50779. * Not supported by GPUParticleSystem
  50780. * Gets or sets a boolean indicating that ramp gradients must be used
  50781. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50782. */
  50783. useRampGradients: boolean;
  50784. /**
  50785. * Not supported by GPUParticleSystem
  50786. * @param gradient defines the gradient to use (between 0 and 1)
  50787. * @param factor defines the life time factor to affect to the specified gradient
  50788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50789. * @returns the current particle system
  50790. */
  50791. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50792. /**
  50793. * Not supported by GPUParticleSystem
  50794. * @param gradient defines the gradient to remove
  50795. * @returns the current particle system
  50796. */
  50797. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50798. /**
  50799. * Instantiates a GPU particle system.
  50800. * 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.
  50801. * @param name The name of the particle system
  50802. * @param options The options used to create the system
  50803. * @param scene The scene the particle system belongs to
  50804. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50805. */
  50806. constructor(name: string, options: Partial<{
  50807. capacity: number;
  50808. randomTextureSize: number;
  50809. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50810. protected _reset(): void;
  50811. private _createUpdateVAO;
  50812. private _createRenderVAO;
  50813. private _initialize;
  50814. /** @hidden */
  50815. _recreateUpdateEffect(): void;
  50816. /** @hidden */
  50817. _recreateRenderEffect(): void;
  50818. /**
  50819. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50820. * @param preWarm defines if we are in the pre-warmimg phase
  50821. */
  50822. animate(preWarm?: boolean): void;
  50823. private _createFactorGradientTexture;
  50824. private _createSizeGradientTexture;
  50825. private _createAngularSpeedGradientTexture;
  50826. private _createVelocityGradientTexture;
  50827. private _createLimitVelocityGradientTexture;
  50828. private _createDragGradientTexture;
  50829. private _createColorGradientTexture;
  50830. /**
  50831. * Renders the particle system in its current state
  50832. * @param preWarm defines if the system should only update the particles but not render them
  50833. * @returns the current number of particles
  50834. */
  50835. render(preWarm?: boolean): number;
  50836. /**
  50837. * Rebuilds the particle system
  50838. */
  50839. rebuild(): void;
  50840. private _releaseBuffers;
  50841. private _releaseVAOs;
  50842. /**
  50843. * Disposes the particle system and free the associated resources
  50844. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50845. */
  50846. dispose(disposeTexture?: boolean): void;
  50847. /**
  50848. * Clones the particle system.
  50849. * @param name The name of the cloned object
  50850. * @param newEmitter The new emitter to use
  50851. * @returns the cloned particle system
  50852. */
  50853. clone(name: string, newEmitter: any): GPUParticleSystem;
  50854. /**
  50855. * Serializes the particle system to a JSON object.
  50856. * @returns the JSON object
  50857. */
  50858. serialize(): any;
  50859. /**
  50860. * Parses a JSON object to create a GPU particle system.
  50861. * @param parsedParticleSystem The JSON object to parse
  50862. * @param scene The scene to create the particle system in
  50863. * @param rootUrl The root url to use to load external dependencies like texture
  50864. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50865. * @returns the parsed GPU particle system
  50866. */
  50867. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50868. }
  50869. }
  50870. declare module "babylonjs/Particles/particleSystemSet" {
  50871. import { Nullable } from "babylonjs/types";
  50872. import { Color3 } from "babylonjs/Maths/math";
  50873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50876. import { Scene, IDisposable } from "babylonjs/scene";
  50877. /**
  50878. * Represents a set of particle systems working together to create a specific effect
  50879. */
  50880. export class ParticleSystemSet implements IDisposable {
  50881. private _emitterCreationOptions;
  50882. private _emitterNode;
  50883. /**
  50884. * Gets the particle system list
  50885. */
  50886. systems: IParticleSystem[];
  50887. /**
  50888. * Gets the emitter node used with this set
  50889. */
  50890. readonly emitterNode: Nullable<TransformNode>;
  50891. /**
  50892. * Creates a new emitter mesh as a sphere
  50893. * @param options defines the options used to create the sphere
  50894. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50895. * @param scene defines the hosting scene
  50896. */
  50897. setEmitterAsSphere(options: {
  50898. diameter: number;
  50899. segments: number;
  50900. color: Color3;
  50901. }, renderingGroupId: number, scene: Scene): void;
  50902. /**
  50903. * Starts all particle systems of the set
  50904. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50905. */
  50906. start(emitter?: AbstractMesh): void;
  50907. /**
  50908. * Release all associated resources
  50909. */
  50910. dispose(): void;
  50911. /**
  50912. * Serialize the set into a JSON compatible object
  50913. * @returns a JSON compatible representation of the set
  50914. */
  50915. serialize(): any;
  50916. /**
  50917. * Parse a new ParticleSystemSet from a serialized source
  50918. * @param data defines a JSON compatible representation of the set
  50919. * @param scene defines the hosting scene
  50920. * @param gpu defines if we want GPU particles or CPU particles
  50921. * @returns a new ParticleSystemSet
  50922. */
  50923. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50924. }
  50925. }
  50926. declare module "babylonjs/Particles/particleHelper" {
  50927. import { Nullable } from "babylonjs/types";
  50928. import { Scene } from "babylonjs/scene";
  50929. import { Vector3 } from "babylonjs/Maths/math";
  50930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50931. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50932. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50933. /**
  50934. * This class is made for on one-liner static method to help creating particle system set.
  50935. */
  50936. export class ParticleHelper {
  50937. /**
  50938. * Gets or sets base Assets URL
  50939. */
  50940. static BaseAssetsUrl: string;
  50941. /**
  50942. * Create a default particle system that you can tweak
  50943. * @param emitter defines the emitter to use
  50944. * @param capacity defines the system capacity (default is 500 particles)
  50945. * @param scene defines the hosting scene
  50946. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50947. * @returns the new Particle system
  50948. */
  50949. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50950. /**
  50951. * This is the main static method (one-liner) of this helper to create different particle systems
  50952. * @param type This string represents the type to the particle system to create
  50953. * @param scene The scene where the particle system should live
  50954. * @param gpu If the system will use gpu
  50955. * @returns the ParticleSystemSet created
  50956. */
  50957. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50958. /**
  50959. * Static function used to export a particle system to a ParticleSystemSet variable.
  50960. * Please note that the emitter shape is not exported
  50961. * @param systems defines the particle systems to export
  50962. * @returns the created particle system set
  50963. */
  50964. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50965. }
  50966. }
  50967. declare module "babylonjs/Particles/particleSystemComponent" {
  50968. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50969. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50970. import "babylonjs/Shaders/particles.vertex";
  50971. module "babylonjs/Engines/engine" {
  50972. interface Engine {
  50973. /**
  50974. * Create an effect to use with particle systems.
  50975. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50976. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50977. * @param uniformsNames defines a list of attribute names
  50978. * @param samplers defines an array of string used to represent textures
  50979. * @param defines defines the string containing the defines to use to compile the shaders
  50980. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50981. * @param onCompiled defines a function to call when the effect creation is successful
  50982. * @param onError defines a function to call when the effect creation has failed
  50983. * @returns the new Effect
  50984. */
  50985. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50986. }
  50987. }
  50988. module "babylonjs/Meshes/mesh" {
  50989. interface Mesh {
  50990. /**
  50991. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50992. * @returns an array of IParticleSystem
  50993. */
  50994. getEmittedParticleSystems(): IParticleSystem[];
  50995. /**
  50996. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50997. * @returns an array of IParticleSystem
  50998. */
  50999. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51000. }
  51001. }
  51002. /**
  51003. * @hidden
  51004. */
  51005. export var _IDoNeedToBeInTheBuild: number;
  51006. }
  51007. declare module "babylonjs/Particles/index" {
  51008. export * from "babylonjs/Particles/baseParticleSystem";
  51009. export * from "babylonjs/Particles/EmitterTypes/index";
  51010. export * from "babylonjs/Particles/gpuParticleSystem";
  51011. export * from "babylonjs/Particles/IParticleSystem";
  51012. export * from "babylonjs/Particles/particle";
  51013. export * from "babylonjs/Particles/particleHelper";
  51014. export * from "babylonjs/Particles/particleSystem";
  51015. export * from "babylonjs/Particles/particleSystemComponent";
  51016. export * from "babylonjs/Particles/particleSystemSet";
  51017. export * from "babylonjs/Particles/solidParticle";
  51018. export * from "babylonjs/Particles/solidParticleSystem";
  51019. export * from "babylonjs/Particles/subEmitter";
  51020. }
  51021. declare module "babylonjs/Physics/physicsEngineComponent" {
  51022. import { Nullable } from "babylonjs/types";
  51023. import { Observable, Observer } from "babylonjs/Misc/observable";
  51024. import { Vector3 } from "babylonjs/Maths/math";
  51025. import { Mesh } from "babylonjs/Meshes/mesh";
  51026. import { ISceneComponent } from "babylonjs/sceneComponent";
  51027. import { Scene } from "babylonjs/scene";
  51028. import { Node } from "babylonjs/node";
  51029. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51030. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51031. module "babylonjs/scene" {
  51032. interface Scene {
  51033. /** @hidden (Backing field) */
  51034. _physicsEngine: Nullable<IPhysicsEngine>;
  51035. /**
  51036. * Gets the current physics engine
  51037. * @returns a IPhysicsEngine or null if none attached
  51038. */
  51039. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51040. /**
  51041. * Enables physics to the current scene
  51042. * @param gravity defines the scene's gravity for the physics engine
  51043. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51044. * @return a boolean indicating if the physics engine was initialized
  51045. */
  51046. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51047. /**
  51048. * Disables and disposes the physics engine associated with the scene
  51049. */
  51050. disablePhysicsEngine(): void;
  51051. /**
  51052. * Gets a boolean indicating if there is an active physics engine
  51053. * @returns a boolean indicating if there is an active physics engine
  51054. */
  51055. isPhysicsEnabled(): boolean;
  51056. /**
  51057. * Deletes a physics compound impostor
  51058. * @param compound defines the compound to delete
  51059. */
  51060. deleteCompoundImpostor(compound: any): void;
  51061. /**
  51062. * An event triggered when physic simulation is about to be run
  51063. */
  51064. onBeforePhysicsObservable: Observable<Scene>;
  51065. /**
  51066. * An event triggered when physic simulation has been done
  51067. */
  51068. onAfterPhysicsObservable: Observable<Scene>;
  51069. }
  51070. }
  51071. module "babylonjs/Meshes/abstractMesh" {
  51072. interface AbstractMesh {
  51073. /** @hidden */
  51074. _physicsImpostor: Nullable<PhysicsImpostor>;
  51075. /**
  51076. * Gets or sets impostor used for physic simulation
  51077. * @see http://doc.babylonjs.com/features/physics_engine
  51078. */
  51079. physicsImpostor: Nullable<PhysicsImpostor>;
  51080. /**
  51081. * Gets the current physics impostor
  51082. * @see http://doc.babylonjs.com/features/physics_engine
  51083. * @returns a physics impostor or null
  51084. */
  51085. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51086. /** Apply a physic impulse to the mesh
  51087. * @param force defines the force to apply
  51088. * @param contactPoint defines where to apply the force
  51089. * @returns the current mesh
  51090. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51091. */
  51092. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51093. /**
  51094. * Creates a physic joint between two meshes
  51095. * @param otherMesh defines the other mesh to use
  51096. * @param pivot1 defines the pivot to use on this mesh
  51097. * @param pivot2 defines the pivot to use on the other mesh
  51098. * @param options defines additional options (can be plugin dependent)
  51099. * @returns the current mesh
  51100. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51101. */
  51102. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51103. /** @hidden */
  51104. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51105. }
  51106. }
  51107. /**
  51108. * Defines the physics engine scene component responsible to manage a physics engine
  51109. */
  51110. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51111. /**
  51112. * The component name helpful to identify the component in the list of scene components.
  51113. */
  51114. readonly name: string;
  51115. /**
  51116. * The scene the component belongs to.
  51117. */
  51118. scene: Scene;
  51119. /**
  51120. * Creates a new instance of the component for the given scene
  51121. * @param scene Defines the scene to register the component in
  51122. */
  51123. constructor(scene: Scene);
  51124. /**
  51125. * Registers the component in a given scene
  51126. */
  51127. register(): void;
  51128. /**
  51129. * Rebuilds the elements related to this component in case of
  51130. * context lost for instance.
  51131. */
  51132. rebuild(): void;
  51133. /**
  51134. * Disposes the component and the associated ressources
  51135. */
  51136. dispose(): void;
  51137. }
  51138. }
  51139. declare module "babylonjs/Physics/physicsHelper" {
  51140. import { Nullable } from "babylonjs/types";
  51141. import { Vector3 } from "babylonjs/Maths/math";
  51142. import { Mesh } from "babylonjs/Meshes/mesh";
  51143. import { Ray } from "babylonjs/Culling/ray";
  51144. import { Scene } from "babylonjs/scene";
  51145. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51146. /**
  51147. * A helper for physics simulations
  51148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51149. */
  51150. export class PhysicsHelper {
  51151. private _scene;
  51152. private _physicsEngine;
  51153. /**
  51154. * Initializes the Physics helper
  51155. * @param scene Babylon.js scene
  51156. */
  51157. constructor(scene: Scene);
  51158. /**
  51159. * Applies a radial explosion impulse
  51160. * @param origin the origin of the explosion
  51161. * @param radius the explosion radius
  51162. * @param strength the explosion strength
  51163. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51164. * @returns A physics radial explosion event, or null
  51165. */
  51166. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51167. /**
  51168. * Applies a radial explosion force
  51169. * @param origin the origin of the explosion
  51170. * @param radius the explosion radius
  51171. * @param strength the explosion strength
  51172. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51173. * @returns A physics radial explosion event, or null
  51174. */
  51175. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51176. /**
  51177. * Creates a gravitational field
  51178. * @param origin the origin of the explosion
  51179. * @param radius the explosion radius
  51180. * @param strength the explosion strength
  51181. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51182. * @returns A physics gravitational field event, or null
  51183. */
  51184. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51185. /**
  51186. * Creates a physics updraft event
  51187. * @param origin the origin of the updraft
  51188. * @param radius the radius of the updraft
  51189. * @param strength the strength of the updraft
  51190. * @param height the height of the updraft
  51191. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51192. * @returns A physics updraft event, or null
  51193. */
  51194. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51195. /**
  51196. * Creates a physics vortex event
  51197. * @param origin the of the vortex
  51198. * @param radius the radius of the vortex
  51199. * @param strength the strength of the vortex
  51200. * @param height the height of the vortex
  51201. * @returns a Physics vortex event, or null
  51202. * A physics vortex event or null
  51203. */
  51204. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51205. }
  51206. /**
  51207. * Represents a physics radial explosion event
  51208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51209. */
  51210. export class PhysicsRadialExplosionEvent {
  51211. private _scene;
  51212. private _sphere;
  51213. private _sphereOptions;
  51214. private _rays;
  51215. private _dataFetched;
  51216. /**
  51217. * Initializes a radial explosioin event
  51218. * @param scene BabylonJS scene
  51219. */
  51220. constructor(scene: Scene);
  51221. /**
  51222. * Returns the data related to the radial explosion event (sphere & rays).
  51223. * @returns The radial explosion event data
  51224. */
  51225. getData(): PhysicsRadialExplosionEventData;
  51226. /**
  51227. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51228. * @param impostor A physics imposter
  51229. * @param origin the origin of the explosion
  51230. * @param radius the explosion radius
  51231. * @param strength the explosion strength
  51232. * @param falloff possible options: Constant & Linear
  51233. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51234. */
  51235. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51236. /**
  51237. * Disposes the sphere.
  51238. * @param force Specifies if the sphere should be disposed by force
  51239. */
  51240. dispose(force?: boolean): void;
  51241. /*** Helpers ***/
  51242. private _prepareSphere;
  51243. private _intersectsWithSphere;
  51244. }
  51245. /**
  51246. * Represents a gravitational field event
  51247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51248. */
  51249. export class PhysicsGravitationalFieldEvent {
  51250. private _physicsHelper;
  51251. private _scene;
  51252. private _origin;
  51253. private _radius;
  51254. private _strength;
  51255. private _falloff;
  51256. private _tickCallback;
  51257. private _sphere;
  51258. private _dataFetched;
  51259. /**
  51260. * Initializes the physics gravitational field event
  51261. * @param physicsHelper A physics helper
  51262. * @param scene BabylonJS scene
  51263. * @param origin The origin position of the gravitational field event
  51264. * @param radius The radius of the gravitational field event
  51265. * @param strength The strength of the gravitational field event
  51266. * @param falloff The falloff for the gravitational field event
  51267. */
  51268. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51269. /**
  51270. * Returns the data related to the gravitational field event (sphere).
  51271. * @returns A gravitational field event
  51272. */
  51273. getData(): PhysicsGravitationalFieldEventData;
  51274. /**
  51275. * Enables the gravitational field.
  51276. */
  51277. enable(): void;
  51278. /**
  51279. * Disables the gravitational field.
  51280. */
  51281. disable(): void;
  51282. /**
  51283. * Disposes the sphere.
  51284. * @param force The force to dispose from the gravitational field event
  51285. */
  51286. dispose(force?: boolean): void;
  51287. private _tick;
  51288. }
  51289. /**
  51290. * Represents a physics updraft event
  51291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51292. */
  51293. export class PhysicsUpdraftEvent {
  51294. private _scene;
  51295. private _origin;
  51296. private _radius;
  51297. private _strength;
  51298. private _height;
  51299. private _updraftMode;
  51300. private _physicsEngine;
  51301. private _originTop;
  51302. private _originDirection;
  51303. private _tickCallback;
  51304. private _cylinder;
  51305. private _cylinderPosition;
  51306. private _dataFetched;
  51307. /**
  51308. * Initializes the physics updraft event
  51309. * @param _scene BabylonJS scene
  51310. * @param _origin The origin position of the updraft
  51311. * @param _radius The radius of the updraft
  51312. * @param _strength The strength of the updraft
  51313. * @param _height The height of the updraft
  51314. * @param _updraftMode The mode of the updraft
  51315. */
  51316. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51317. /**
  51318. * Returns the data related to the updraft event (cylinder).
  51319. * @returns A physics updraft event
  51320. */
  51321. getData(): PhysicsUpdraftEventData;
  51322. /**
  51323. * Enables the updraft.
  51324. */
  51325. enable(): void;
  51326. /**
  51327. * Disables the cortex.
  51328. */
  51329. disable(): void;
  51330. /**
  51331. * Disposes the sphere.
  51332. * @param force Specifies if the updraft should be disposed by force
  51333. */
  51334. dispose(force?: boolean): void;
  51335. private getImpostorForceAndContactPoint;
  51336. private _tick;
  51337. /*** Helpers ***/
  51338. private _prepareCylinder;
  51339. private _intersectsWithCylinder;
  51340. }
  51341. /**
  51342. * Represents a physics vortex event
  51343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51344. */
  51345. export class PhysicsVortexEvent {
  51346. private _scene;
  51347. private _origin;
  51348. private _radius;
  51349. private _strength;
  51350. private _height;
  51351. private _physicsEngine;
  51352. private _originTop;
  51353. private _centripetalForceThreshold;
  51354. private _updraftMultiplier;
  51355. private _tickCallback;
  51356. private _cylinder;
  51357. private _cylinderPosition;
  51358. private _dataFetched;
  51359. /**
  51360. * Initializes the physics vortex event
  51361. * @param _scene The BabylonJS scene
  51362. * @param _origin The origin position of the vortex
  51363. * @param _radius The radius of the vortex
  51364. * @param _strength The strength of the vortex
  51365. * @param _height The height of the vortex
  51366. */
  51367. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51368. /**
  51369. * Returns the data related to the vortex event (cylinder).
  51370. * @returns The physics vortex event data
  51371. */
  51372. getData(): PhysicsVortexEventData;
  51373. /**
  51374. * Enables the vortex.
  51375. */
  51376. enable(): void;
  51377. /**
  51378. * Disables the cortex.
  51379. */
  51380. disable(): void;
  51381. /**
  51382. * Disposes the sphere.
  51383. * @param force
  51384. */
  51385. dispose(force?: boolean): void;
  51386. private getImpostorForceAndContactPoint;
  51387. private _tick;
  51388. /*** Helpers ***/
  51389. private _prepareCylinder;
  51390. private _intersectsWithCylinder;
  51391. }
  51392. /**
  51393. * The strenght of the force in correspondence to the distance of the affected object
  51394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51395. */
  51396. export enum PhysicsRadialImpulseFalloff {
  51397. /** Defines that impulse is constant in strength across it's whole radius */
  51398. Constant = 0,
  51399. /** DEfines that impulse gets weaker if it's further from the origin */
  51400. Linear = 1
  51401. }
  51402. /**
  51403. * The strength of the force in correspondence to the distance of the affected object
  51404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51405. */
  51406. export enum PhysicsUpdraftMode {
  51407. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51408. Center = 0,
  51409. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51410. Perpendicular = 1
  51411. }
  51412. /**
  51413. * Interface for a physics force and contact point
  51414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51415. */
  51416. export interface PhysicsForceAndContactPoint {
  51417. /**
  51418. * The force applied at the contact point
  51419. */
  51420. force: Vector3;
  51421. /**
  51422. * The contact point
  51423. */
  51424. contactPoint: Vector3;
  51425. }
  51426. /**
  51427. * Interface for radial explosion event data
  51428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51429. */
  51430. export interface PhysicsRadialExplosionEventData {
  51431. /**
  51432. * A sphere used for the radial explosion event
  51433. */
  51434. sphere: Mesh;
  51435. /**
  51436. * An array of rays for the radial explosion event
  51437. */
  51438. rays: Array<Ray>;
  51439. }
  51440. /**
  51441. * Interface for gravitational field event data
  51442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51443. */
  51444. export interface PhysicsGravitationalFieldEventData {
  51445. /**
  51446. * A sphere mesh used for the gravitational field event
  51447. */
  51448. sphere: Mesh;
  51449. }
  51450. /**
  51451. * Interface for updraft event data
  51452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51453. */
  51454. export interface PhysicsUpdraftEventData {
  51455. /**
  51456. * A cylinder used for the updraft event
  51457. */
  51458. cylinder: Mesh;
  51459. }
  51460. /**
  51461. * Interface for vortex event data
  51462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51463. */
  51464. export interface PhysicsVortexEventData {
  51465. /**
  51466. * A cylinder used for the vortex event
  51467. */
  51468. cylinder: Mesh;
  51469. }
  51470. }
  51471. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51472. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51473. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51474. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51475. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51476. import { Nullable } from "babylonjs/types";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. /**
  51479. * AmmoJS Physics plugin
  51480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51481. * @see https://github.com/kripken/ammo.js/
  51482. */
  51483. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51484. private _useDeltaForWorldStep;
  51485. /**
  51486. * Reference to the Ammo library
  51487. */
  51488. bjsAMMO: any;
  51489. /**
  51490. * Created ammoJS world which physics bodies are added to
  51491. */
  51492. world: any;
  51493. /**
  51494. * Name of the plugin
  51495. */
  51496. name: string;
  51497. private _timeStep;
  51498. private _fixedTimeStep;
  51499. private _maxSteps;
  51500. private _tmpQuaternion;
  51501. private _tmpAmmoTransform;
  51502. private _tmpAmmoQuaternion;
  51503. private _tmpAmmoConcreteContactResultCallback;
  51504. private _collisionConfiguration;
  51505. private _dispatcher;
  51506. private _overlappingPairCache;
  51507. private _solver;
  51508. private _tmpAmmoVectorA;
  51509. private _tmpAmmoVectorB;
  51510. private _tmpAmmoVectorC;
  51511. private _tmpContactCallbackResult;
  51512. private static readonly DISABLE_COLLISION_FLAG;
  51513. private static readonly KINEMATIC_FLAG;
  51514. private static readonly DISABLE_DEACTIVATION_FLAG;
  51515. /**
  51516. * Initializes the ammoJS plugin
  51517. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51518. * @param ammoInjection can be used to inject your own ammo reference
  51519. */
  51520. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51521. /**
  51522. * Sets the gravity of the physics world (m/(s^2))
  51523. * @param gravity Gravity to set
  51524. */
  51525. setGravity(gravity: Vector3): void;
  51526. /**
  51527. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51528. * @param timeStep timestep to use in seconds
  51529. */
  51530. setTimeStep(timeStep: number): void;
  51531. /**
  51532. * 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)
  51533. * @param fixedTimeStep fixedTimeStep to use in seconds
  51534. */
  51535. setFixedTimeStep(fixedTimeStep: number): void;
  51536. /**
  51537. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51538. * @param maxSteps the maximum number of steps by the physics engine per frame
  51539. */
  51540. setMaxSteps(maxSteps: number): void;
  51541. /**
  51542. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51543. * @returns the current timestep in seconds
  51544. */
  51545. getTimeStep(): number;
  51546. private _isImpostorInContact;
  51547. private _isImpostorPairInContact;
  51548. private _stepSimulation;
  51549. /**
  51550. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51551. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51552. * After the step the babylon meshes are set to the position of the physics imposters
  51553. * @param delta amount of time to step forward
  51554. * @param impostors array of imposters to update before/after the step
  51555. */
  51556. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51557. private _tmpVector;
  51558. private _tmpMatrix;
  51559. /**
  51560. * Applies an implulse on the imposter
  51561. * @param impostor imposter to apply impulse
  51562. * @param force amount of force to be applied to the imposter
  51563. * @param contactPoint the location to apply the impulse on the imposter
  51564. */
  51565. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51566. /**
  51567. * Applies a force on the imposter
  51568. * @param impostor imposter to apply force
  51569. * @param force amount of force to be applied to the imposter
  51570. * @param contactPoint the location to apply the force on the imposter
  51571. */
  51572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51573. /**
  51574. * Creates a physics body using the plugin
  51575. * @param impostor the imposter to create the physics body on
  51576. */
  51577. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51578. /**
  51579. * Removes the physics body from the imposter and disposes of the body's memory
  51580. * @param impostor imposter to remove the physics body from
  51581. */
  51582. removePhysicsBody(impostor: PhysicsImpostor): void;
  51583. /**
  51584. * Generates a joint
  51585. * @param impostorJoint the imposter joint to create the joint with
  51586. */
  51587. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51588. /**
  51589. * Removes a joint
  51590. * @param impostorJoint the imposter joint to remove the joint from
  51591. */
  51592. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51593. private _addMeshVerts;
  51594. private _createShape;
  51595. /**
  51596. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51597. * @param impostor imposter containing the physics body and babylon object
  51598. */
  51599. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51600. /**
  51601. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51602. * @param impostor imposter containing the physics body and babylon object
  51603. * @param newPosition new position
  51604. * @param newRotation new rotation
  51605. */
  51606. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51607. /**
  51608. * If this plugin is supported
  51609. * @returns true if its supported
  51610. */
  51611. isSupported(): boolean;
  51612. /**
  51613. * Sets the linear velocity of the physics body
  51614. * @param impostor imposter to set the velocity on
  51615. * @param velocity velocity to set
  51616. */
  51617. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51618. /**
  51619. * Sets the angular velocity of the physics body
  51620. * @param impostor imposter to set the velocity on
  51621. * @param velocity velocity to set
  51622. */
  51623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51624. /**
  51625. * gets the linear velocity
  51626. * @param impostor imposter to get linear velocity from
  51627. * @returns linear velocity
  51628. */
  51629. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51630. /**
  51631. * gets the angular velocity
  51632. * @param impostor imposter to get angular velocity from
  51633. * @returns angular velocity
  51634. */
  51635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51636. /**
  51637. * Sets the mass of physics body
  51638. * @param impostor imposter to set the mass on
  51639. * @param mass mass to set
  51640. */
  51641. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51642. /**
  51643. * Gets the mass of the physics body
  51644. * @param impostor imposter to get the mass from
  51645. * @returns mass
  51646. */
  51647. getBodyMass(impostor: PhysicsImpostor): number;
  51648. /**
  51649. * Gets friction of the impostor
  51650. * @param impostor impostor to get friction from
  51651. * @returns friction value
  51652. */
  51653. getBodyFriction(impostor: PhysicsImpostor): number;
  51654. /**
  51655. * Sets friction of the impostor
  51656. * @param impostor impostor to set friction on
  51657. * @param friction friction value
  51658. */
  51659. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51660. /**
  51661. * Gets restitution of the impostor
  51662. * @param impostor impostor to get restitution from
  51663. * @returns restitution value
  51664. */
  51665. getBodyRestitution(impostor: PhysicsImpostor): number;
  51666. /**
  51667. * Sets resitution of the impostor
  51668. * @param impostor impostor to set resitution on
  51669. * @param restitution resitution value
  51670. */
  51671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51672. /**
  51673. * Sleeps the physics body and stops it from being active
  51674. * @param impostor impostor to sleep
  51675. */
  51676. sleepBody(impostor: PhysicsImpostor): void;
  51677. /**
  51678. * Activates the physics body
  51679. * @param impostor impostor to activate
  51680. */
  51681. wakeUpBody(impostor: PhysicsImpostor): void;
  51682. /**
  51683. * Updates the distance parameters of the joint
  51684. * @param joint joint to update
  51685. * @param maxDistance maximum distance of the joint
  51686. * @param minDistance minimum distance of the joint
  51687. */
  51688. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51689. /**
  51690. * Sets a motor on the joint
  51691. * @param joint joint to set motor on
  51692. * @param speed speed of the motor
  51693. * @param maxForce maximum force of the motor
  51694. * @param motorIndex index of the motor
  51695. */
  51696. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51697. /**
  51698. * Sets the motors limit
  51699. * @param joint joint to set limit on
  51700. * @param upperLimit upper limit
  51701. * @param lowerLimit lower limit
  51702. */
  51703. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51704. /**
  51705. * Syncs the position and rotation of a mesh with the impostor
  51706. * @param mesh mesh to sync
  51707. * @param impostor impostor to update the mesh with
  51708. */
  51709. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51710. /**
  51711. * Gets the radius of the impostor
  51712. * @param impostor impostor to get radius from
  51713. * @returns the radius
  51714. */
  51715. getRadius(impostor: PhysicsImpostor): number;
  51716. /**
  51717. * Gets the box size of the impostor
  51718. * @param impostor impostor to get box size from
  51719. * @param result the resulting box size
  51720. */
  51721. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51722. /**
  51723. * Disposes of the impostor
  51724. */
  51725. dispose(): void;
  51726. }
  51727. }
  51728. declare module "babylonjs/Physics/Plugins/index" {
  51729. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51730. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51731. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51732. }
  51733. declare module "babylonjs/Physics/index" {
  51734. export * from "babylonjs/Physics/IPhysicsEngine";
  51735. export * from "babylonjs/Physics/physicsEngine";
  51736. export * from "babylonjs/Physics/physicsEngineComponent";
  51737. export * from "babylonjs/Physics/physicsHelper";
  51738. export * from "babylonjs/Physics/physicsImpostor";
  51739. export * from "babylonjs/Physics/physicsJoint";
  51740. export * from "babylonjs/Physics/Plugins/index";
  51741. }
  51742. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51743. /** @hidden */
  51744. export var blackAndWhitePixelShader: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51751. import { Camera } from "babylonjs/Cameras/camera";
  51752. import { Engine } from "babylonjs/Engines/engine";
  51753. import "babylonjs/Shaders/blackAndWhite.fragment";
  51754. /**
  51755. * Post process used to render in black and white
  51756. */
  51757. export class BlackAndWhitePostProcess extends PostProcess {
  51758. /**
  51759. * Linear about to convert he result to black and white (default: 1)
  51760. */
  51761. degree: number;
  51762. /**
  51763. * Creates a black and white post process
  51764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51765. * @param name The name of the effect.
  51766. * @param options The required width/height ratio to downsize to before computing the render pass.
  51767. * @param camera The camera to apply the render pass to.
  51768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51769. * @param engine The engine which the post process will be applied. (default: current engine)
  51770. * @param reusable If the post process can be reused on the same frame. (default: false)
  51771. */
  51772. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51773. }
  51774. }
  51775. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51776. import { Nullable } from "babylonjs/types";
  51777. import { Camera } from "babylonjs/Cameras/camera";
  51778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51779. import { Engine } from "babylonjs/Engines/engine";
  51780. /**
  51781. * This represents a set of one or more post processes in Babylon.
  51782. * A post process can be used to apply a shader to a texture after it is rendered.
  51783. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51784. */
  51785. export class PostProcessRenderEffect {
  51786. private _postProcesses;
  51787. private _getPostProcesses;
  51788. private _singleInstance;
  51789. private _cameras;
  51790. private _indicesForCamera;
  51791. /**
  51792. * Name of the effect
  51793. * @hidden
  51794. */
  51795. _name: string;
  51796. /**
  51797. * Instantiates a post process render effect.
  51798. * A post process can be used to apply a shader to a texture after it is rendered.
  51799. * @param engine The engine the effect is tied to
  51800. * @param name The name of the effect
  51801. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51802. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51803. */
  51804. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51805. /**
  51806. * Checks if all the post processes in the effect are supported.
  51807. */
  51808. readonly isSupported: boolean;
  51809. /**
  51810. * Updates the current state of the effect
  51811. * @hidden
  51812. */
  51813. _update(): void;
  51814. /**
  51815. * Attaches the effect on cameras
  51816. * @param cameras The camera to attach to.
  51817. * @hidden
  51818. */
  51819. _attachCameras(cameras: Camera): void;
  51820. /**
  51821. * Attaches the effect on cameras
  51822. * @param cameras The camera to attach to.
  51823. * @hidden
  51824. */
  51825. _attachCameras(cameras: Camera[]): void;
  51826. /**
  51827. * Detatches the effect on cameras
  51828. * @param cameras The camera to detatch from.
  51829. * @hidden
  51830. */
  51831. _detachCameras(cameras: Camera): void;
  51832. /**
  51833. * Detatches the effect on cameras
  51834. * @param cameras The camera to detatch from.
  51835. * @hidden
  51836. */
  51837. _detachCameras(cameras: Camera[]): void;
  51838. /**
  51839. * Enables the effect on given cameras
  51840. * @param cameras The camera to enable.
  51841. * @hidden
  51842. */
  51843. _enable(cameras: Camera): void;
  51844. /**
  51845. * Enables the effect on given cameras
  51846. * @param cameras The camera to enable.
  51847. * @hidden
  51848. */
  51849. _enable(cameras: Nullable<Camera[]>): void;
  51850. /**
  51851. * Disables the effect on the given cameras
  51852. * @param cameras The camera to disable.
  51853. * @hidden
  51854. */
  51855. _disable(cameras: Camera): void;
  51856. /**
  51857. * Disables the effect on the given cameras
  51858. * @param cameras The camera to disable.
  51859. * @hidden
  51860. */
  51861. _disable(cameras: Nullable<Camera[]>): void;
  51862. /**
  51863. * Gets a list of the post processes contained in the effect.
  51864. * @param camera The camera to get the post processes on.
  51865. * @returns The list of the post processes in the effect.
  51866. */
  51867. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51868. }
  51869. }
  51870. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51872. /** @hidden */
  51873. export var extractHighlightsPixelShader: {
  51874. name: string;
  51875. shader: string;
  51876. };
  51877. }
  51878. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51879. import { Nullable } from "babylonjs/types";
  51880. import { Camera } from "babylonjs/Cameras/camera";
  51881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51882. import { Engine } from "babylonjs/Engines/engine";
  51883. import "babylonjs/Shaders/extractHighlights.fragment";
  51884. /**
  51885. * 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.
  51886. */
  51887. export class ExtractHighlightsPostProcess extends PostProcess {
  51888. /**
  51889. * The luminance threshold, pixels below this value will be set to black.
  51890. */
  51891. threshold: number;
  51892. /** @hidden */
  51893. _exposure: number;
  51894. /**
  51895. * Post process which has the input texture to be used when performing highlight extraction
  51896. * @hidden
  51897. */
  51898. _inputPostProcess: Nullable<PostProcess>;
  51899. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51900. }
  51901. }
  51902. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51903. /** @hidden */
  51904. export var bloomMergePixelShader: {
  51905. name: string;
  51906. shader: string;
  51907. };
  51908. }
  51909. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51911. import { Nullable } from "babylonjs/types";
  51912. import { Engine } from "babylonjs/Engines/engine";
  51913. import { Camera } from "babylonjs/Cameras/camera";
  51914. import "babylonjs/Shaders/bloomMerge.fragment";
  51915. /**
  51916. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51917. */
  51918. export class BloomMergePostProcess extends PostProcess {
  51919. /** Weight of the bloom to be added to the original input. */
  51920. weight: number;
  51921. /**
  51922. * Creates a new instance of @see BloomMergePostProcess
  51923. * @param name The name of the effect.
  51924. * @param originalFromInput Post process which's input will be used for the merge.
  51925. * @param blurred Blurred highlights post process which's output will be used.
  51926. * @param weight Weight of the bloom to be added to the original input.
  51927. * @param options The required width/height ratio to downsize to before computing the render pass.
  51928. * @param camera The camera to apply the render pass to.
  51929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51930. * @param engine The engine which the post process will be applied. (default: current engine)
  51931. * @param reusable If the post process can be reused on the same frame. (default: false)
  51932. * @param textureType Type of textures used when performing the post process. (default: 0)
  51933. * @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)
  51934. */
  51935. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51936. /** Weight of the bloom to be added to the original input. */
  51937. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51938. }
  51939. }
  51940. declare module "babylonjs/PostProcesses/bloomEffect" {
  51941. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51943. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51944. import { Camera } from "babylonjs/Cameras/camera";
  51945. import { Scene } from "babylonjs/scene";
  51946. /**
  51947. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51948. */
  51949. export class BloomEffect extends PostProcessRenderEffect {
  51950. private bloomScale;
  51951. /**
  51952. * @hidden Internal
  51953. */
  51954. _effects: Array<PostProcess>;
  51955. /**
  51956. * @hidden Internal
  51957. */
  51958. _downscale: ExtractHighlightsPostProcess;
  51959. private _blurX;
  51960. private _blurY;
  51961. private _merge;
  51962. /**
  51963. * The luminance threshold to find bright areas of the image to bloom.
  51964. */
  51965. threshold: number;
  51966. /**
  51967. * The strength of the bloom.
  51968. */
  51969. weight: number;
  51970. /**
  51971. * Specifies the size of the bloom blur kernel, relative to the final output size
  51972. */
  51973. kernel: number;
  51974. /**
  51975. * Creates a new instance of @see BloomEffect
  51976. * @param scene The scene the effect belongs to.
  51977. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51978. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51979. * @param bloomWeight The the strength of bloom.
  51980. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51981. * @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)
  51982. */
  51983. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51984. /**
  51985. * Disposes each of the internal effects for a given camera.
  51986. * @param camera The camera to dispose the effect on.
  51987. */
  51988. disposeEffects(camera: Camera): void;
  51989. /**
  51990. * @hidden Internal
  51991. */
  51992. _updateEffects(): void;
  51993. /**
  51994. * Internal
  51995. * @returns if all the contained post processes are ready.
  51996. * @hidden
  51997. */
  51998. _isReady(): boolean;
  51999. }
  52000. }
  52001. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52002. /** @hidden */
  52003. export var chromaticAberrationPixelShader: {
  52004. name: string;
  52005. shader: string;
  52006. };
  52007. }
  52008. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52009. import { Vector2 } from "babylonjs/Maths/math";
  52010. import { Nullable } from "babylonjs/types";
  52011. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52012. import { Camera } from "babylonjs/Cameras/camera";
  52013. import { Engine } from "babylonjs/Engines/engine";
  52014. import "babylonjs/Shaders/chromaticAberration.fragment";
  52015. /**
  52016. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52017. */
  52018. export class ChromaticAberrationPostProcess extends PostProcess {
  52019. /**
  52020. * The amount of seperation of rgb channels (default: 30)
  52021. */
  52022. aberrationAmount: number;
  52023. /**
  52024. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52025. */
  52026. radialIntensity: number;
  52027. /**
  52028. * 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))
  52029. */
  52030. direction: Vector2;
  52031. /**
  52032. * 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))
  52033. */
  52034. centerPosition: Vector2;
  52035. /**
  52036. * Creates a new instance ChromaticAberrationPostProcess
  52037. * @param name The name of the effect.
  52038. * @param screenWidth The width of the screen to apply the effect on.
  52039. * @param screenHeight The height of the screen to apply the effect on.
  52040. * @param options The required width/height ratio to downsize to before computing the render pass.
  52041. * @param camera The camera to apply the render pass to.
  52042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52043. * @param engine The engine which the post process will be applied. (default: current engine)
  52044. * @param reusable If the post process can be reused on the same frame. (default: false)
  52045. * @param textureType Type of textures used when performing the post process. (default: 0)
  52046. * @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)
  52047. */
  52048. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52049. }
  52050. }
  52051. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52052. /** @hidden */
  52053. export var circleOfConfusionPixelShader: {
  52054. name: string;
  52055. shader: string;
  52056. };
  52057. }
  52058. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52059. import { Nullable } from "babylonjs/types";
  52060. import { Engine } from "babylonjs/Engines/engine";
  52061. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52062. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52063. import { Camera } from "babylonjs/Cameras/camera";
  52064. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52065. /**
  52066. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52067. */
  52068. export class CircleOfConfusionPostProcess extends PostProcess {
  52069. /**
  52070. * 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.
  52071. */
  52072. lensSize: number;
  52073. /**
  52074. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52075. */
  52076. fStop: number;
  52077. /**
  52078. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52079. */
  52080. focusDistance: number;
  52081. /**
  52082. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52083. */
  52084. focalLength: number;
  52085. private _depthTexture;
  52086. /**
  52087. * Creates a new instance CircleOfConfusionPostProcess
  52088. * @param name The name of the effect.
  52089. * @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.
  52090. * @param options The required width/height ratio to downsize to before computing the render pass.
  52091. * @param camera The camera to apply the render pass to.
  52092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52093. * @param engine The engine which the post process will be applied. (default: current engine)
  52094. * @param reusable If the post process can be reused on the same frame. (default: false)
  52095. * @param textureType Type of textures used when performing the post process. (default: 0)
  52096. * @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)
  52097. */
  52098. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52099. /**
  52100. * 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.
  52101. */
  52102. depthTexture: RenderTargetTexture;
  52103. }
  52104. }
  52105. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52106. /** @hidden */
  52107. export var colorCorrectionPixelShader: {
  52108. name: string;
  52109. shader: string;
  52110. };
  52111. }
  52112. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52113. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52114. import { Engine } from "babylonjs/Engines/engine";
  52115. import { Camera } from "babylonjs/Cameras/camera";
  52116. import "babylonjs/Shaders/colorCorrection.fragment";
  52117. /**
  52118. *
  52119. * This post-process allows the modification of rendered colors by using
  52120. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52121. *
  52122. * The object needs to be provided an url to a texture containing the color
  52123. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52124. * Use an image editing software to tweak the LUT to match your needs.
  52125. *
  52126. * For an example of a color LUT, see here:
  52127. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52128. * For explanations on color grading, see here:
  52129. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52130. *
  52131. */
  52132. export class ColorCorrectionPostProcess extends PostProcess {
  52133. private _colorTableTexture;
  52134. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52135. }
  52136. }
  52137. declare module "babylonjs/Shaders/convolution.fragment" {
  52138. /** @hidden */
  52139. export var convolutionPixelShader: {
  52140. name: string;
  52141. shader: string;
  52142. };
  52143. }
  52144. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52146. import { Nullable } from "babylonjs/types";
  52147. import { Camera } from "babylonjs/Cameras/camera";
  52148. import { Engine } from "babylonjs/Engines/engine";
  52149. import "babylonjs/Shaders/convolution.fragment";
  52150. /**
  52151. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52152. * input texture to perform effects such as edge detection or sharpening
  52153. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52154. */
  52155. export class ConvolutionPostProcess extends PostProcess {
  52156. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52157. kernel: number[];
  52158. /**
  52159. * Creates a new instance ConvolutionPostProcess
  52160. * @param name The name of the effect.
  52161. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52162. * @param options The required width/height ratio to downsize to before computing the render pass.
  52163. * @param camera The camera to apply the render pass to.
  52164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52165. * @param engine The engine which the post process will be applied. (default: current engine)
  52166. * @param reusable If the post process can be reused on the same frame. (default: false)
  52167. * @param textureType Type of textures used when performing the post process. (default: 0)
  52168. */
  52169. constructor(name: string,
  52170. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52171. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52172. /**
  52173. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52174. */
  52175. static EdgeDetect0Kernel: number[];
  52176. /**
  52177. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52178. */
  52179. static EdgeDetect1Kernel: number[];
  52180. /**
  52181. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52182. */
  52183. static EdgeDetect2Kernel: number[];
  52184. /**
  52185. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52186. */
  52187. static SharpenKernel: number[];
  52188. /**
  52189. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52190. */
  52191. static EmbossKernel: number[];
  52192. /**
  52193. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52194. */
  52195. static GaussianKernel: number[];
  52196. }
  52197. }
  52198. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52199. import { Nullable } from "babylonjs/types";
  52200. import { Vector2 } from "babylonjs/Maths/math";
  52201. import { Camera } from "babylonjs/Cameras/camera";
  52202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52203. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52204. import { Engine } from "babylonjs/Engines/engine";
  52205. import { Scene } from "babylonjs/scene";
  52206. /**
  52207. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52208. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52209. * based on samples that have a large difference in distance than the center pixel.
  52210. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52211. */
  52212. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52213. direction: Vector2;
  52214. /**
  52215. * Creates a new instance CircleOfConfusionPostProcess
  52216. * @param name The name of the effect.
  52217. * @param scene The scene the effect belongs to.
  52218. * @param direction The direction the blur should be applied.
  52219. * @param kernel The size of the kernel used to blur.
  52220. * @param options The required width/height ratio to downsize to before computing the render pass.
  52221. * @param camera The camera to apply the render pass to.
  52222. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52223. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52225. * @param engine The engine which the post process will be applied. (default: current engine)
  52226. * @param reusable If the post process can be reused on the same frame. (default: false)
  52227. * @param textureType Type of textures used when performing the post process. (default: 0)
  52228. * @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)
  52229. */
  52230. 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);
  52231. }
  52232. }
  52233. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52234. /** @hidden */
  52235. export var depthOfFieldMergePixelShader: {
  52236. name: string;
  52237. shader: string;
  52238. };
  52239. }
  52240. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52241. import { Nullable } from "babylonjs/types";
  52242. import { Camera } from "babylonjs/Cameras/camera";
  52243. import { Effect } from "babylonjs/Materials/effect";
  52244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52245. import { Engine } from "babylonjs/Engines/engine";
  52246. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52247. /**
  52248. * Options to be set when merging outputs from the default pipeline.
  52249. */
  52250. export class DepthOfFieldMergePostProcessOptions {
  52251. /**
  52252. * The original image to merge on top of
  52253. */
  52254. originalFromInput: PostProcess;
  52255. /**
  52256. * Parameters to perform the merge of the depth of field effect
  52257. */
  52258. depthOfField?: {
  52259. circleOfConfusion: PostProcess;
  52260. blurSteps: Array<PostProcess>;
  52261. };
  52262. /**
  52263. * Parameters to perform the merge of bloom effect
  52264. */
  52265. bloom?: {
  52266. blurred: PostProcess;
  52267. weight: number;
  52268. };
  52269. }
  52270. /**
  52271. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52272. */
  52273. export class DepthOfFieldMergePostProcess extends PostProcess {
  52274. private blurSteps;
  52275. /**
  52276. * Creates a new instance of DepthOfFieldMergePostProcess
  52277. * @param name The name of the effect.
  52278. * @param originalFromInput Post process which's input will be used for the merge.
  52279. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52280. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52281. * @param options The required width/height ratio to downsize to before computing the render pass.
  52282. * @param camera The camera to apply the render pass to.
  52283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52284. * @param engine The engine which the post process will be applied. (default: current engine)
  52285. * @param reusable If the post process can be reused on the same frame. (default: false)
  52286. * @param textureType Type of textures used when performing the post process. (default: 0)
  52287. * @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)
  52288. */
  52289. 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);
  52290. /**
  52291. * Updates the effect with the current post process compile time values and recompiles the shader.
  52292. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52293. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52294. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52295. * @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
  52296. * @param onCompiled Called when the shader has been compiled.
  52297. * @param onError Called if there is an error when compiling a shader.
  52298. */
  52299. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52300. }
  52301. }
  52302. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52303. import { Nullable } from "babylonjs/types";
  52304. import { Camera } from "babylonjs/Cameras/camera";
  52305. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52306. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52307. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52308. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52309. import { Scene } from "babylonjs/scene";
  52310. /**
  52311. * Specifies the level of max blur that should be applied when using the depth of field effect
  52312. */
  52313. export enum DepthOfFieldEffectBlurLevel {
  52314. /**
  52315. * Subtle blur
  52316. */
  52317. Low = 0,
  52318. /**
  52319. * Medium blur
  52320. */
  52321. Medium = 1,
  52322. /**
  52323. * Large blur
  52324. */
  52325. High = 2
  52326. }
  52327. /**
  52328. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52329. */
  52330. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52331. private _circleOfConfusion;
  52332. /**
  52333. * @hidden Internal, blurs from high to low
  52334. */
  52335. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52336. private _depthOfFieldBlurY;
  52337. private _dofMerge;
  52338. /**
  52339. * @hidden Internal post processes in depth of field effect
  52340. */
  52341. _effects: Array<PostProcess>;
  52342. /**
  52343. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52344. */
  52345. focalLength: number;
  52346. /**
  52347. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52348. */
  52349. fStop: number;
  52350. /**
  52351. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52352. */
  52353. focusDistance: number;
  52354. /**
  52355. * 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.
  52356. */
  52357. lensSize: number;
  52358. /**
  52359. * Creates a new instance DepthOfFieldEffect
  52360. * @param scene The scene the effect belongs to.
  52361. * @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.
  52362. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52363. * @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)
  52364. */
  52365. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52366. /**
  52367. * 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.
  52368. */
  52369. depthTexture: RenderTargetTexture;
  52370. /**
  52371. * Disposes each of the internal effects for a given camera.
  52372. * @param camera The camera to dispose the effect on.
  52373. */
  52374. disposeEffects(camera: Camera): void;
  52375. /**
  52376. * @hidden Internal
  52377. */
  52378. _updateEffects(): void;
  52379. /**
  52380. * Internal
  52381. * @returns if all the contained post processes are ready.
  52382. * @hidden
  52383. */
  52384. _isReady(): boolean;
  52385. }
  52386. }
  52387. declare module "babylonjs/Shaders/displayPass.fragment" {
  52388. /** @hidden */
  52389. export var displayPassPixelShader: {
  52390. name: string;
  52391. shader: string;
  52392. };
  52393. }
  52394. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52395. import { Nullable } from "babylonjs/types";
  52396. import { Camera } from "babylonjs/Cameras/camera";
  52397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52398. import { Engine } from "babylonjs/Engines/engine";
  52399. import "babylonjs/Shaders/displayPass.fragment";
  52400. /**
  52401. * DisplayPassPostProcess which produces an output the same as it's input
  52402. */
  52403. export class DisplayPassPostProcess extends PostProcess {
  52404. /**
  52405. * Creates the DisplayPassPostProcess
  52406. * @param name The name of the effect.
  52407. * @param options The required width/height ratio to downsize to before computing the render pass.
  52408. * @param camera The camera to apply the render pass to.
  52409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52410. * @param engine The engine which the post process will be applied. (default: current engine)
  52411. * @param reusable If the post process can be reused on the same frame. (default: false)
  52412. */
  52413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52414. }
  52415. }
  52416. declare module "babylonjs/Shaders/filter.fragment" {
  52417. /** @hidden */
  52418. export var filterPixelShader: {
  52419. name: string;
  52420. shader: string;
  52421. };
  52422. }
  52423. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52424. import { Nullable } from "babylonjs/types";
  52425. import { Matrix } from "babylonjs/Maths/math";
  52426. import { Camera } from "babylonjs/Cameras/camera";
  52427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52428. import { Engine } from "babylonjs/Engines/engine";
  52429. import "babylonjs/Shaders/filter.fragment";
  52430. /**
  52431. * Applies a kernel filter to the image
  52432. */
  52433. export class FilterPostProcess extends PostProcess {
  52434. /** The matrix to be applied to the image */
  52435. kernelMatrix: Matrix;
  52436. /**
  52437. *
  52438. * @param name The name of the effect.
  52439. * @param kernelMatrix The matrix to be applied to the image
  52440. * @param options The required width/height ratio to downsize to before computing the render pass.
  52441. * @param camera The camera to apply the render pass to.
  52442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52443. * @param engine The engine which the post process will be applied. (default: current engine)
  52444. * @param reusable If the post process can be reused on the same frame. (default: false)
  52445. */
  52446. constructor(name: string,
  52447. /** The matrix to be applied to the image */
  52448. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52449. }
  52450. }
  52451. declare module "babylonjs/Shaders/fxaa.fragment" {
  52452. /** @hidden */
  52453. export var fxaaPixelShader: {
  52454. name: string;
  52455. shader: string;
  52456. };
  52457. }
  52458. declare module "babylonjs/Shaders/fxaa.vertex" {
  52459. /** @hidden */
  52460. export var fxaaVertexShader: {
  52461. name: string;
  52462. shader: string;
  52463. };
  52464. }
  52465. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52466. import { Nullable } from "babylonjs/types";
  52467. import { Camera } from "babylonjs/Cameras/camera";
  52468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52469. import { Engine } from "babylonjs/Engines/engine";
  52470. import "babylonjs/Shaders/fxaa.fragment";
  52471. import "babylonjs/Shaders/fxaa.vertex";
  52472. /**
  52473. * Fxaa post process
  52474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52475. */
  52476. export class FxaaPostProcess extends PostProcess {
  52477. /** @hidden */
  52478. texelWidth: number;
  52479. /** @hidden */
  52480. texelHeight: number;
  52481. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52482. private _getDefines;
  52483. }
  52484. }
  52485. declare module "babylonjs/Shaders/grain.fragment" {
  52486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52487. /** @hidden */
  52488. export var grainPixelShader: {
  52489. name: string;
  52490. shader: string;
  52491. };
  52492. }
  52493. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52494. import { Nullable } from "babylonjs/types";
  52495. import { Camera } from "babylonjs/Cameras/camera";
  52496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52497. import { Engine } from "babylonjs/Engines/engine";
  52498. import "babylonjs/Shaders/grain.fragment";
  52499. /**
  52500. * The GrainPostProcess adds noise to the image at mid luminance levels
  52501. */
  52502. export class GrainPostProcess extends PostProcess {
  52503. /**
  52504. * The intensity of the grain added (default: 30)
  52505. */
  52506. intensity: number;
  52507. /**
  52508. * If the grain should be randomized on every frame
  52509. */
  52510. animated: boolean;
  52511. /**
  52512. * Creates a new instance of @see GrainPostProcess
  52513. * @param name The name of the effect.
  52514. * @param options The required width/height ratio to downsize to before computing the render pass.
  52515. * @param camera The camera to apply the render pass to.
  52516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52517. * @param engine The engine which the post process will be applied. (default: current engine)
  52518. * @param reusable If the post process can be reused on the same frame. (default: false)
  52519. * @param textureType Type of textures used when performing the post process. (default: 0)
  52520. * @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)
  52521. */
  52522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52523. }
  52524. }
  52525. declare module "babylonjs/Shaders/highlights.fragment" {
  52526. /** @hidden */
  52527. export var highlightsPixelShader: {
  52528. name: string;
  52529. shader: string;
  52530. };
  52531. }
  52532. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52533. import { Nullable } from "babylonjs/types";
  52534. import { Camera } from "babylonjs/Cameras/camera";
  52535. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52536. import { Engine } from "babylonjs/Engines/engine";
  52537. import "babylonjs/Shaders/highlights.fragment";
  52538. /**
  52539. * Extracts highlights from the image
  52540. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52541. */
  52542. export class HighlightsPostProcess extends PostProcess {
  52543. /**
  52544. * Extracts highlights from the image
  52545. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52546. * @param name The name of the effect.
  52547. * @param options The required width/height ratio to downsize to before computing the render pass.
  52548. * @param camera The camera to apply the render pass to.
  52549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52550. * @param engine The engine which the post process will be applied. (default: current engine)
  52551. * @param reusable If the post process can be reused on the same frame. (default: false)
  52552. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52553. */
  52554. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52555. }
  52556. }
  52557. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52558. /** @hidden */
  52559. export var mrtFragmentDeclaration: {
  52560. name: string;
  52561. shader: string;
  52562. };
  52563. }
  52564. declare module "babylonjs/Shaders/geometry.fragment" {
  52565. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52566. /** @hidden */
  52567. export var geometryPixelShader: {
  52568. name: string;
  52569. shader: string;
  52570. };
  52571. }
  52572. declare module "babylonjs/Shaders/geometry.vertex" {
  52573. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52574. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52575. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52576. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52577. /** @hidden */
  52578. export var geometryVertexShader: {
  52579. name: string;
  52580. shader: string;
  52581. };
  52582. }
  52583. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52584. import { Matrix } from "babylonjs/Maths/math";
  52585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52586. import { Mesh } from "babylonjs/Meshes/mesh";
  52587. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52588. import { Effect } from "babylonjs/Materials/effect";
  52589. import { Scene } from "babylonjs/scene";
  52590. import "babylonjs/Shaders/geometry.fragment";
  52591. import "babylonjs/Shaders/geometry.vertex";
  52592. /**
  52593. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52594. */
  52595. export class GeometryBufferRenderer {
  52596. /**
  52597. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52598. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52599. */
  52600. static readonly POSITION_TEXTURE_TYPE: number;
  52601. /**
  52602. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52603. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52604. */
  52605. static readonly VELOCITY_TEXTURE_TYPE: number;
  52606. /**
  52607. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52608. * in order to compute objects velocities when enableVelocity is set to "true"
  52609. * @hidden
  52610. */
  52611. _previousTransformationMatrices: {
  52612. [index: number]: Matrix;
  52613. };
  52614. private _scene;
  52615. private _multiRenderTarget;
  52616. private _ratio;
  52617. private _enablePosition;
  52618. private _enableVelocity;
  52619. private _positionIndex;
  52620. private _velocityIndex;
  52621. protected _effect: Effect;
  52622. protected _cachedDefines: string;
  52623. /**
  52624. * Set the render list (meshes to be rendered) used in the G buffer.
  52625. */
  52626. renderList: Mesh[];
  52627. /**
  52628. * Gets wether or not G buffer are supported by the running hardware.
  52629. * This requires draw buffer supports
  52630. */
  52631. readonly isSupported: boolean;
  52632. /**
  52633. * Returns the index of the given texture type in the G-Buffer textures array
  52634. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52635. * @returns the index of the given texture type in the G-Buffer textures array
  52636. */
  52637. getTextureIndex(textureType: number): number;
  52638. /**
  52639. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52640. */
  52641. /**
  52642. * Sets whether or not objects positions are enabled for the G buffer.
  52643. */
  52644. enablePosition: boolean;
  52645. /**
  52646. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52647. */
  52648. /**
  52649. * Sets wether or not objects velocities are enabled for the G buffer.
  52650. */
  52651. enableVelocity: boolean;
  52652. /**
  52653. * Gets the scene associated with the buffer.
  52654. */
  52655. readonly scene: Scene;
  52656. /**
  52657. * Gets the ratio used by the buffer during its creation.
  52658. * How big is the buffer related to the main canvas.
  52659. */
  52660. readonly ratio: number;
  52661. /** @hidden */
  52662. static _SceneComponentInitialization: (scene: Scene) => void;
  52663. /**
  52664. * Creates a new G Buffer for the scene
  52665. * @param scene The scene the buffer belongs to
  52666. * @param ratio How big is the buffer related to the main canvas.
  52667. */
  52668. constructor(scene: Scene, ratio?: number);
  52669. /**
  52670. * Checks wether everything is ready to render a submesh to the G buffer.
  52671. * @param subMesh the submesh to check readiness for
  52672. * @param useInstances is the mesh drawn using instance or not
  52673. * @returns true if ready otherwise false
  52674. */
  52675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52676. /**
  52677. * Gets the current underlying G Buffer.
  52678. * @returns the buffer
  52679. */
  52680. getGBuffer(): MultiRenderTarget;
  52681. /**
  52682. * Gets the number of samples used to render the buffer (anti aliasing).
  52683. */
  52684. /**
  52685. * Sets the number of samples used to render the buffer (anti aliasing).
  52686. */
  52687. samples: number;
  52688. /**
  52689. * Disposes the renderer and frees up associated resources.
  52690. */
  52691. dispose(): void;
  52692. protected _createRenderTargets(): void;
  52693. }
  52694. }
  52695. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52696. /** @hidden */
  52697. export var motionBlurPixelShader: {
  52698. name: string;
  52699. shader: string;
  52700. };
  52701. }
  52702. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52703. import { Nullable } from "babylonjs/types";
  52704. import { Camera } from "babylonjs/Cameras/camera";
  52705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52706. import { Scene } from "babylonjs/scene";
  52707. import "babylonjs/Shaders/motionBlur.fragment";
  52708. import { Engine } from "babylonjs/Engines/engine";
  52709. /**
  52710. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52711. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52712. * As an example, all you have to do is to create the post-process:
  52713. * var mb = new BABYLON.MotionBlurPostProcess(
  52714. * 'mb', // The name of the effect.
  52715. * scene, // The scene containing the objects to blur according to their velocity.
  52716. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52717. * camera // The camera to apply the render pass to.
  52718. * );
  52719. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52720. */
  52721. export class MotionBlurPostProcess extends PostProcess {
  52722. /**
  52723. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52724. */
  52725. motionStrength: number;
  52726. /**
  52727. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52728. */
  52729. /**
  52730. * Sets the number of iterations to be used for motion blur quality
  52731. */
  52732. motionBlurSamples: number;
  52733. private _motionBlurSamples;
  52734. private _geometryBufferRenderer;
  52735. /**
  52736. * Creates a new instance MotionBlurPostProcess
  52737. * @param name The name of the effect.
  52738. * @param scene The scene containing the objects to blur according to their velocity.
  52739. * @param options The required width/height ratio to downsize to before computing the render pass.
  52740. * @param camera The camera to apply the render pass to.
  52741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52742. * @param engine The engine which the post process will be applied. (default: current engine)
  52743. * @param reusable If the post process can be reused on the same frame. (default: false)
  52744. * @param textureType Type of textures used when performing the post process. (default: 0)
  52745. * @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)
  52746. */
  52747. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52748. /**
  52749. * Disposes the post process.
  52750. * @param camera The camera to dispose the post process on.
  52751. */
  52752. dispose(camera?: Camera): void;
  52753. }
  52754. }
  52755. declare module "babylonjs/Shaders/refraction.fragment" {
  52756. /** @hidden */
  52757. export var refractionPixelShader: {
  52758. name: string;
  52759. shader: string;
  52760. };
  52761. }
  52762. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52763. import { Color3 } from "babylonjs/Maths/math";
  52764. import { Camera } from "babylonjs/Cameras/camera";
  52765. import { Texture } from "babylonjs/Materials/Textures/texture";
  52766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52767. import { Engine } from "babylonjs/Engines/engine";
  52768. import "babylonjs/Shaders/refraction.fragment";
  52769. /**
  52770. * Post process which applies a refractin texture
  52771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52772. */
  52773. export class RefractionPostProcess extends PostProcess {
  52774. /** the base color of the refraction (used to taint the rendering) */
  52775. color: Color3;
  52776. /** simulated refraction depth */
  52777. depth: number;
  52778. /** the coefficient of the base color (0 to remove base color tainting) */
  52779. colorLevel: number;
  52780. private _refTexture;
  52781. private _ownRefractionTexture;
  52782. /**
  52783. * Gets or sets the refraction texture
  52784. * Please note that you are responsible for disposing the texture if you set it manually
  52785. */
  52786. refractionTexture: Texture;
  52787. /**
  52788. * Initializes the RefractionPostProcess
  52789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52790. * @param name The name of the effect.
  52791. * @param refractionTextureUrl Url of the refraction texture to use
  52792. * @param color the base color of the refraction (used to taint the rendering)
  52793. * @param depth simulated refraction depth
  52794. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52795. * @param camera The camera to apply the render pass to.
  52796. * @param options The required width/height ratio to downsize to before computing the render pass.
  52797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52798. * @param engine The engine which the post process will be applied. (default: current engine)
  52799. * @param reusable If the post process can be reused on the same frame. (default: false)
  52800. */
  52801. constructor(name: string, refractionTextureUrl: string,
  52802. /** the base color of the refraction (used to taint the rendering) */
  52803. color: Color3,
  52804. /** simulated refraction depth */
  52805. depth: number,
  52806. /** the coefficient of the base color (0 to remove base color tainting) */
  52807. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52808. /**
  52809. * Disposes of the post process
  52810. * @param camera Camera to dispose post process on
  52811. */
  52812. dispose(camera: Camera): void;
  52813. }
  52814. }
  52815. declare module "babylonjs/Shaders/sharpen.fragment" {
  52816. /** @hidden */
  52817. export var sharpenPixelShader: {
  52818. name: string;
  52819. shader: string;
  52820. };
  52821. }
  52822. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52823. import { Nullable } from "babylonjs/types";
  52824. import { Camera } from "babylonjs/Cameras/camera";
  52825. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52826. import "babylonjs/Shaders/sharpen.fragment";
  52827. import { Engine } from "babylonjs/Engines/engine";
  52828. /**
  52829. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52830. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52831. */
  52832. export class SharpenPostProcess extends PostProcess {
  52833. /**
  52834. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52835. */
  52836. colorAmount: number;
  52837. /**
  52838. * How much sharpness should be applied (default: 0.3)
  52839. */
  52840. edgeAmount: number;
  52841. /**
  52842. * Creates a new instance ConvolutionPostProcess
  52843. * @param name The name of the effect.
  52844. * @param options The required width/height ratio to downsize to before computing the render pass.
  52845. * @param camera The camera to apply the render pass to.
  52846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52847. * @param engine The engine which the post process will be applied. (default: current engine)
  52848. * @param reusable If the post process can be reused on the same frame. (default: false)
  52849. * @param textureType Type of textures used when performing the post process. (default: 0)
  52850. * @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)
  52851. */
  52852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52853. }
  52854. }
  52855. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52856. import { Nullable } from "babylonjs/types";
  52857. import { Camera } from "babylonjs/Cameras/camera";
  52858. import { Engine } from "babylonjs/Engines/engine";
  52859. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52860. /**
  52861. * PostProcessRenderPipeline
  52862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52863. */
  52864. export class PostProcessRenderPipeline {
  52865. private engine;
  52866. private _renderEffects;
  52867. private _renderEffectsForIsolatedPass;
  52868. /**
  52869. * @hidden
  52870. */
  52871. protected _cameras: Camera[];
  52872. /** @hidden */
  52873. _name: string;
  52874. /**
  52875. * Gets pipeline name
  52876. */
  52877. readonly name: string;
  52878. /**
  52879. * Initializes a PostProcessRenderPipeline
  52880. * @param engine engine to add the pipeline to
  52881. * @param name name of the pipeline
  52882. */
  52883. constructor(engine: Engine, name: string);
  52884. /**
  52885. * Gets the class name
  52886. * @returns "PostProcessRenderPipeline"
  52887. */
  52888. getClassName(): string;
  52889. /**
  52890. * If all the render effects in the pipeline are supported
  52891. */
  52892. readonly isSupported: boolean;
  52893. /**
  52894. * Adds an effect to the pipeline
  52895. * @param renderEffect the effect to add
  52896. */
  52897. addEffect(renderEffect: PostProcessRenderEffect): void;
  52898. /** @hidden */
  52899. _rebuild(): void;
  52900. /** @hidden */
  52901. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52902. /** @hidden */
  52903. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52904. /** @hidden */
  52905. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52906. /** @hidden */
  52907. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52908. /** @hidden */
  52909. _attachCameras(cameras: Camera, unique: boolean): void;
  52910. /** @hidden */
  52911. _attachCameras(cameras: Camera[], unique: boolean): void;
  52912. /** @hidden */
  52913. _detachCameras(cameras: Camera): void;
  52914. /** @hidden */
  52915. _detachCameras(cameras: Nullable<Camera[]>): void;
  52916. /** @hidden */
  52917. _update(): void;
  52918. /** @hidden */
  52919. _reset(): void;
  52920. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52921. /**
  52922. * Disposes of the pipeline
  52923. */
  52924. dispose(): void;
  52925. }
  52926. }
  52927. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52928. import { IAnimatable } from "babylonjs/Misc/tools";
  52929. import { Camera } from "babylonjs/Cameras/camera";
  52930. import { IDisposable } from "babylonjs/scene";
  52931. import { Scene } from "babylonjs/scene";
  52932. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52933. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52934. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52935. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52936. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52937. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52938. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52939. import { Animation } from "babylonjs/Animations/animation";
  52940. /**
  52941. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52942. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52943. */
  52944. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52945. private _scene;
  52946. private _camerasToBeAttached;
  52947. /**
  52948. * ID of the sharpen post process,
  52949. */
  52950. private readonly SharpenPostProcessId;
  52951. /**
  52952. * @ignore
  52953. * ID of the image processing post process;
  52954. */
  52955. readonly ImageProcessingPostProcessId: string;
  52956. /**
  52957. * @ignore
  52958. * ID of the Fast Approximate Anti-Aliasing post process;
  52959. */
  52960. readonly FxaaPostProcessId: string;
  52961. /**
  52962. * ID of the chromatic aberration post process,
  52963. */
  52964. private readonly ChromaticAberrationPostProcessId;
  52965. /**
  52966. * ID of the grain post process
  52967. */
  52968. private readonly GrainPostProcessId;
  52969. /**
  52970. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52971. */
  52972. sharpen: SharpenPostProcess;
  52973. private _sharpenEffect;
  52974. private bloom;
  52975. /**
  52976. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52977. */
  52978. depthOfField: DepthOfFieldEffect;
  52979. /**
  52980. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52981. */
  52982. fxaa: FxaaPostProcess;
  52983. /**
  52984. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52985. */
  52986. imageProcessing: ImageProcessingPostProcess;
  52987. /**
  52988. * Chromatic aberration post process which will shift rgb colors in the image
  52989. */
  52990. chromaticAberration: ChromaticAberrationPostProcess;
  52991. private _chromaticAberrationEffect;
  52992. /**
  52993. * Grain post process which add noise to the image
  52994. */
  52995. grain: GrainPostProcess;
  52996. private _grainEffect;
  52997. /**
  52998. * Glow post process which adds a glow to emissive areas of the image
  52999. */
  53000. private _glowLayer;
  53001. /**
  53002. * Animations which can be used to tweak settings over a period of time
  53003. */
  53004. animations: Animation[];
  53005. private _imageProcessingConfigurationObserver;
  53006. private _sharpenEnabled;
  53007. private _bloomEnabled;
  53008. private _depthOfFieldEnabled;
  53009. private _depthOfFieldBlurLevel;
  53010. private _fxaaEnabled;
  53011. private _imageProcessingEnabled;
  53012. private _defaultPipelineTextureType;
  53013. private _bloomScale;
  53014. private _chromaticAberrationEnabled;
  53015. private _grainEnabled;
  53016. private _buildAllowed;
  53017. /**
  53018. * Gets active scene
  53019. */
  53020. readonly scene: Scene;
  53021. /**
  53022. * Enable or disable the sharpen process from the pipeline
  53023. */
  53024. sharpenEnabled: boolean;
  53025. private _resizeObserver;
  53026. private _hardwareScaleLevel;
  53027. private _bloomKernel;
  53028. /**
  53029. * Specifies the size of the bloom blur kernel, relative to the final output size
  53030. */
  53031. bloomKernel: number;
  53032. /**
  53033. * Specifies the weight of the bloom in the final rendering
  53034. */
  53035. private _bloomWeight;
  53036. /**
  53037. * Specifies the luma threshold for the area that will be blurred by the bloom
  53038. */
  53039. private _bloomThreshold;
  53040. private _hdr;
  53041. /**
  53042. * The strength of the bloom.
  53043. */
  53044. bloomWeight: number;
  53045. /**
  53046. * The strength of the bloom.
  53047. */
  53048. bloomThreshold: number;
  53049. /**
  53050. * The scale of the bloom, lower value will provide better performance.
  53051. */
  53052. bloomScale: number;
  53053. /**
  53054. * Enable or disable the bloom from the pipeline
  53055. */
  53056. bloomEnabled: boolean;
  53057. private _rebuildBloom;
  53058. /**
  53059. * If the depth of field is enabled.
  53060. */
  53061. depthOfFieldEnabled: boolean;
  53062. /**
  53063. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53064. */
  53065. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53066. /**
  53067. * If the anti aliasing is enabled.
  53068. */
  53069. fxaaEnabled: boolean;
  53070. private _samples;
  53071. /**
  53072. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53073. */
  53074. samples: number;
  53075. /**
  53076. * If image processing is enabled.
  53077. */
  53078. imageProcessingEnabled: boolean;
  53079. /**
  53080. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53081. */
  53082. glowLayerEnabled: boolean;
  53083. /**
  53084. * Enable or disable the chromaticAberration process from the pipeline
  53085. */
  53086. chromaticAberrationEnabled: boolean;
  53087. /**
  53088. * Enable or disable the grain process from the pipeline
  53089. */
  53090. grainEnabled: boolean;
  53091. /**
  53092. * @constructor
  53093. * @param name - The rendering pipeline name (default: "")
  53094. * @param hdr - If high dynamic range textures should be used (default: true)
  53095. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53096. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53097. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53098. */
  53099. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53100. /**
  53101. * Get the class name
  53102. * @returns "DefaultRenderingPipeline"
  53103. */
  53104. getClassName(): string;
  53105. /**
  53106. * Force the compilation of the entire pipeline.
  53107. */
  53108. prepare(): void;
  53109. private _hasCleared;
  53110. private _prevPostProcess;
  53111. private _prevPrevPostProcess;
  53112. private _setAutoClearAndTextureSharing;
  53113. private _depthOfFieldSceneObserver;
  53114. private _buildPipeline;
  53115. private _disposePostProcesses;
  53116. /**
  53117. * Adds a camera to the pipeline
  53118. * @param camera the camera to be added
  53119. */
  53120. addCamera(camera: Camera): void;
  53121. /**
  53122. * Removes a camera from the pipeline
  53123. * @param camera the camera to remove
  53124. */
  53125. removeCamera(camera: Camera): void;
  53126. /**
  53127. * Dispose of the pipeline and stop all post processes
  53128. */
  53129. dispose(): void;
  53130. /**
  53131. * Serialize the rendering pipeline (Used when exporting)
  53132. * @returns the serialized object
  53133. */
  53134. serialize(): any;
  53135. /**
  53136. * Parse the serialized pipeline
  53137. * @param source Source pipeline.
  53138. * @param scene The scene to load the pipeline to.
  53139. * @param rootUrl The URL of the serialized pipeline.
  53140. * @returns An instantiated pipeline from the serialized object.
  53141. */
  53142. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53143. }
  53144. }
  53145. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53146. /** @hidden */
  53147. export var lensHighlightsPixelShader: {
  53148. name: string;
  53149. shader: string;
  53150. };
  53151. }
  53152. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53153. /** @hidden */
  53154. export var depthOfFieldPixelShader: {
  53155. name: string;
  53156. shader: string;
  53157. };
  53158. }
  53159. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53160. import { Camera } from "babylonjs/Cameras/camera";
  53161. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53162. import { Scene } from "babylonjs/scene";
  53163. import "babylonjs/Shaders/chromaticAberration.fragment";
  53164. import "babylonjs/Shaders/lensHighlights.fragment";
  53165. import "babylonjs/Shaders/depthOfField.fragment";
  53166. /**
  53167. * BABYLON.JS Chromatic Aberration GLSL Shader
  53168. * Author: Olivier Guyot
  53169. * Separates very slightly R, G and B colors on the edges of the screen
  53170. * Inspired by Francois Tarlier & Martins Upitis
  53171. */
  53172. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53173. /**
  53174. * @ignore
  53175. * The chromatic aberration PostProcess id in the pipeline
  53176. */
  53177. LensChromaticAberrationEffect: string;
  53178. /**
  53179. * @ignore
  53180. * The highlights enhancing PostProcess id in the pipeline
  53181. */
  53182. HighlightsEnhancingEffect: string;
  53183. /**
  53184. * @ignore
  53185. * The depth-of-field PostProcess id in the pipeline
  53186. */
  53187. LensDepthOfFieldEffect: string;
  53188. private _scene;
  53189. private _depthTexture;
  53190. private _grainTexture;
  53191. private _chromaticAberrationPostProcess;
  53192. private _highlightsPostProcess;
  53193. private _depthOfFieldPostProcess;
  53194. private _edgeBlur;
  53195. private _grainAmount;
  53196. private _chromaticAberration;
  53197. private _distortion;
  53198. private _highlightsGain;
  53199. private _highlightsThreshold;
  53200. private _dofDistance;
  53201. private _dofAperture;
  53202. private _dofDarken;
  53203. private _dofPentagon;
  53204. private _blurNoise;
  53205. /**
  53206. * @constructor
  53207. *
  53208. * Effect parameters are as follow:
  53209. * {
  53210. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53211. * edge_blur: number; // from 0 to x (1 for realism)
  53212. * distortion: number; // from 0 to x (1 for realism)
  53213. * grain_amount: number; // from 0 to 1
  53214. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53215. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53216. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53217. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53218. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53219. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53220. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53221. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53222. * }
  53223. * Note: if an effect parameter is unset, effect is disabled
  53224. *
  53225. * @param name The rendering pipeline name
  53226. * @param parameters - An object containing all parameters (see above)
  53227. * @param scene The scene linked to this pipeline
  53228. * @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)
  53229. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53230. */
  53231. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53232. /**
  53233. * Sets the amount of blur at the edges
  53234. * @param amount blur amount
  53235. */
  53236. setEdgeBlur(amount: number): void;
  53237. /**
  53238. * Sets edge blur to 0
  53239. */
  53240. disableEdgeBlur(): void;
  53241. /**
  53242. * Sets the amout of grain
  53243. * @param amount Amount of grain
  53244. */
  53245. setGrainAmount(amount: number): void;
  53246. /**
  53247. * Set grain amount to 0
  53248. */
  53249. disableGrain(): void;
  53250. /**
  53251. * Sets the chromatic aberration amount
  53252. * @param amount amount of chromatic aberration
  53253. */
  53254. setChromaticAberration(amount: number): void;
  53255. /**
  53256. * Sets chromatic aberration amount to 0
  53257. */
  53258. disableChromaticAberration(): void;
  53259. /**
  53260. * Sets the EdgeDistortion amount
  53261. * @param amount amount of EdgeDistortion
  53262. */
  53263. setEdgeDistortion(amount: number): void;
  53264. /**
  53265. * Sets edge distortion to 0
  53266. */
  53267. disableEdgeDistortion(): void;
  53268. /**
  53269. * Sets the FocusDistance amount
  53270. * @param amount amount of FocusDistance
  53271. */
  53272. setFocusDistance(amount: number): void;
  53273. /**
  53274. * Disables depth of field
  53275. */
  53276. disableDepthOfField(): void;
  53277. /**
  53278. * Sets the Aperture amount
  53279. * @param amount amount of Aperture
  53280. */
  53281. setAperture(amount: number): void;
  53282. /**
  53283. * Sets the DarkenOutOfFocus amount
  53284. * @param amount amount of DarkenOutOfFocus
  53285. */
  53286. setDarkenOutOfFocus(amount: number): void;
  53287. /**
  53288. * Creates a pentagon bokeh effect
  53289. */
  53290. enablePentagonBokeh(): void;
  53291. /**
  53292. * Disables the pentagon bokeh effect
  53293. */
  53294. disablePentagonBokeh(): void;
  53295. /**
  53296. * Enables noise blur
  53297. */
  53298. enableNoiseBlur(): void;
  53299. /**
  53300. * Disables noise blur
  53301. */
  53302. disableNoiseBlur(): void;
  53303. /**
  53304. * Sets the HighlightsGain amount
  53305. * @param amount amount of HighlightsGain
  53306. */
  53307. setHighlightsGain(amount: number): void;
  53308. /**
  53309. * Sets the HighlightsThreshold amount
  53310. * @param amount amount of HighlightsThreshold
  53311. */
  53312. setHighlightsThreshold(amount: number): void;
  53313. /**
  53314. * Disables highlights
  53315. */
  53316. disableHighlights(): void;
  53317. /**
  53318. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53319. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53320. */
  53321. dispose(disableDepthRender?: boolean): void;
  53322. private _createChromaticAberrationPostProcess;
  53323. private _createHighlightsPostProcess;
  53324. private _createDepthOfFieldPostProcess;
  53325. private _createGrainTexture;
  53326. }
  53327. }
  53328. declare module "babylonjs/Shaders/ssao2.fragment" {
  53329. /** @hidden */
  53330. export var ssao2PixelShader: {
  53331. name: string;
  53332. shader: string;
  53333. };
  53334. }
  53335. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53336. /** @hidden */
  53337. export var ssaoCombinePixelShader: {
  53338. name: string;
  53339. shader: string;
  53340. };
  53341. }
  53342. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53343. import { Camera } from "babylonjs/Cameras/camera";
  53344. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53345. import { Scene } from "babylonjs/scene";
  53346. import "babylonjs/Shaders/ssao2.fragment";
  53347. import "babylonjs/Shaders/ssaoCombine.fragment";
  53348. /**
  53349. * Render pipeline to produce ssao effect
  53350. */
  53351. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53352. /**
  53353. * @ignore
  53354. * The PassPostProcess id in the pipeline that contains the original scene color
  53355. */
  53356. SSAOOriginalSceneColorEffect: string;
  53357. /**
  53358. * @ignore
  53359. * The SSAO PostProcess id in the pipeline
  53360. */
  53361. SSAORenderEffect: string;
  53362. /**
  53363. * @ignore
  53364. * The horizontal blur PostProcess id in the pipeline
  53365. */
  53366. SSAOBlurHRenderEffect: string;
  53367. /**
  53368. * @ignore
  53369. * The vertical blur PostProcess id in the pipeline
  53370. */
  53371. SSAOBlurVRenderEffect: string;
  53372. /**
  53373. * @ignore
  53374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53375. */
  53376. SSAOCombineRenderEffect: string;
  53377. /**
  53378. * The output strength of the SSAO post-process. Default value is 1.0.
  53379. */
  53380. totalStrength: number;
  53381. /**
  53382. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53383. */
  53384. maxZ: number;
  53385. /**
  53386. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53387. */
  53388. minZAspect: number;
  53389. private _samples;
  53390. /**
  53391. * Number of samples used for the SSAO calculations. Default value is 8
  53392. */
  53393. samples: number;
  53394. private _textureSamples;
  53395. /**
  53396. * Number of samples to use for antialiasing
  53397. */
  53398. textureSamples: number;
  53399. /**
  53400. * Ratio object used for SSAO ratio and blur ratio
  53401. */
  53402. private _ratio;
  53403. /**
  53404. * Dynamically generated sphere sampler.
  53405. */
  53406. private _sampleSphere;
  53407. /**
  53408. * Blur filter offsets
  53409. */
  53410. private _samplerOffsets;
  53411. private _expensiveBlur;
  53412. /**
  53413. * If bilateral blur should be used
  53414. */
  53415. expensiveBlur: boolean;
  53416. /**
  53417. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53418. */
  53419. radius: number;
  53420. /**
  53421. * The base color of the SSAO post-process
  53422. * The final result is "base + ssao" between [0, 1]
  53423. */
  53424. base: number;
  53425. /**
  53426. * Support test.
  53427. */
  53428. static readonly IsSupported: boolean;
  53429. private _scene;
  53430. private _depthTexture;
  53431. private _normalTexture;
  53432. private _randomTexture;
  53433. private _originalColorPostProcess;
  53434. private _ssaoPostProcess;
  53435. private _blurHPostProcess;
  53436. private _blurVPostProcess;
  53437. private _ssaoCombinePostProcess;
  53438. private _firstUpdate;
  53439. /**
  53440. * Gets active scene
  53441. */
  53442. readonly scene: Scene;
  53443. /**
  53444. * @constructor
  53445. * @param name The rendering pipeline name
  53446. * @param scene The scene linked to this pipeline
  53447. * @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 }
  53448. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53449. */
  53450. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53451. /**
  53452. * Get the class name
  53453. * @returns "SSAO2RenderingPipeline"
  53454. */
  53455. getClassName(): string;
  53456. /**
  53457. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53458. */
  53459. dispose(disableGeometryBufferRenderer?: boolean): void;
  53460. private _createBlurPostProcess;
  53461. /** @hidden */
  53462. _rebuild(): void;
  53463. private _bits;
  53464. private _radicalInverse_VdC;
  53465. private _hammersley;
  53466. private _hemisphereSample_uniform;
  53467. private _generateHemisphere;
  53468. private _createSSAOPostProcess;
  53469. private _createSSAOCombinePostProcess;
  53470. private _createRandomTexture;
  53471. /**
  53472. * Serialize the rendering pipeline (Used when exporting)
  53473. * @returns the serialized object
  53474. */
  53475. serialize(): any;
  53476. /**
  53477. * Parse the serialized pipeline
  53478. * @param source Source pipeline.
  53479. * @param scene The scene to load the pipeline to.
  53480. * @param rootUrl The URL of the serialized pipeline.
  53481. * @returns An instantiated pipeline from the serialized object.
  53482. */
  53483. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53484. }
  53485. }
  53486. declare module "babylonjs/Shaders/ssao.fragment" {
  53487. /** @hidden */
  53488. export var ssaoPixelShader: {
  53489. name: string;
  53490. shader: string;
  53491. };
  53492. }
  53493. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53494. import { Camera } from "babylonjs/Cameras/camera";
  53495. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53496. import { Scene } from "babylonjs/scene";
  53497. import "babylonjs/Shaders/ssao.fragment";
  53498. import "babylonjs/Shaders/ssaoCombine.fragment";
  53499. /**
  53500. * Render pipeline to produce ssao effect
  53501. */
  53502. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53503. /**
  53504. * @ignore
  53505. * The PassPostProcess id in the pipeline that contains the original scene color
  53506. */
  53507. SSAOOriginalSceneColorEffect: string;
  53508. /**
  53509. * @ignore
  53510. * The SSAO PostProcess id in the pipeline
  53511. */
  53512. SSAORenderEffect: string;
  53513. /**
  53514. * @ignore
  53515. * The horizontal blur PostProcess id in the pipeline
  53516. */
  53517. SSAOBlurHRenderEffect: string;
  53518. /**
  53519. * @ignore
  53520. * The vertical blur PostProcess id in the pipeline
  53521. */
  53522. SSAOBlurVRenderEffect: string;
  53523. /**
  53524. * @ignore
  53525. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53526. */
  53527. SSAOCombineRenderEffect: string;
  53528. /**
  53529. * The output strength of the SSAO post-process. Default value is 1.0.
  53530. */
  53531. totalStrength: number;
  53532. /**
  53533. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53534. */
  53535. radius: number;
  53536. /**
  53537. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53538. * Must not be equal to fallOff and superior to fallOff.
  53539. * Default value is 0.0075
  53540. */
  53541. area: number;
  53542. /**
  53543. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53544. * Must not be equal to area and inferior to area.
  53545. * Default value is 0.000001
  53546. */
  53547. fallOff: number;
  53548. /**
  53549. * The base color of the SSAO post-process
  53550. * The final result is "base + ssao" between [0, 1]
  53551. */
  53552. base: number;
  53553. private _scene;
  53554. private _depthTexture;
  53555. private _randomTexture;
  53556. private _originalColorPostProcess;
  53557. private _ssaoPostProcess;
  53558. private _blurHPostProcess;
  53559. private _blurVPostProcess;
  53560. private _ssaoCombinePostProcess;
  53561. private _firstUpdate;
  53562. /**
  53563. * Gets active scene
  53564. */
  53565. readonly scene: Scene;
  53566. /**
  53567. * @constructor
  53568. * @param name - The rendering pipeline name
  53569. * @param scene - The scene linked to this pipeline
  53570. * @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 }
  53571. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53572. */
  53573. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53574. /**
  53575. * Get the class name
  53576. * @returns "SSAORenderingPipeline"
  53577. */
  53578. getClassName(): string;
  53579. /**
  53580. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53581. */
  53582. dispose(disableDepthRender?: boolean): void;
  53583. private _createBlurPostProcess;
  53584. /** @hidden */
  53585. _rebuild(): void;
  53586. private _createSSAOPostProcess;
  53587. private _createSSAOCombinePostProcess;
  53588. private _createRandomTexture;
  53589. }
  53590. }
  53591. declare module "babylonjs/Shaders/standard.fragment" {
  53592. /** @hidden */
  53593. export var standardPixelShader: {
  53594. name: string;
  53595. shader: string;
  53596. };
  53597. }
  53598. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53599. import { Nullable } from "babylonjs/types";
  53600. import { IAnimatable } from "babylonjs/Misc/tools";
  53601. import { Camera } from "babylonjs/Cameras/camera";
  53602. import { Texture } from "babylonjs/Materials/Textures/texture";
  53603. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53604. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53605. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53606. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53607. import { IDisposable } from "babylonjs/scene";
  53608. import { SpotLight } from "babylonjs/Lights/spotLight";
  53609. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53610. import { Scene } from "babylonjs/scene";
  53611. import { Animation } from "babylonjs/Animations/animation";
  53612. import "babylonjs/Shaders/standard.fragment";
  53613. /**
  53614. * Standard rendering pipeline
  53615. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53616. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53617. */
  53618. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53619. /**
  53620. * Public members
  53621. */
  53622. /**
  53623. * Post-process which contains the original scene color before the pipeline applies all the effects
  53624. */
  53625. originalPostProcess: Nullable<PostProcess>;
  53626. /**
  53627. * Post-process used to down scale an image x4
  53628. */
  53629. downSampleX4PostProcess: Nullable<PostProcess>;
  53630. /**
  53631. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53632. */
  53633. brightPassPostProcess: Nullable<PostProcess>;
  53634. /**
  53635. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53636. */
  53637. blurHPostProcesses: PostProcess[];
  53638. /**
  53639. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53640. */
  53641. blurVPostProcesses: PostProcess[];
  53642. /**
  53643. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53644. */
  53645. textureAdderPostProcess: Nullable<PostProcess>;
  53646. /**
  53647. * Post-process used to create volumetric lighting effect
  53648. */
  53649. volumetricLightPostProcess: Nullable<PostProcess>;
  53650. /**
  53651. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53652. */
  53653. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53654. /**
  53655. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53656. */
  53657. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53658. /**
  53659. * Post-process used to merge the volumetric light effect and the real scene color
  53660. */
  53661. volumetricLightMergePostProces: Nullable<PostProcess>;
  53662. /**
  53663. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53664. */
  53665. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53666. /**
  53667. * Base post-process used to calculate the average luminance of the final image for HDR
  53668. */
  53669. luminancePostProcess: Nullable<PostProcess>;
  53670. /**
  53671. * Post-processes used to create down sample post-processes in order to get
  53672. * the average luminance of the final image for HDR
  53673. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53674. */
  53675. luminanceDownSamplePostProcesses: PostProcess[];
  53676. /**
  53677. * Post-process used to create a HDR effect (light adaptation)
  53678. */
  53679. hdrPostProcess: Nullable<PostProcess>;
  53680. /**
  53681. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53682. */
  53683. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53684. /**
  53685. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53686. */
  53687. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53688. /**
  53689. * Post-process used to merge the final HDR post-process and the real scene color
  53690. */
  53691. hdrFinalPostProcess: Nullable<PostProcess>;
  53692. /**
  53693. * Post-process used to create a lens flare effect
  53694. */
  53695. lensFlarePostProcess: Nullable<PostProcess>;
  53696. /**
  53697. * Post-process that merges the result of the lens flare post-process and the real scene color
  53698. */
  53699. lensFlareComposePostProcess: Nullable<PostProcess>;
  53700. /**
  53701. * Post-process used to create a motion blur effect
  53702. */
  53703. motionBlurPostProcess: Nullable<PostProcess>;
  53704. /**
  53705. * Post-process used to create a depth of field effect
  53706. */
  53707. depthOfFieldPostProcess: Nullable<PostProcess>;
  53708. /**
  53709. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53710. */
  53711. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53712. /**
  53713. * Represents the brightness threshold in order to configure the illuminated surfaces
  53714. */
  53715. brightThreshold: number;
  53716. /**
  53717. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53718. */
  53719. blurWidth: number;
  53720. /**
  53721. * Sets if the blur for highlighted surfaces must be only horizontal
  53722. */
  53723. horizontalBlur: boolean;
  53724. /**
  53725. * Sets the overall exposure used by the pipeline
  53726. */
  53727. exposure: number;
  53728. /**
  53729. * Texture used typically to simulate "dirty" on camera lens
  53730. */
  53731. lensTexture: Nullable<Texture>;
  53732. /**
  53733. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53734. */
  53735. volumetricLightCoefficient: number;
  53736. /**
  53737. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53738. */
  53739. volumetricLightPower: number;
  53740. /**
  53741. * Used the set the blur intensity to smooth the volumetric lights
  53742. */
  53743. volumetricLightBlurScale: number;
  53744. /**
  53745. * Light (spot or directional) used to generate the volumetric lights rays
  53746. * The source light must have a shadow generate so the pipeline can get its
  53747. * depth map
  53748. */
  53749. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53750. /**
  53751. * For eye adaptation, represents the minimum luminance the eye can see
  53752. */
  53753. hdrMinimumLuminance: number;
  53754. /**
  53755. * For eye adaptation, represents the decrease luminance speed
  53756. */
  53757. hdrDecreaseRate: number;
  53758. /**
  53759. * For eye adaptation, represents the increase luminance speed
  53760. */
  53761. hdrIncreaseRate: number;
  53762. /**
  53763. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53764. */
  53765. lensColorTexture: Nullable<Texture>;
  53766. /**
  53767. * The overall strengh for the lens flare effect
  53768. */
  53769. lensFlareStrength: number;
  53770. /**
  53771. * Dispersion coefficient for lens flare ghosts
  53772. */
  53773. lensFlareGhostDispersal: number;
  53774. /**
  53775. * Main lens flare halo width
  53776. */
  53777. lensFlareHaloWidth: number;
  53778. /**
  53779. * Based on the lens distortion effect, defines how much the lens flare result
  53780. * is distorted
  53781. */
  53782. lensFlareDistortionStrength: number;
  53783. /**
  53784. * Lens star texture must be used to simulate rays on the flares and is available
  53785. * in the documentation
  53786. */
  53787. lensStarTexture: Nullable<Texture>;
  53788. /**
  53789. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53790. * flare effect by taking account of the dirt texture
  53791. */
  53792. lensFlareDirtTexture: Nullable<Texture>;
  53793. /**
  53794. * Represents the focal length for the depth of field effect
  53795. */
  53796. depthOfFieldDistance: number;
  53797. /**
  53798. * Represents the blur intensity for the blurred part of the depth of field effect
  53799. */
  53800. depthOfFieldBlurWidth: number;
  53801. /**
  53802. * For motion blur, defines how much the image is blurred by the movement
  53803. */
  53804. motionStrength: number;
  53805. /**
  53806. * List of animations for the pipeline (IAnimatable implementation)
  53807. */
  53808. animations: Animation[];
  53809. /**
  53810. * Private members
  53811. */
  53812. private _scene;
  53813. private _currentDepthOfFieldSource;
  53814. private _basePostProcess;
  53815. private _hdrCurrentLuminance;
  53816. private _floatTextureType;
  53817. private _ratio;
  53818. private _bloomEnabled;
  53819. private _depthOfFieldEnabled;
  53820. private _vlsEnabled;
  53821. private _lensFlareEnabled;
  53822. private _hdrEnabled;
  53823. private _motionBlurEnabled;
  53824. private _fxaaEnabled;
  53825. private _motionBlurSamples;
  53826. private _volumetricLightStepsCount;
  53827. private _samples;
  53828. /**
  53829. * @ignore
  53830. * Specifies if the bloom pipeline is enabled
  53831. */
  53832. BloomEnabled: boolean;
  53833. /**
  53834. * @ignore
  53835. * Specifies if the depth of field pipeline is enabed
  53836. */
  53837. DepthOfFieldEnabled: boolean;
  53838. /**
  53839. * @ignore
  53840. * Specifies if the lens flare pipeline is enabed
  53841. */
  53842. LensFlareEnabled: boolean;
  53843. /**
  53844. * @ignore
  53845. * Specifies if the HDR pipeline is enabled
  53846. */
  53847. HDREnabled: boolean;
  53848. /**
  53849. * @ignore
  53850. * Specifies if the volumetric lights scattering effect is enabled
  53851. */
  53852. VLSEnabled: boolean;
  53853. /**
  53854. * @ignore
  53855. * Specifies if the motion blur effect is enabled
  53856. */
  53857. MotionBlurEnabled: boolean;
  53858. /**
  53859. * Specifies if anti-aliasing is enabled
  53860. */
  53861. fxaaEnabled: boolean;
  53862. /**
  53863. * Specifies the number of steps used to calculate the volumetric lights
  53864. * Typically in interval [50, 200]
  53865. */
  53866. volumetricLightStepsCount: number;
  53867. /**
  53868. * Specifies the number of samples used for the motion blur effect
  53869. * Typically in interval [16, 64]
  53870. */
  53871. motionBlurSamples: number;
  53872. /**
  53873. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53874. */
  53875. samples: number;
  53876. /**
  53877. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53878. * @constructor
  53879. * @param name The rendering pipeline name
  53880. * @param scene The scene linked to this pipeline
  53881. * @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)
  53882. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53883. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53884. */
  53885. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53886. private _buildPipeline;
  53887. private _createDownSampleX4PostProcess;
  53888. private _createBrightPassPostProcess;
  53889. private _createBlurPostProcesses;
  53890. private _createTextureAdderPostProcess;
  53891. private _createVolumetricLightPostProcess;
  53892. private _createLuminancePostProcesses;
  53893. private _createHdrPostProcess;
  53894. private _createLensFlarePostProcess;
  53895. private _createDepthOfFieldPostProcess;
  53896. private _createMotionBlurPostProcess;
  53897. private _getDepthTexture;
  53898. private _disposePostProcesses;
  53899. /**
  53900. * Dispose of the pipeline and stop all post processes
  53901. */
  53902. dispose(): void;
  53903. /**
  53904. * Serialize the rendering pipeline (Used when exporting)
  53905. * @returns the serialized object
  53906. */
  53907. serialize(): any;
  53908. /**
  53909. * Parse the serialized pipeline
  53910. * @param source Source pipeline.
  53911. * @param scene The scene to load the pipeline to.
  53912. * @param rootUrl The URL of the serialized pipeline.
  53913. * @returns An instantiated pipeline from the serialized object.
  53914. */
  53915. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53916. /**
  53917. * Luminance steps
  53918. */
  53919. static LuminanceSteps: number;
  53920. }
  53921. }
  53922. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53923. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53924. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53925. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53926. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53927. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53928. }
  53929. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53930. import { Camera } from "babylonjs/Cameras/camera";
  53931. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53932. /**
  53933. * PostProcessRenderPipelineManager class
  53934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53935. */
  53936. export class PostProcessRenderPipelineManager {
  53937. private _renderPipelines;
  53938. /**
  53939. * Initializes a PostProcessRenderPipelineManager
  53940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53941. */
  53942. constructor();
  53943. /**
  53944. * Gets the list of supported render pipelines
  53945. */
  53946. readonly supportedPipelines: PostProcessRenderPipeline[];
  53947. /**
  53948. * Adds a pipeline to the manager
  53949. * @param renderPipeline The pipeline to add
  53950. */
  53951. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53952. /**
  53953. * Attaches a camera to the pipeline
  53954. * @param renderPipelineName The name of the pipeline to attach to
  53955. * @param cameras the camera to attach
  53956. * @param unique if the camera can be attached multiple times to the pipeline
  53957. */
  53958. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53959. /**
  53960. * Detaches a camera from the pipeline
  53961. * @param renderPipelineName The name of the pipeline to detach from
  53962. * @param cameras the camera to detach
  53963. */
  53964. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53965. /**
  53966. * Enables an effect by name on a pipeline
  53967. * @param renderPipelineName the name of the pipeline to enable the effect in
  53968. * @param renderEffectName the name of the effect to enable
  53969. * @param cameras the cameras that the effect should be enabled on
  53970. */
  53971. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53972. /**
  53973. * Disables an effect by name on a pipeline
  53974. * @param renderPipelineName the name of the pipeline to disable the effect in
  53975. * @param renderEffectName the name of the effect to disable
  53976. * @param cameras the cameras that the effect should be disabled on
  53977. */
  53978. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53979. /**
  53980. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53981. */
  53982. update(): void;
  53983. /** @hidden */
  53984. _rebuild(): void;
  53985. /**
  53986. * Disposes of the manager and pipelines
  53987. */
  53988. dispose(): void;
  53989. }
  53990. }
  53991. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53992. import { ISceneComponent } from "babylonjs/sceneComponent";
  53993. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53994. import { Scene } from "babylonjs/scene";
  53995. module "babylonjs/scene" {
  53996. interface Scene {
  53997. /** @hidden (Backing field) */
  53998. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53999. /**
  54000. * Gets the postprocess render pipeline manager
  54001. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54002. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54003. */
  54004. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54005. }
  54006. }
  54007. /**
  54008. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54009. */
  54010. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54011. /**
  54012. * The component name helpfull to identify the component in the list of scene components.
  54013. */
  54014. readonly name: string;
  54015. /**
  54016. * The scene the component belongs to.
  54017. */
  54018. scene: Scene;
  54019. /**
  54020. * Creates a new instance of the component for the given scene
  54021. * @param scene Defines the scene to register the component in
  54022. */
  54023. constructor(scene: Scene);
  54024. /**
  54025. * Registers the component in a given scene
  54026. */
  54027. register(): void;
  54028. /**
  54029. * Rebuilds the elements related to this component in case of
  54030. * context lost for instance.
  54031. */
  54032. rebuild(): void;
  54033. /**
  54034. * Disposes the component and the associated ressources
  54035. */
  54036. dispose(): void;
  54037. private _gatherRenderTargets;
  54038. }
  54039. }
  54040. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54041. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54042. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54043. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54044. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54045. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54046. }
  54047. declare module "babylonjs/Shaders/tonemap.fragment" {
  54048. /** @hidden */
  54049. export var tonemapPixelShader: {
  54050. name: string;
  54051. shader: string;
  54052. };
  54053. }
  54054. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54055. import { Camera } from "babylonjs/Cameras/camera";
  54056. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54057. import "babylonjs/Shaders/tonemap.fragment";
  54058. import { Engine } from "babylonjs/Engines/engine";
  54059. /** Defines operator used for tonemapping */
  54060. export enum TonemappingOperator {
  54061. /** Hable */
  54062. Hable = 0,
  54063. /** Reinhard */
  54064. Reinhard = 1,
  54065. /** HejiDawson */
  54066. HejiDawson = 2,
  54067. /** Photographic */
  54068. Photographic = 3
  54069. }
  54070. /**
  54071. * Defines a post process to apply tone mapping
  54072. */
  54073. export class TonemapPostProcess extends PostProcess {
  54074. private _operator;
  54075. /** Defines the required exposure adjustement */
  54076. exposureAdjustment: number;
  54077. /**
  54078. * Creates a new TonemapPostProcess
  54079. * @param name defines the name of the postprocess
  54080. * @param _operator defines the operator to use
  54081. * @param exposureAdjustment defines the required exposure adjustement
  54082. * @param camera defines the camera to use (can be null)
  54083. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54084. * @param engine defines the hosting engine (can be ignore if camera is set)
  54085. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54086. */
  54087. constructor(name: string, _operator: TonemappingOperator,
  54088. /** Defines the required exposure adjustement */
  54089. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54090. }
  54091. }
  54092. declare module "babylonjs/Shaders/depth.vertex" {
  54093. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54094. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54095. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54096. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54097. /** @hidden */
  54098. export var depthVertexShader: {
  54099. name: string;
  54100. shader: string;
  54101. };
  54102. }
  54103. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54104. /** @hidden */
  54105. export var volumetricLightScatteringPixelShader: {
  54106. name: string;
  54107. shader: string;
  54108. };
  54109. }
  54110. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54111. /** @hidden */
  54112. export var volumetricLightScatteringPassPixelShader: {
  54113. name: string;
  54114. shader: string;
  54115. };
  54116. }
  54117. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54118. import { Vector3 } from "babylonjs/Maths/math";
  54119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54120. import { Mesh } from "babylonjs/Meshes/mesh";
  54121. import { Camera } from "babylonjs/Cameras/camera";
  54122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54124. import { Scene } from "babylonjs/scene";
  54125. import "babylonjs/Meshes/Builders/planeBuilder";
  54126. import "babylonjs/Shaders/depth.vertex";
  54127. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54128. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54129. import { Engine } from "babylonjs/Engines/engine";
  54130. /**
  54131. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54132. */
  54133. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54134. private _volumetricLightScatteringPass;
  54135. private _volumetricLightScatteringRTT;
  54136. private _viewPort;
  54137. private _screenCoordinates;
  54138. private _cachedDefines;
  54139. /**
  54140. * If not undefined, the mesh position is computed from the attached node position
  54141. */
  54142. attachedNode: {
  54143. position: Vector3;
  54144. };
  54145. /**
  54146. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54147. */
  54148. customMeshPosition: Vector3;
  54149. /**
  54150. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54151. */
  54152. useCustomMeshPosition: boolean;
  54153. /**
  54154. * If the post-process should inverse the light scattering direction
  54155. */
  54156. invert: boolean;
  54157. /**
  54158. * The internal mesh used by the post-process
  54159. */
  54160. mesh: Mesh;
  54161. /**
  54162. * @hidden
  54163. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54164. */
  54165. useDiffuseColor: boolean;
  54166. /**
  54167. * Array containing the excluded meshes not rendered in the internal pass
  54168. */
  54169. excludedMeshes: AbstractMesh[];
  54170. /**
  54171. * Controls the overall intensity of the post-process
  54172. */
  54173. exposure: number;
  54174. /**
  54175. * Dissipates each sample's contribution in range [0, 1]
  54176. */
  54177. decay: number;
  54178. /**
  54179. * Controls the overall intensity of each sample
  54180. */
  54181. weight: number;
  54182. /**
  54183. * Controls the density of each sample
  54184. */
  54185. density: number;
  54186. /**
  54187. * @constructor
  54188. * @param name The post-process name
  54189. * @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)
  54190. * @param camera The camera that the post-process will be attached to
  54191. * @param mesh The mesh used to create the light scattering
  54192. * @param samples The post-process quality, default 100
  54193. * @param samplingModeThe post-process filtering mode
  54194. * @param engine The babylon engine
  54195. * @param reusable If the post-process is reusable
  54196. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54197. */
  54198. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54199. /**
  54200. * Returns the string "VolumetricLightScatteringPostProcess"
  54201. * @returns "VolumetricLightScatteringPostProcess"
  54202. */
  54203. getClassName(): string;
  54204. private _isReady;
  54205. /**
  54206. * Sets the new light position for light scattering effect
  54207. * @param position The new custom light position
  54208. */
  54209. setCustomMeshPosition(position: Vector3): void;
  54210. /**
  54211. * Returns the light position for light scattering effect
  54212. * @return Vector3 The custom light position
  54213. */
  54214. getCustomMeshPosition(): Vector3;
  54215. /**
  54216. * Disposes the internal assets and detaches the post-process from the camera
  54217. */
  54218. dispose(camera: Camera): void;
  54219. /**
  54220. * Returns the render target texture used by the post-process
  54221. * @return the render target texture used by the post-process
  54222. */
  54223. getPass(): RenderTargetTexture;
  54224. private _meshExcluded;
  54225. private _createPass;
  54226. private _updateMeshScreenCoordinates;
  54227. /**
  54228. * Creates a default mesh for the Volumeric Light Scattering post-process
  54229. * @param name The mesh name
  54230. * @param scene The scene where to create the mesh
  54231. * @return the default mesh
  54232. */
  54233. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54234. }
  54235. }
  54236. declare module "babylonjs/PostProcesses/index" {
  54237. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54238. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54239. export * from "babylonjs/PostProcesses/bloomEffect";
  54240. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54241. export * from "babylonjs/PostProcesses/blurPostProcess";
  54242. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54243. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54244. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54245. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54246. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54247. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54248. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54249. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54250. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54251. export * from "babylonjs/PostProcesses/filterPostProcess";
  54252. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54253. export * from "babylonjs/PostProcesses/grainPostProcess";
  54254. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54255. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54256. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54257. export * from "babylonjs/PostProcesses/passPostProcess";
  54258. export * from "babylonjs/PostProcesses/postProcess";
  54259. export * from "babylonjs/PostProcesses/postProcessManager";
  54260. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54261. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54262. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54263. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54264. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54265. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54266. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54267. }
  54268. declare module "babylonjs/Probes/index" {
  54269. export * from "babylonjs/Probes/reflectionProbe";
  54270. }
  54271. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54272. import { Scene } from "babylonjs/scene";
  54273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54274. import { Color3 } from "babylonjs/Maths/math";
  54275. import { SmartArray } from "babylonjs/Misc/smartArray";
  54276. import { ISceneComponent } from "babylonjs/sceneComponent";
  54277. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54278. import "babylonjs/Meshes/Builders/boxBuilder";
  54279. import "babylonjs/Shaders/color.fragment";
  54280. import "babylonjs/Shaders/color.vertex";
  54281. module "babylonjs/scene" {
  54282. interface Scene {
  54283. /** @hidden (Backing field) */
  54284. _boundingBoxRenderer: BoundingBoxRenderer;
  54285. /** @hidden (Backing field) */
  54286. _forceShowBoundingBoxes: boolean;
  54287. /**
  54288. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54289. */
  54290. forceShowBoundingBoxes: boolean;
  54291. /**
  54292. * Gets the bounding box renderer associated with the scene
  54293. * @returns a BoundingBoxRenderer
  54294. */
  54295. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54296. }
  54297. }
  54298. module "babylonjs/Meshes/abstractMesh" {
  54299. interface AbstractMesh {
  54300. /** @hidden (Backing field) */
  54301. _showBoundingBox: boolean;
  54302. /**
  54303. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54304. */
  54305. showBoundingBox: boolean;
  54306. }
  54307. }
  54308. /**
  54309. * Component responsible of rendering the bounding box of the meshes in a scene.
  54310. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54311. */
  54312. export class BoundingBoxRenderer implements ISceneComponent {
  54313. /**
  54314. * The component name helpfull to identify the component in the list of scene components.
  54315. */
  54316. readonly name: string;
  54317. /**
  54318. * The scene the component belongs to.
  54319. */
  54320. scene: Scene;
  54321. /**
  54322. * Color of the bounding box lines placed in front of an object
  54323. */
  54324. frontColor: Color3;
  54325. /**
  54326. * Color of the bounding box lines placed behind an object
  54327. */
  54328. backColor: Color3;
  54329. /**
  54330. * Defines if the renderer should show the back lines or not
  54331. */
  54332. showBackLines: boolean;
  54333. /**
  54334. * @hidden
  54335. */
  54336. renderList: SmartArray<BoundingBox>;
  54337. private _colorShader;
  54338. private _vertexBuffers;
  54339. private _indexBuffer;
  54340. /**
  54341. * Instantiates a new bounding box renderer in a scene.
  54342. * @param scene the scene the renderer renders in
  54343. */
  54344. constructor(scene: Scene);
  54345. /**
  54346. * Registers the component in a given scene
  54347. */
  54348. register(): void;
  54349. private _evaluateSubMesh;
  54350. private _activeMesh;
  54351. private _prepareRessources;
  54352. private _createIndexBuffer;
  54353. /**
  54354. * Rebuilds the elements related to this component in case of
  54355. * context lost for instance.
  54356. */
  54357. rebuild(): void;
  54358. /**
  54359. * @hidden
  54360. */
  54361. reset(): void;
  54362. /**
  54363. * Render the bounding boxes of a specific rendering group
  54364. * @param renderingGroupId defines the rendering group to render
  54365. */
  54366. render(renderingGroupId: number): void;
  54367. /**
  54368. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54369. * @param mesh Define the mesh to render the occlusion bounding box for
  54370. */
  54371. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54372. /**
  54373. * Dispose and release the resources attached to this renderer.
  54374. */
  54375. dispose(): void;
  54376. }
  54377. }
  54378. declare module "babylonjs/Shaders/depth.fragment" {
  54379. /** @hidden */
  54380. export var depthPixelShader: {
  54381. name: string;
  54382. shader: string;
  54383. };
  54384. }
  54385. declare module "babylonjs/Rendering/depthRenderer" {
  54386. import { Nullable } from "babylonjs/types";
  54387. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54388. import { Scene } from "babylonjs/scene";
  54389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54390. import { Camera } from "babylonjs/Cameras/camera";
  54391. import "babylonjs/Shaders/depth.fragment";
  54392. import "babylonjs/Shaders/depth.vertex";
  54393. /**
  54394. * This represents a depth renderer in Babylon.
  54395. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54396. */
  54397. export class DepthRenderer {
  54398. private _scene;
  54399. private _depthMap;
  54400. private _effect;
  54401. private _cachedDefines;
  54402. private _camera;
  54403. /**
  54404. * Specifiess that the depth renderer will only be used within
  54405. * the camera it is created for.
  54406. * This can help forcing its rendering during the camera processing.
  54407. */
  54408. useOnlyInActiveCamera: boolean;
  54409. /** @hidden */
  54410. static _SceneComponentInitialization: (scene: Scene) => void;
  54411. /**
  54412. * Instantiates a depth renderer
  54413. * @param scene The scene the renderer belongs to
  54414. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54415. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54416. */
  54417. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54418. /**
  54419. * Creates the depth rendering effect and checks if the effect is ready.
  54420. * @param subMesh The submesh to be used to render the depth map of
  54421. * @param useInstances If multiple world instances should be used
  54422. * @returns if the depth renderer is ready to render the depth map
  54423. */
  54424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54425. /**
  54426. * Gets the texture which the depth map will be written to.
  54427. * @returns The depth map texture
  54428. */
  54429. getDepthMap(): RenderTargetTexture;
  54430. /**
  54431. * Disposes of the depth renderer.
  54432. */
  54433. dispose(): void;
  54434. }
  54435. }
  54436. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54437. import { Nullable } from "babylonjs/types";
  54438. import { Scene } from "babylonjs/scene";
  54439. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54440. import { Camera } from "babylonjs/Cameras/camera";
  54441. import { ISceneComponent } from "babylonjs/sceneComponent";
  54442. module "babylonjs/scene" {
  54443. interface Scene {
  54444. /** @hidden (Backing field) */
  54445. _depthRenderer: {
  54446. [id: string]: DepthRenderer;
  54447. };
  54448. /**
  54449. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54450. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54451. * @returns the created depth renderer
  54452. */
  54453. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54454. /**
  54455. * Disables a depth renderer for a given camera
  54456. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54457. */
  54458. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54459. }
  54460. }
  54461. /**
  54462. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54463. * in several rendering techniques.
  54464. */
  54465. export class DepthRendererSceneComponent implements ISceneComponent {
  54466. /**
  54467. * The component name helpfull to identify the component in the list of scene components.
  54468. */
  54469. readonly name: string;
  54470. /**
  54471. * The scene the component belongs to.
  54472. */
  54473. scene: Scene;
  54474. /**
  54475. * Creates a new instance of the component for the given scene
  54476. * @param scene Defines the scene to register the component in
  54477. */
  54478. constructor(scene: Scene);
  54479. /**
  54480. * Registers the component in a given scene
  54481. */
  54482. register(): void;
  54483. /**
  54484. * Rebuilds the elements related to this component in case of
  54485. * context lost for instance.
  54486. */
  54487. rebuild(): void;
  54488. /**
  54489. * Disposes the component and the associated ressources
  54490. */
  54491. dispose(): void;
  54492. private _gatherRenderTargets;
  54493. private _gatherActiveCameraRenderTargets;
  54494. }
  54495. }
  54496. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54497. import { Nullable } from "babylonjs/types";
  54498. import { Scene } from "babylonjs/scene";
  54499. import { ISceneComponent } from "babylonjs/sceneComponent";
  54500. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54501. module "babylonjs/scene" {
  54502. interface Scene {
  54503. /** @hidden (Backing field) */
  54504. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54505. /**
  54506. * Gets or Sets the current geometry buffer associated to the scene.
  54507. */
  54508. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54509. /**
  54510. * Enables a GeometryBufferRender and associates it with the scene
  54511. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54512. * @returns the GeometryBufferRenderer
  54513. */
  54514. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54515. /**
  54516. * Disables the GeometryBufferRender associated with the scene
  54517. */
  54518. disableGeometryBufferRenderer(): void;
  54519. }
  54520. }
  54521. /**
  54522. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54523. * in several rendering techniques.
  54524. */
  54525. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54526. /**
  54527. * The component name helpful to identify the component in the list of scene components.
  54528. */
  54529. readonly name: string;
  54530. /**
  54531. * The scene the component belongs to.
  54532. */
  54533. scene: Scene;
  54534. /**
  54535. * Creates a new instance of the component for the given scene
  54536. * @param scene Defines the scene to register the component in
  54537. */
  54538. constructor(scene: Scene);
  54539. /**
  54540. * Registers the component in a given scene
  54541. */
  54542. register(): void;
  54543. /**
  54544. * Rebuilds the elements related to this component in case of
  54545. * context lost for instance.
  54546. */
  54547. rebuild(): void;
  54548. /**
  54549. * Disposes the component and the associated ressources
  54550. */
  54551. dispose(): void;
  54552. private _gatherRenderTargets;
  54553. }
  54554. }
  54555. declare module "babylonjs/Shaders/outline.fragment" {
  54556. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54557. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54558. /** @hidden */
  54559. export var outlinePixelShader: {
  54560. name: string;
  54561. shader: string;
  54562. };
  54563. }
  54564. declare module "babylonjs/Shaders/outline.vertex" {
  54565. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54566. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54567. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54568. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54569. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54570. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54571. /** @hidden */
  54572. export var outlineVertexShader: {
  54573. name: string;
  54574. shader: string;
  54575. };
  54576. }
  54577. declare module "babylonjs/Rendering/outlineRenderer" {
  54578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54579. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54580. import { Scene } from "babylonjs/scene";
  54581. import { ISceneComponent } from "babylonjs/sceneComponent";
  54582. import "babylonjs/Shaders/outline.fragment";
  54583. import "babylonjs/Shaders/outline.vertex";
  54584. module "babylonjs/scene" {
  54585. interface Scene {
  54586. /** @hidden */
  54587. _outlineRenderer: OutlineRenderer;
  54588. /**
  54589. * Gets the outline renderer associated with the scene
  54590. * @returns a OutlineRenderer
  54591. */
  54592. getOutlineRenderer(): OutlineRenderer;
  54593. }
  54594. }
  54595. module "babylonjs/Meshes/abstractMesh" {
  54596. interface AbstractMesh {
  54597. /** @hidden (Backing field) */
  54598. _renderOutline: boolean;
  54599. /**
  54600. * Gets or sets a boolean indicating if the outline must be rendered as well
  54601. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54602. */
  54603. renderOutline: boolean;
  54604. /** @hidden (Backing field) */
  54605. _renderOverlay: boolean;
  54606. /**
  54607. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54608. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54609. */
  54610. renderOverlay: boolean;
  54611. }
  54612. }
  54613. /**
  54614. * This class is responsible to draw bothe outline/overlay of meshes.
  54615. * It should not be used directly but through the available method on mesh.
  54616. */
  54617. export class OutlineRenderer implements ISceneComponent {
  54618. /**
  54619. * The name of the component. Each component must have a unique name.
  54620. */
  54621. name: string;
  54622. /**
  54623. * The scene the component belongs to.
  54624. */
  54625. scene: Scene;
  54626. /**
  54627. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54628. */
  54629. zOffset: number;
  54630. private _engine;
  54631. private _effect;
  54632. private _cachedDefines;
  54633. private _savedDepthWrite;
  54634. /**
  54635. * Instantiates a new outline renderer. (There could be only one per scene).
  54636. * @param scene Defines the scene it belongs to
  54637. */
  54638. constructor(scene: Scene);
  54639. /**
  54640. * Register the component to one instance of a scene.
  54641. */
  54642. register(): void;
  54643. /**
  54644. * Rebuilds the elements related to this component in case of
  54645. * context lost for instance.
  54646. */
  54647. rebuild(): void;
  54648. /**
  54649. * Disposes the component and the associated ressources.
  54650. */
  54651. dispose(): void;
  54652. /**
  54653. * Renders the outline in the canvas.
  54654. * @param subMesh Defines the sumesh to render
  54655. * @param batch Defines the batch of meshes in case of instances
  54656. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54657. */
  54658. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54659. /**
  54660. * Returns whether or not the outline renderer is ready for a given submesh.
  54661. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54662. * @param subMesh Defines the submesh to check readyness for
  54663. * @param useInstances Defines wheter wee are trying to render instances or not
  54664. * @returns true if ready otherwise false
  54665. */
  54666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54667. private _beforeRenderingMesh;
  54668. private _afterRenderingMesh;
  54669. }
  54670. }
  54671. declare module "babylonjs/Rendering/index" {
  54672. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54673. export * from "babylonjs/Rendering/depthRenderer";
  54674. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54675. export * from "babylonjs/Rendering/edgesRenderer";
  54676. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54677. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54678. export * from "babylonjs/Rendering/outlineRenderer";
  54679. export * from "babylonjs/Rendering/renderingGroup";
  54680. export * from "babylonjs/Rendering/renderingManager";
  54681. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54682. }
  54683. declare module "babylonjs/Sprites/index" {
  54684. export * from "babylonjs/Sprites/sprite";
  54685. export * from "babylonjs/Sprites/spriteManager";
  54686. export * from "babylonjs/Sprites/spriteSceneComponent";
  54687. }
  54688. declare module "babylonjs/Misc/assetsManager" {
  54689. import { Scene } from "babylonjs/scene";
  54690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54691. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54692. import { Skeleton } from "babylonjs/Bones/skeleton";
  54693. import { Observable } from "babylonjs/Misc/observable";
  54694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54695. import { Texture } from "babylonjs/Materials/Textures/texture";
  54696. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54697. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54698. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54699. /**
  54700. * Defines the list of states available for a task inside a AssetsManager
  54701. */
  54702. export enum AssetTaskState {
  54703. /**
  54704. * Initialization
  54705. */
  54706. INIT = 0,
  54707. /**
  54708. * Running
  54709. */
  54710. RUNNING = 1,
  54711. /**
  54712. * Done
  54713. */
  54714. DONE = 2,
  54715. /**
  54716. * Error
  54717. */
  54718. ERROR = 3
  54719. }
  54720. /**
  54721. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54722. */
  54723. export abstract class AbstractAssetTask {
  54724. /**
  54725. * Task name
  54726. */ name: string;
  54727. /**
  54728. * Callback called when the task is successful
  54729. */
  54730. onSuccess: (task: any) => void;
  54731. /**
  54732. * Callback called when the task is not successful
  54733. */
  54734. onError: (task: any, message?: string, exception?: any) => void;
  54735. /**
  54736. * Creates a new AssetsManager
  54737. * @param name defines the name of the task
  54738. */
  54739. constructor(
  54740. /**
  54741. * Task name
  54742. */ name: string);
  54743. private _isCompleted;
  54744. private _taskState;
  54745. private _errorObject;
  54746. /**
  54747. * Get if the task is completed
  54748. */
  54749. readonly isCompleted: boolean;
  54750. /**
  54751. * Gets the current state of the task
  54752. */
  54753. readonly taskState: AssetTaskState;
  54754. /**
  54755. * Gets the current error object (if task is in error)
  54756. */
  54757. readonly errorObject: {
  54758. message?: string;
  54759. exception?: any;
  54760. };
  54761. /**
  54762. * Internal only
  54763. * @hidden
  54764. */
  54765. _setErrorObject(message?: string, exception?: any): void;
  54766. /**
  54767. * Execute the current task
  54768. * @param scene defines the scene where you want your assets to be loaded
  54769. * @param onSuccess is a callback called when the task is successfully executed
  54770. * @param onError is a callback called if an error occurs
  54771. */
  54772. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54773. /**
  54774. * Execute the current task
  54775. * @param scene defines the scene where you want your assets to be loaded
  54776. * @param onSuccess is a callback called when the task is successfully executed
  54777. * @param onError is a callback called if an error occurs
  54778. */
  54779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54780. /**
  54781. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54782. * This can be used with failed tasks that have the reason for failure fixed.
  54783. */
  54784. reset(): void;
  54785. private onErrorCallback;
  54786. private onDoneCallback;
  54787. }
  54788. /**
  54789. * Define the interface used by progress events raised during assets loading
  54790. */
  54791. export interface IAssetsProgressEvent {
  54792. /**
  54793. * Defines the number of remaining tasks to process
  54794. */
  54795. remainingCount: number;
  54796. /**
  54797. * Defines the total number of tasks
  54798. */
  54799. totalCount: number;
  54800. /**
  54801. * Defines the task that was just processed
  54802. */
  54803. task: AbstractAssetTask;
  54804. }
  54805. /**
  54806. * Class used to share progress information about assets loading
  54807. */
  54808. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54809. /**
  54810. * Defines the number of remaining tasks to process
  54811. */
  54812. remainingCount: number;
  54813. /**
  54814. * Defines the total number of tasks
  54815. */
  54816. totalCount: number;
  54817. /**
  54818. * Defines the task that was just processed
  54819. */
  54820. task: AbstractAssetTask;
  54821. /**
  54822. * Creates a AssetsProgressEvent
  54823. * @param remainingCount defines the number of remaining tasks to process
  54824. * @param totalCount defines the total number of tasks
  54825. * @param task defines the task that was just processed
  54826. */
  54827. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54828. }
  54829. /**
  54830. * Define a task used by AssetsManager to load meshes
  54831. */
  54832. export class MeshAssetTask extends AbstractAssetTask {
  54833. /**
  54834. * Defines the name of the task
  54835. */
  54836. name: string;
  54837. /**
  54838. * Defines the list of mesh's names you want to load
  54839. */
  54840. meshesNames: any;
  54841. /**
  54842. * Defines the root url to use as a base to load your meshes and associated resources
  54843. */
  54844. rootUrl: string;
  54845. /**
  54846. * Defines the filename of the scene to load from
  54847. */
  54848. sceneFilename: string;
  54849. /**
  54850. * Gets the list of loaded meshes
  54851. */
  54852. loadedMeshes: Array<AbstractMesh>;
  54853. /**
  54854. * Gets the list of loaded particle systems
  54855. */
  54856. loadedParticleSystems: Array<IParticleSystem>;
  54857. /**
  54858. * Gets the list of loaded skeletons
  54859. */
  54860. loadedSkeletons: Array<Skeleton>;
  54861. /**
  54862. * Gets the list of loaded animation groups
  54863. */
  54864. loadedAnimationGroups: Array<AnimationGroup>;
  54865. /**
  54866. * Callback called when the task is successful
  54867. */
  54868. onSuccess: (task: MeshAssetTask) => void;
  54869. /**
  54870. * Callback called when the task is successful
  54871. */
  54872. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54873. /**
  54874. * Creates a new MeshAssetTask
  54875. * @param name defines the name of the task
  54876. * @param meshesNames defines the list of mesh's names you want to load
  54877. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54878. * @param sceneFilename defines the filename of the scene to load from
  54879. */
  54880. constructor(
  54881. /**
  54882. * Defines the name of the task
  54883. */
  54884. name: string,
  54885. /**
  54886. * Defines the list of mesh's names you want to load
  54887. */
  54888. meshesNames: any,
  54889. /**
  54890. * Defines the root url to use as a base to load your meshes and associated resources
  54891. */
  54892. rootUrl: string,
  54893. /**
  54894. * Defines the filename of the scene to load from
  54895. */
  54896. sceneFilename: string);
  54897. /**
  54898. * Execute the current task
  54899. * @param scene defines the scene where you want your assets to be loaded
  54900. * @param onSuccess is a callback called when the task is successfully executed
  54901. * @param onError is a callback called if an error occurs
  54902. */
  54903. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54904. }
  54905. /**
  54906. * Define a task used by AssetsManager to load text content
  54907. */
  54908. export class TextFileAssetTask extends AbstractAssetTask {
  54909. /**
  54910. * Defines the name of the task
  54911. */
  54912. name: string;
  54913. /**
  54914. * Defines the location of the file to load
  54915. */
  54916. url: string;
  54917. /**
  54918. * Gets the loaded text string
  54919. */
  54920. text: string;
  54921. /**
  54922. * Callback called when the task is successful
  54923. */
  54924. onSuccess: (task: TextFileAssetTask) => void;
  54925. /**
  54926. * Callback called when the task is successful
  54927. */
  54928. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54929. /**
  54930. * Creates a new TextFileAssetTask object
  54931. * @param name defines the name of the task
  54932. * @param url defines the location of the file to load
  54933. */
  54934. constructor(
  54935. /**
  54936. * Defines the name of the task
  54937. */
  54938. name: string,
  54939. /**
  54940. * Defines the location of the file to load
  54941. */
  54942. url: string);
  54943. /**
  54944. * Execute the current task
  54945. * @param scene defines the scene where you want your assets to be loaded
  54946. * @param onSuccess is a callback called when the task is successfully executed
  54947. * @param onError is a callback called if an error occurs
  54948. */
  54949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54950. }
  54951. /**
  54952. * Define a task used by AssetsManager to load binary data
  54953. */
  54954. export class BinaryFileAssetTask extends AbstractAssetTask {
  54955. /**
  54956. * Defines the name of the task
  54957. */
  54958. name: string;
  54959. /**
  54960. * Defines the location of the file to load
  54961. */
  54962. url: string;
  54963. /**
  54964. * Gets the lodaded data (as an array buffer)
  54965. */
  54966. data: ArrayBuffer;
  54967. /**
  54968. * Callback called when the task is successful
  54969. */
  54970. onSuccess: (task: BinaryFileAssetTask) => void;
  54971. /**
  54972. * Callback called when the task is successful
  54973. */
  54974. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54975. /**
  54976. * Creates a new BinaryFileAssetTask object
  54977. * @param name defines the name of the new task
  54978. * @param url defines the location of the file to load
  54979. */
  54980. constructor(
  54981. /**
  54982. * Defines the name of the task
  54983. */
  54984. name: string,
  54985. /**
  54986. * Defines the location of the file to load
  54987. */
  54988. url: string);
  54989. /**
  54990. * Execute the current task
  54991. * @param scene defines the scene where you want your assets to be loaded
  54992. * @param onSuccess is a callback called when the task is successfully executed
  54993. * @param onError is a callback called if an error occurs
  54994. */
  54995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54996. }
  54997. /**
  54998. * Define a task used by AssetsManager to load images
  54999. */
  55000. export class ImageAssetTask extends AbstractAssetTask {
  55001. /**
  55002. * Defines the name of the task
  55003. */
  55004. name: string;
  55005. /**
  55006. * Defines the location of the image to load
  55007. */
  55008. url: string;
  55009. /**
  55010. * Gets the loaded images
  55011. */
  55012. image: HTMLImageElement;
  55013. /**
  55014. * Callback called when the task is successful
  55015. */
  55016. onSuccess: (task: ImageAssetTask) => void;
  55017. /**
  55018. * Callback called when the task is successful
  55019. */
  55020. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55021. /**
  55022. * Creates a new ImageAssetTask
  55023. * @param name defines the name of the task
  55024. * @param url defines the location of the image to load
  55025. */
  55026. constructor(
  55027. /**
  55028. * Defines the name of the task
  55029. */
  55030. name: string,
  55031. /**
  55032. * Defines the location of the image to load
  55033. */
  55034. url: string);
  55035. /**
  55036. * Execute the current task
  55037. * @param scene defines the scene where you want your assets to be loaded
  55038. * @param onSuccess is a callback called when the task is successfully executed
  55039. * @param onError is a callback called if an error occurs
  55040. */
  55041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55042. }
  55043. /**
  55044. * Defines the interface used by texture loading tasks
  55045. */
  55046. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55047. /**
  55048. * Gets the loaded texture
  55049. */
  55050. texture: TEX;
  55051. }
  55052. /**
  55053. * Define a task used by AssetsManager to load 2D textures
  55054. */
  55055. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55056. /**
  55057. * Defines the name of the task
  55058. */
  55059. name: string;
  55060. /**
  55061. * Defines the location of the file to load
  55062. */
  55063. url: string;
  55064. /**
  55065. * Defines if mipmap should not be generated (default is false)
  55066. */
  55067. noMipmap?: boolean | undefined;
  55068. /**
  55069. * Defines if texture must be inverted on Y axis (default is false)
  55070. */
  55071. invertY?: boolean | undefined;
  55072. /**
  55073. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55074. */
  55075. samplingMode: number;
  55076. /**
  55077. * Gets the loaded texture
  55078. */
  55079. texture: Texture;
  55080. /**
  55081. * Callback called when the task is successful
  55082. */
  55083. onSuccess: (task: TextureAssetTask) => void;
  55084. /**
  55085. * Callback called when the task is successful
  55086. */
  55087. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55088. /**
  55089. * Creates a new TextureAssetTask object
  55090. * @param name defines the name of the task
  55091. * @param url defines the location of the file to load
  55092. * @param noMipmap defines if mipmap should not be generated (default is false)
  55093. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55094. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55095. */
  55096. constructor(
  55097. /**
  55098. * Defines the name of the task
  55099. */
  55100. name: string,
  55101. /**
  55102. * Defines the location of the file to load
  55103. */
  55104. url: string,
  55105. /**
  55106. * Defines if mipmap should not be generated (default is false)
  55107. */
  55108. noMipmap?: boolean | undefined,
  55109. /**
  55110. * Defines if texture must be inverted on Y axis (default is false)
  55111. */
  55112. invertY?: boolean | undefined,
  55113. /**
  55114. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55115. */
  55116. samplingMode?: number);
  55117. /**
  55118. * Execute the current task
  55119. * @param scene defines the scene where you want your assets to be loaded
  55120. * @param onSuccess is a callback called when the task is successfully executed
  55121. * @param onError is a callback called if an error occurs
  55122. */
  55123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55124. }
  55125. /**
  55126. * Define a task used by AssetsManager to load cube textures
  55127. */
  55128. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55129. /**
  55130. * Defines the name of the task
  55131. */
  55132. name: string;
  55133. /**
  55134. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55135. */
  55136. url: string;
  55137. /**
  55138. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55139. */
  55140. extensions?: string[] | undefined;
  55141. /**
  55142. * Defines if mipmaps should not be generated (default is false)
  55143. */
  55144. noMipmap?: boolean | undefined;
  55145. /**
  55146. * Defines the explicit list of files (undefined by default)
  55147. */
  55148. files?: string[] | undefined;
  55149. /**
  55150. * Gets the loaded texture
  55151. */
  55152. texture: CubeTexture;
  55153. /**
  55154. * Callback called when the task is successful
  55155. */
  55156. onSuccess: (task: CubeTextureAssetTask) => void;
  55157. /**
  55158. * Callback called when the task is successful
  55159. */
  55160. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55161. /**
  55162. * Creates a new CubeTextureAssetTask
  55163. * @param name defines the name of the task
  55164. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55165. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55166. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55167. * @param files defines the explicit list of files (undefined by default)
  55168. */
  55169. constructor(
  55170. /**
  55171. * Defines the name of the task
  55172. */
  55173. name: string,
  55174. /**
  55175. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55176. */
  55177. url: string,
  55178. /**
  55179. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55180. */
  55181. extensions?: string[] | undefined,
  55182. /**
  55183. * Defines if mipmaps should not be generated (default is false)
  55184. */
  55185. noMipmap?: boolean | undefined,
  55186. /**
  55187. * Defines the explicit list of files (undefined by default)
  55188. */
  55189. files?: string[] | undefined);
  55190. /**
  55191. * Execute the current task
  55192. * @param scene defines the scene where you want your assets to be loaded
  55193. * @param onSuccess is a callback called when the task is successfully executed
  55194. * @param onError is a callback called if an error occurs
  55195. */
  55196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55197. }
  55198. /**
  55199. * Define a task used by AssetsManager to load HDR cube textures
  55200. */
  55201. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55202. /**
  55203. * Defines the name of the task
  55204. */
  55205. name: string;
  55206. /**
  55207. * Defines the location of the file to load
  55208. */
  55209. url: string;
  55210. /**
  55211. * Defines the desired size (the more it increases the longer the generation will be)
  55212. */
  55213. size: number;
  55214. /**
  55215. * Defines if mipmaps should not be generated (default is false)
  55216. */
  55217. noMipmap: boolean;
  55218. /**
  55219. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55220. */
  55221. generateHarmonics: boolean;
  55222. /**
  55223. * 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)
  55224. */
  55225. gammaSpace: boolean;
  55226. /**
  55227. * Internal Use Only
  55228. */
  55229. reserved: boolean;
  55230. /**
  55231. * Gets the loaded texture
  55232. */
  55233. texture: HDRCubeTexture;
  55234. /**
  55235. * Callback called when the task is successful
  55236. */
  55237. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55238. /**
  55239. * Callback called when the task is successful
  55240. */
  55241. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55242. /**
  55243. * Creates a new HDRCubeTextureAssetTask object
  55244. * @param name defines the name of the task
  55245. * @param url defines the location of the file to load
  55246. * @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.
  55247. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55248. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55249. * @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)
  55250. * @param reserved Internal use only
  55251. */
  55252. constructor(
  55253. /**
  55254. * Defines the name of the task
  55255. */
  55256. name: string,
  55257. /**
  55258. * Defines the location of the file to load
  55259. */
  55260. url: string,
  55261. /**
  55262. * Defines the desired size (the more it increases the longer the generation will be)
  55263. */
  55264. size: number,
  55265. /**
  55266. * Defines if mipmaps should not be generated (default is false)
  55267. */
  55268. noMipmap?: boolean,
  55269. /**
  55270. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55271. */
  55272. generateHarmonics?: boolean,
  55273. /**
  55274. * 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)
  55275. */
  55276. gammaSpace?: boolean,
  55277. /**
  55278. * Internal Use Only
  55279. */
  55280. reserved?: boolean);
  55281. /**
  55282. * Execute the current task
  55283. * @param scene defines the scene where you want your assets to be loaded
  55284. * @param onSuccess is a callback called when the task is successfully executed
  55285. * @param onError is a callback called if an error occurs
  55286. */
  55287. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55288. }
  55289. /**
  55290. * This class can be used to easily import assets into a scene
  55291. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55292. */
  55293. export class AssetsManager {
  55294. private _scene;
  55295. private _isLoading;
  55296. protected _tasks: AbstractAssetTask[];
  55297. protected _waitingTasksCount: number;
  55298. protected _totalTasksCount: number;
  55299. /**
  55300. * Callback called when all tasks are processed
  55301. */
  55302. onFinish: (tasks: AbstractAssetTask[]) => void;
  55303. /**
  55304. * Callback called when a task is successful
  55305. */
  55306. onTaskSuccess: (task: AbstractAssetTask) => void;
  55307. /**
  55308. * Callback called when a task had an error
  55309. */
  55310. onTaskError: (task: AbstractAssetTask) => void;
  55311. /**
  55312. * Callback called when a task is done (whatever the result is)
  55313. */
  55314. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55315. /**
  55316. * Observable called when all tasks are processed
  55317. */
  55318. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55319. /**
  55320. * Observable called when a task had an error
  55321. */
  55322. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55323. /**
  55324. * Observable called when a task is successful
  55325. */
  55326. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55327. /**
  55328. * Observable called when a task is done (whatever the result is)
  55329. */
  55330. onProgressObservable: Observable<IAssetsProgressEvent>;
  55331. /**
  55332. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55333. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55334. */
  55335. useDefaultLoadingScreen: boolean;
  55336. /**
  55337. * Creates a new AssetsManager
  55338. * @param scene defines the scene to work on
  55339. */
  55340. constructor(scene: Scene);
  55341. /**
  55342. * Add a MeshAssetTask to the list of active tasks
  55343. * @param taskName defines the name of the new task
  55344. * @param meshesNames defines the name of meshes to load
  55345. * @param rootUrl defines the root url to use to locate files
  55346. * @param sceneFilename defines the filename of the scene file
  55347. * @returns a new MeshAssetTask object
  55348. */
  55349. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55350. /**
  55351. * Add a TextFileAssetTask to the list of active tasks
  55352. * @param taskName defines the name of the new task
  55353. * @param url defines the url of the file to load
  55354. * @returns a new TextFileAssetTask object
  55355. */
  55356. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55357. /**
  55358. * Add a BinaryFileAssetTask to the list of active tasks
  55359. * @param taskName defines the name of the new task
  55360. * @param url defines the url of the file to load
  55361. * @returns a new BinaryFileAssetTask object
  55362. */
  55363. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55364. /**
  55365. * Add a ImageAssetTask to the list of active tasks
  55366. * @param taskName defines the name of the new task
  55367. * @param url defines the url of the file to load
  55368. * @returns a new ImageAssetTask object
  55369. */
  55370. addImageTask(taskName: string, url: string): ImageAssetTask;
  55371. /**
  55372. * Add a TextureAssetTask to the list of active tasks
  55373. * @param taskName defines the name of the new task
  55374. * @param url defines the url of the file to load
  55375. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55376. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55377. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55378. * @returns a new TextureAssetTask object
  55379. */
  55380. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55381. /**
  55382. * Add a CubeTextureAssetTask to the list of active tasks
  55383. * @param taskName defines the name of the new task
  55384. * @param url defines the url of the file to load
  55385. * @param extensions defines the extension to use to load the cube map (can be null)
  55386. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55387. * @param files defines the list of files to load (can be null)
  55388. * @returns a new CubeTextureAssetTask object
  55389. */
  55390. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55391. /**
  55392. *
  55393. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55394. * @param taskName defines the name of the new task
  55395. * @param url defines the url of the file to load
  55396. * @param size defines the size you want for the cubemap (can be null)
  55397. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55398. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55399. * @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)
  55400. * @param reserved Internal use only
  55401. * @returns a new HDRCubeTextureAssetTask object
  55402. */
  55403. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55404. /**
  55405. * Remove a task from the assets manager.
  55406. * @param task the task to remove
  55407. */
  55408. removeTask(task: AbstractAssetTask): void;
  55409. private _decreaseWaitingTasksCount;
  55410. private _runTask;
  55411. /**
  55412. * Reset the AssetsManager and remove all tasks
  55413. * @return the current instance of the AssetsManager
  55414. */
  55415. reset(): AssetsManager;
  55416. /**
  55417. * Start the loading process
  55418. * @return the current instance of the AssetsManager
  55419. */
  55420. load(): AssetsManager;
  55421. }
  55422. }
  55423. declare module "babylonjs/Misc/deferred" {
  55424. /**
  55425. * Wrapper class for promise with external resolve and reject.
  55426. */
  55427. export class Deferred<T> {
  55428. /**
  55429. * The promise associated with this deferred object.
  55430. */
  55431. readonly promise: Promise<T>;
  55432. private _resolve;
  55433. private _reject;
  55434. /**
  55435. * The resolve method of the promise associated with this deferred object.
  55436. */
  55437. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55438. /**
  55439. * The reject method of the promise associated with this deferred object.
  55440. */
  55441. readonly reject: (reason?: any) => void;
  55442. /**
  55443. * Constructor for this deferred object.
  55444. */
  55445. constructor();
  55446. }
  55447. }
  55448. declare module "babylonjs/Misc/filesInput" {
  55449. import { Engine } from "babylonjs/Engines/engine";
  55450. import { Scene } from "babylonjs/scene";
  55451. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55452. /**
  55453. * Class used to help managing file picking and drag'n'drop
  55454. */
  55455. export class FilesInput {
  55456. /**
  55457. * List of files ready to be loaded
  55458. */
  55459. static readonly FilesToLoad: {
  55460. [key: string]: File;
  55461. };
  55462. /**
  55463. * Callback called when a file is processed
  55464. */
  55465. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55466. private _engine;
  55467. private _currentScene;
  55468. private _sceneLoadedCallback;
  55469. private _progressCallback;
  55470. private _additionalRenderLoopLogicCallback;
  55471. private _textureLoadingCallback;
  55472. private _startingProcessingFilesCallback;
  55473. private _onReloadCallback;
  55474. private _errorCallback;
  55475. private _elementToMonitor;
  55476. private _sceneFileToLoad;
  55477. private _filesToLoad;
  55478. /**
  55479. * Creates a new FilesInput
  55480. * @param engine defines the rendering engine
  55481. * @param scene defines the hosting scene
  55482. * @param sceneLoadedCallback callback called when scene is loaded
  55483. * @param progressCallback callback called to track progress
  55484. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55485. * @param textureLoadingCallback callback called when a texture is loading
  55486. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55487. * @param onReloadCallback callback called when a reload is requested
  55488. * @param errorCallback callback call if an error occurs
  55489. */
  55490. 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);
  55491. private _dragEnterHandler;
  55492. private _dragOverHandler;
  55493. private _dropHandler;
  55494. /**
  55495. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55496. * @param elementToMonitor defines the DOM element to track
  55497. */
  55498. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55499. /**
  55500. * Release all associated resources
  55501. */
  55502. dispose(): void;
  55503. private renderFunction;
  55504. private drag;
  55505. private drop;
  55506. private _traverseFolder;
  55507. private _processFiles;
  55508. /**
  55509. * Load files from a drop event
  55510. * @param event defines the drop event to use as source
  55511. */
  55512. loadFiles(event: any): void;
  55513. private _processReload;
  55514. /**
  55515. * Reload the current scene from the loaded files
  55516. */
  55517. reload(): void;
  55518. }
  55519. }
  55520. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55521. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55522. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55523. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55524. }
  55525. declare module "babylonjs/Misc/sceneOptimizer" {
  55526. import { Scene, IDisposable } from "babylonjs/scene";
  55527. import { Observable } from "babylonjs/Misc/observable";
  55528. /**
  55529. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55531. */
  55532. export class SceneOptimization {
  55533. /**
  55534. * Defines the priority of this optimization (0 by default which means first in the list)
  55535. */
  55536. priority: number;
  55537. /**
  55538. * Gets a string describing the action executed by the current optimization
  55539. * @returns description string
  55540. */
  55541. getDescription(): string;
  55542. /**
  55543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55544. * @param scene defines the current scene where to apply this optimization
  55545. * @param optimizer defines the current optimizer
  55546. * @returns true if everything that can be done was applied
  55547. */
  55548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55549. /**
  55550. * Creates the SceneOptimization object
  55551. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55552. * @param desc defines the description associated with the optimization
  55553. */
  55554. constructor(
  55555. /**
  55556. * Defines the priority of this optimization (0 by default which means first in the list)
  55557. */
  55558. priority?: number);
  55559. }
  55560. /**
  55561. * Defines an optimization used to reduce the size of render target textures
  55562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55563. */
  55564. export class TextureOptimization extends SceneOptimization {
  55565. /**
  55566. * Defines the priority of this optimization (0 by default which means first in the list)
  55567. */
  55568. priority: number;
  55569. /**
  55570. * 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
  55571. */
  55572. maximumSize: number;
  55573. /**
  55574. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55575. */
  55576. step: number;
  55577. /**
  55578. * Gets a string describing the action executed by the current optimization
  55579. * @returns description string
  55580. */
  55581. getDescription(): string;
  55582. /**
  55583. * Creates the TextureOptimization object
  55584. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55585. * @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
  55586. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55587. */
  55588. constructor(
  55589. /**
  55590. * Defines the priority of this optimization (0 by default which means first in the list)
  55591. */
  55592. priority?: number,
  55593. /**
  55594. * 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
  55595. */
  55596. maximumSize?: number,
  55597. /**
  55598. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55599. */
  55600. step?: number);
  55601. /**
  55602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55603. * @param scene defines the current scene where to apply this optimization
  55604. * @param optimizer defines the current optimizer
  55605. * @returns true if everything that can be done was applied
  55606. */
  55607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55608. }
  55609. /**
  55610. * Defines an optimization used to increase or decrease the rendering resolution
  55611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55612. */
  55613. export class HardwareScalingOptimization extends SceneOptimization {
  55614. /**
  55615. * Defines the priority of this optimization (0 by default which means first in the list)
  55616. */
  55617. priority: number;
  55618. /**
  55619. * Defines the maximum scale to use (2 by default)
  55620. */
  55621. maximumScale: number;
  55622. /**
  55623. * Defines the step to use between two passes (0.5 by default)
  55624. */
  55625. step: number;
  55626. private _currentScale;
  55627. private _directionOffset;
  55628. /**
  55629. * Gets a string describing the action executed by the current optimization
  55630. * @return description string
  55631. */
  55632. getDescription(): string;
  55633. /**
  55634. * Creates the HardwareScalingOptimization object
  55635. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55636. * @param maximumScale defines the maximum scale to use (2 by default)
  55637. * @param step defines the step to use between two passes (0.5 by default)
  55638. */
  55639. constructor(
  55640. /**
  55641. * Defines the priority of this optimization (0 by default which means first in the list)
  55642. */
  55643. priority?: number,
  55644. /**
  55645. * Defines the maximum scale to use (2 by default)
  55646. */
  55647. maximumScale?: number,
  55648. /**
  55649. * Defines the step to use between two passes (0.5 by default)
  55650. */
  55651. step?: number);
  55652. /**
  55653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55654. * @param scene defines the current scene where to apply this optimization
  55655. * @param optimizer defines the current optimizer
  55656. * @returns true if everything that can be done was applied
  55657. */
  55658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55659. }
  55660. /**
  55661. * Defines an optimization used to remove shadows
  55662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55663. */
  55664. export class ShadowsOptimization extends SceneOptimization {
  55665. /**
  55666. * Gets a string describing the action executed by the current optimization
  55667. * @return description string
  55668. */
  55669. getDescription(): string;
  55670. /**
  55671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55672. * @param scene defines the current scene where to apply this optimization
  55673. * @param optimizer defines the current optimizer
  55674. * @returns true if everything that can be done was applied
  55675. */
  55676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55677. }
  55678. /**
  55679. * Defines an optimization used to turn post-processes off
  55680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55681. */
  55682. export class PostProcessesOptimization extends SceneOptimization {
  55683. /**
  55684. * Gets a string describing the action executed by the current optimization
  55685. * @return description string
  55686. */
  55687. getDescription(): string;
  55688. /**
  55689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55690. * @param scene defines the current scene where to apply this optimization
  55691. * @param optimizer defines the current optimizer
  55692. * @returns true if everything that can be done was applied
  55693. */
  55694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55695. }
  55696. /**
  55697. * Defines an optimization used to turn lens flares off
  55698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55699. */
  55700. export class LensFlaresOptimization extends SceneOptimization {
  55701. /**
  55702. * Gets a string describing the action executed by the current optimization
  55703. * @return description string
  55704. */
  55705. getDescription(): string;
  55706. /**
  55707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55708. * @param scene defines the current scene where to apply this optimization
  55709. * @param optimizer defines the current optimizer
  55710. * @returns true if everything that can be done was applied
  55711. */
  55712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55713. }
  55714. /**
  55715. * Defines an optimization based on user defined callback.
  55716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55717. */
  55718. export class CustomOptimization extends SceneOptimization {
  55719. /**
  55720. * Callback called to apply the custom optimization.
  55721. */
  55722. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55723. /**
  55724. * Callback called to get custom description
  55725. */
  55726. onGetDescription: () => string;
  55727. /**
  55728. * Gets a string describing the action executed by the current optimization
  55729. * @returns description string
  55730. */
  55731. getDescription(): string;
  55732. /**
  55733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55734. * @param scene defines the current scene where to apply this optimization
  55735. * @param optimizer defines the current optimizer
  55736. * @returns true if everything that can be done was applied
  55737. */
  55738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55739. }
  55740. /**
  55741. * Defines an optimization used to turn particles off
  55742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55743. */
  55744. export class ParticlesOptimization extends SceneOptimization {
  55745. /**
  55746. * Gets a string describing the action executed by the current optimization
  55747. * @return description string
  55748. */
  55749. getDescription(): string;
  55750. /**
  55751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55752. * @param scene defines the current scene where to apply this optimization
  55753. * @param optimizer defines the current optimizer
  55754. * @returns true if everything that can be done was applied
  55755. */
  55756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55757. }
  55758. /**
  55759. * Defines an optimization used to turn render targets off
  55760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55761. */
  55762. export class RenderTargetsOptimization extends SceneOptimization {
  55763. /**
  55764. * Gets a string describing the action executed by the current optimization
  55765. * @return description string
  55766. */
  55767. getDescription(): string;
  55768. /**
  55769. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55770. * @param scene defines the current scene where to apply this optimization
  55771. * @param optimizer defines the current optimizer
  55772. * @returns true if everything that can be done was applied
  55773. */
  55774. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55775. }
  55776. /**
  55777. * Defines an optimization used to merge meshes with compatible materials
  55778. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55779. */
  55780. export class MergeMeshesOptimization extends SceneOptimization {
  55781. private static _UpdateSelectionTree;
  55782. /**
  55783. * Gets or sets a boolean which defines if optimization octree has to be updated
  55784. */
  55785. /**
  55786. * Gets or sets a boolean which defines if optimization octree has to be updated
  55787. */
  55788. static UpdateSelectionTree: boolean;
  55789. /**
  55790. * Gets a string describing the action executed by the current optimization
  55791. * @return description string
  55792. */
  55793. getDescription(): string;
  55794. private _canBeMerged;
  55795. /**
  55796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55797. * @param scene defines the current scene where to apply this optimization
  55798. * @param optimizer defines the current optimizer
  55799. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55800. * @returns true if everything that can be done was applied
  55801. */
  55802. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55803. }
  55804. /**
  55805. * Defines a list of options used by SceneOptimizer
  55806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55807. */
  55808. export class SceneOptimizerOptions {
  55809. /**
  55810. * Defines the target frame rate to reach (60 by default)
  55811. */
  55812. targetFrameRate: number;
  55813. /**
  55814. * Defines the interval between two checkes (2000ms by default)
  55815. */
  55816. trackerDuration: number;
  55817. /**
  55818. * Gets the list of optimizations to apply
  55819. */
  55820. optimizations: SceneOptimization[];
  55821. /**
  55822. * Creates a new list of options used by SceneOptimizer
  55823. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55824. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55825. */
  55826. constructor(
  55827. /**
  55828. * Defines the target frame rate to reach (60 by default)
  55829. */
  55830. targetFrameRate?: number,
  55831. /**
  55832. * Defines the interval between two checkes (2000ms by default)
  55833. */
  55834. trackerDuration?: number);
  55835. /**
  55836. * Add a new optimization
  55837. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55838. * @returns the current SceneOptimizerOptions
  55839. */
  55840. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55841. /**
  55842. * Add a new custom optimization
  55843. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55844. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55845. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55846. * @returns the current SceneOptimizerOptions
  55847. */
  55848. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55849. /**
  55850. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55851. * @param targetFrameRate defines the target frame rate (60 by default)
  55852. * @returns a SceneOptimizerOptions object
  55853. */
  55854. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55855. /**
  55856. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55857. * @param targetFrameRate defines the target frame rate (60 by default)
  55858. * @returns a SceneOptimizerOptions object
  55859. */
  55860. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55861. /**
  55862. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55863. * @param targetFrameRate defines the target frame rate (60 by default)
  55864. * @returns a SceneOptimizerOptions object
  55865. */
  55866. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55867. }
  55868. /**
  55869. * Class used to run optimizations in order to reach a target frame rate
  55870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55871. */
  55872. export class SceneOptimizer implements IDisposable {
  55873. private _isRunning;
  55874. private _options;
  55875. private _scene;
  55876. private _currentPriorityLevel;
  55877. private _targetFrameRate;
  55878. private _trackerDuration;
  55879. private _currentFrameRate;
  55880. private _sceneDisposeObserver;
  55881. private _improvementMode;
  55882. /**
  55883. * Defines an observable called when the optimizer reaches the target frame rate
  55884. */
  55885. onSuccessObservable: Observable<SceneOptimizer>;
  55886. /**
  55887. * Defines an observable called when the optimizer enables an optimization
  55888. */
  55889. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55890. /**
  55891. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55892. */
  55893. onFailureObservable: Observable<SceneOptimizer>;
  55894. /**
  55895. * Gets a boolean indicating if the optimizer is in improvement mode
  55896. */
  55897. readonly isInImprovementMode: boolean;
  55898. /**
  55899. * Gets the current priority level (0 at start)
  55900. */
  55901. readonly currentPriorityLevel: number;
  55902. /**
  55903. * Gets the current frame rate checked by the SceneOptimizer
  55904. */
  55905. readonly currentFrameRate: number;
  55906. /**
  55907. * Gets or sets the current target frame rate (60 by default)
  55908. */
  55909. /**
  55910. * Gets or sets the current target frame rate (60 by default)
  55911. */
  55912. targetFrameRate: number;
  55913. /**
  55914. * Gets or sets the current interval between two checks (every 2000ms by default)
  55915. */
  55916. /**
  55917. * Gets or sets the current interval between two checks (every 2000ms by default)
  55918. */
  55919. trackerDuration: number;
  55920. /**
  55921. * Gets the list of active optimizations
  55922. */
  55923. readonly optimizations: SceneOptimization[];
  55924. /**
  55925. * Creates a new SceneOptimizer
  55926. * @param scene defines the scene to work on
  55927. * @param options defines the options to use with the SceneOptimizer
  55928. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55929. * @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)
  55930. */
  55931. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55932. /**
  55933. * Stops the current optimizer
  55934. */
  55935. stop(): void;
  55936. /**
  55937. * Reset the optimizer to initial step (current priority level = 0)
  55938. */
  55939. reset(): void;
  55940. /**
  55941. * Start the optimizer. By default it will try to reach a specific framerate
  55942. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55943. */
  55944. start(): void;
  55945. private _checkCurrentState;
  55946. /**
  55947. * Release all resources
  55948. */
  55949. dispose(): void;
  55950. /**
  55951. * Helper function to create a SceneOptimizer with one single line of code
  55952. * @param scene defines the scene to work on
  55953. * @param options defines the options to use with the SceneOptimizer
  55954. * @param onSuccess defines a callback to call on success
  55955. * @param onFailure defines a callback to call on failure
  55956. * @returns the new SceneOptimizer object
  55957. */
  55958. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55959. }
  55960. }
  55961. declare module "babylonjs/Misc/sceneSerializer" {
  55962. import { Scene } from "babylonjs/scene";
  55963. /**
  55964. * Class used to serialize a scene into a string
  55965. */
  55966. export class SceneSerializer {
  55967. /**
  55968. * Clear cache used by a previous serialization
  55969. */
  55970. static ClearCache(): void;
  55971. /**
  55972. * Serialize a scene into a JSON compatible object
  55973. * @param scene defines the scene to serialize
  55974. * @returns a JSON compatible object
  55975. */
  55976. static Serialize(scene: Scene): any;
  55977. /**
  55978. * Serialize a mesh into a JSON compatible object
  55979. * @param toSerialize defines the mesh to serialize
  55980. * @param withParents defines if parents must be serialized as well
  55981. * @param withChildren defines if children must be serialized as well
  55982. * @returns a JSON compatible object
  55983. */
  55984. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55985. }
  55986. }
  55987. declare module "babylonjs/Misc/videoRecorder" {
  55988. import { Nullable } from "babylonjs/types";
  55989. import { Engine } from "babylonjs/Engines/engine";
  55990. /**
  55991. * This represents the different options avilable for the video capture.
  55992. */
  55993. export interface VideoRecorderOptions {
  55994. /** Defines the mime type of the video */
  55995. mimeType: string;
  55996. /** Defines the video the video should be recorded at */
  55997. fps: number;
  55998. /** Defines the chunk size for the recording data */
  55999. recordChunckSize: number;
  56000. }
  56001. /**
  56002. * This can helps recording videos from BabylonJS.
  56003. * This is based on the available WebRTC functionalities of the browser.
  56004. *
  56005. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56006. */
  56007. export class VideoRecorder {
  56008. private static readonly _defaultOptions;
  56009. /**
  56010. * Returns wehther or not the VideoRecorder is available in your browser.
  56011. * @param engine Defines the Babylon Engine to check the support for
  56012. * @returns true if supported otherwise false
  56013. */
  56014. static IsSupported(engine: Engine): boolean;
  56015. private readonly _options;
  56016. private _canvas;
  56017. private _mediaRecorder;
  56018. private _recordedChunks;
  56019. private _fileName;
  56020. private _resolve;
  56021. private _reject;
  56022. /**
  56023. * True wether a recording is already in progress.
  56024. */
  56025. readonly isRecording: boolean;
  56026. /**
  56027. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56028. * a video file.
  56029. * @param engine Defines the BabylonJS Engine you wish to record
  56030. * @param options Defines options that can be used to customized the capture
  56031. */
  56032. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56033. /**
  56034. * Stops the current recording before the default capture timeout passed in the startRecording
  56035. * functions.
  56036. */
  56037. stopRecording(): void;
  56038. /**
  56039. * Starts recording the canvas for a max duration specified in parameters.
  56040. * @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.
  56041. * @param maxDuration Defines the maximum recording time in seconds.
  56042. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56043. * @return a promise callback at the end of the recording with the video data in Blob.
  56044. */
  56045. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56046. /**
  56047. * Releases internal resources used during the recording.
  56048. */
  56049. dispose(): void;
  56050. private _handleDataAvailable;
  56051. private _handleError;
  56052. private _handleStop;
  56053. }
  56054. }
  56055. declare module "babylonjs/Misc/workerPool" {
  56056. import { IDisposable } from "babylonjs/scene";
  56057. /**
  56058. * Helper class to push actions to a pool of workers.
  56059. */
  56060. export class WorkerPool implements IDisposable {
  56061. private _workerInfos;
  56062. private _pendingActions;
  56063. /**
  56064. * Constructor
  56065. * @param workers Array of workers to use for actions
  56066. */
  56067. constructor(workers: Array<Worker>);
  56068. /**
  56069. * Terminates all workers and clears any pending actions.
  56070. */
  56071. dispose(): void;
  56072. /**
  56073. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56074. * pended until a worker has completed its action.
  56075. * @param action The action to perform. Call onComplete when the action is complete.
  56076. */
  56077. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56078. private _execute;
  56079. }
  56080. }
  56081. declare module "babylonjs/Misc/screenshotTools" {
  56082. import { Camera } from "babylonjs/Cameras/camera";
  56083. import { Engine } from "babylonjs/Engines/engine";
  56084. /**
  56085. * Class containing a set of static utilities functions for screenshots
  56086. */
  56087. export class ScreenshotTools {
  56088. /**
  56089. * Captures a screenshot of the current rendering
  56090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56091. * @param engine defines the rendering engine
  56092. * @param camera defines the source camera
  56093. * @param size This parameter can be set to a single number or to an object with the
  56094. * following (optional) properties: precision, width, height. If a single number is passed,
  56095. * it will be used for both width and height. If an object is passed, the screenshot size
  56096. * will be derived from the parameters. The precision property is a multiplier allowing
  56097. * rendering at a higher or lower resolution
  56098. * @param successCallback defines the callback receives a single parameter which contains the
  56099. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56100. * src parameter of an <img> to display it
  56101. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56102. * Check your browser for supported MIME types
  56103. */
  56104. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56105. /**
  56106. * Generates an image screenshot from the specified camera.
  56107. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56108. * @param engine The engine to use for rendering
  56109. * @param camera The camera to use for rendering
  56110. * @param size This parameter can be set to a single number or to an object with the
  56111. * following (optional) properties: precision, width, height. If a single number is passed,
  56112. * it will be used for both width and height. If an object is passed, the screenshot size
  56113. * will be derived from the parameters. The precision property is a multiplier allowing
  56114. * rendering at a higher or lower resolution
  56115. * @param successCallback The callback receives a single parameter which contains the
  56116. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56117. * src parameter of an <img> to display it
  56118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56119. * Check your browser for supported MIME types
  56120. * @param samples Texture samples (default: 1)
  56121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56122. * @param fileName A name for for the downloaded file.
  56123. */
  56124. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56125. }
  56126. }
  56127. declare module "babylonjs/Misc/index" {
  56128. export * from "babylonjs/Misc/andOrNotEvaluator";
  56129. export * from "babylonjs/Misc/assetsManager";
  56130. export * from "babylonjs/Misc/dds";
  56131. export * from "babylonjs/Misc/decorators";
  56132. export * from "babylonjs/Misc/deferred";
  56133. export * from "babylonjs/Misc/environmentTextureTools";
  56134. export * from "babylonjs/Misc/filesInput";
  56135. export * from "babylonjs/Misc/HighDynamicRange/index";
  56136. export * from "babylonjs/Misc/khronosTextureContainer";
  56137. export * from "babylonjs/Misc/observable";
  56138. export * from "babylonjs/Misc/performanceMonitor";
  56139. export * from "babylonjs/Misc/promise";
  56140. export * from "babylonjs/Misc/sceneOptimizer";
  56141. export * from "babylonjs/Misc/sceneSerializer";
  56142. export * from "babylonjs/Misc/smartArray";
  56143. export * from "babylonjs/Misc/stringDictionary";
  56144. export * from "babylonjs/Misc/tags";
  56145. export * from "babylonjs/Misc/textureTools";
  56146. export * from "babylonjs/Misc/tga";
  56147. export * from "babylonjs/Misc/tools";
  56148. export * from "babylonjs/Misc/videoRecorder";
  56149. export * from "babylonjs/Misc/virtualJoystick";
  56150. export * from "babylonjs/Misc/workerPool";
  56151. export * from "babylonjs/Misc/logger";
  56152. export * from "babylonjs/Misc/typeStore";
  56153. export * from "babylonjs/Misc/filesInputStore";
  56154. export * from "babylonjs/Misc/deepCopier";
  56155. export * from "babylonjs/Misc/pivotTools";
  56156. export * from "babylonjs/Misc/precisionDate";
  56157. export * from "babylonjs/Misc/screenshotTools";
  56158. export * from "babylonjs/Misc/typeStore";
  56159. }
  56160. declare module "babylonjs/index" {
  56161. export * from "babylonjs/abstractScene";
  56162. export * from "babylonjs/Actions/index";
  56163. export * from "babylonjs/Animations/index";
  56164. export * from "babylonjs/assetContainer";
  56165. export * from "babylonjs/Audio/index";
  56166. export * from "babylonjs/Behaviors/index";
  56167. export * from "babylonjs/Bones/index";
  56168. export * from "babylonjs/Cameras/index";
  56169. export * from "babylonjs/Collisions/index";
  56170. export * from "babylonjs/Culling/index";
  56171. export * from "babylonjs/Debug/index";
  56172. export * from "babylonjs/Engines/index";
  56173. export * from "babylonjs/Events/index";
  56174. export * from "babylonjs/Gamepads/index";
  56175. export * from "babylonjs/Gizmos/index";
  56176. export * from "babylonjs/Helpers/index";
  56177. export * from "babylonjs/Instrumentation/index";
  56178. export * from "babylonjs/Layers/index";
  56179. export * from "babylonjs/LensFlares/index";
  56180. export * from "babylonjs/Lights/index";
  56181. export * from "babylonjs/Loading/index";
  56182. export * from "babylonjs/Materials/index";
  56183. export * from "babylonjs/Maths/index";
  56184. export * from "babylonjs/Meshes/index";
  56185. export * from "babylonjs/Morph/index";
  56186. export * from "babylonjs/node";
  56187. export * from "babylonjs/Offline/index";
  56188. export * from "babylonjs/Particles/index";
  56189. export * from "babylonjs/Physics/index";
  56190. export * from "babylonjs/PostProcesses/index";
  56191. export * from "babylonjs/Probes/index";
  56192. export * from "babylonjs/Rendering/index";
  56193. export * from "babylonjs/scene";
  56194. export * from "babylonjs/sceneComponent";
  56195. export * from "babylonjs/Sprites/index";
  56196. export * from "babylonjs/States/index";
  56197. export * from "babylonjs/Misc/index";
  56198. export * from "babylonjs/types";
  56199. }
  56200. declare module "babylonjs/Animations/pathCursor" {
  56201. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56202. /**
  56203. * A cursor which tracks a point on a path
  56204. */
  56205. export class PathCursor {
  56206. private path;
  56207. /**
  56208. * Stores path cursor callbacks for when an onchange event is triggered
  56209. */
  56210. private _onchange;
  56211. /**
  56212. * The value of the path cursor
  56213. */
  56214. value: number;
  56215. /**
  56216. * The animation array of the path cursor
  56217. */
  56218. animations: Animation[];
  56219. /**
  56220. * Initializes the path cursor
  56221. * @param path The path to track
  56222. */
  56223. constructor(path: Path2);
  56224. /**
  56225. * Gets the cursor point on the path
  56226. * @returns A point on the path cursor at the cursor location
  56227. */
  56228. getPoint(): Vector3;
  56229. /**
  56230. * Moves the cursor ahead by the step amount
  56231. * @param step The amount to move the cursor forward
  56232. * @returns This path cursor
  56233. */
  56234. moveAhead(step?: number): PathCursor;
  56235. /**
  56236. * Moves the cursor behind by the step amount
  56237. * @param step The amount to move the cursor back
  56238. * @returns This path cursor
  56239. */
  56240. moveBack(step?: number): PathCursor;
  56241. /**
  56242. * Moves the cursor by the step amount
  56243. * If the step amount is greater than one, an exception is thrown
  56244. * @param step The amount to move the cursor
  56245. * @returns This path cursor
  56246. */
  56247. move(step: number): PathCursor;
  56248. /**
  56249. * Ensures that the value is limited between zero and one
  56250. * @returns This path cursor
  56251. */
  56252. private ensureLimits;
  56253. /**
  56254. * Runs onchange callbacks on change (used by the animation engine)
  56255. * @returns This path cursor
  56256. */
  56257. private raiseOnChange;
  56258. /**
  56259. * Executes a function on change
  56260. * @param f A path cursor onchange callback
  56261. * @returns This path cursor
  56262. */
  56263. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56264. }
  56265. }
  56266. declare module "babylonjs/Legacy/legacy" {
  56267. export * from "babylonjs/index";
  56268. }
  56269. declare module "babylonjs/Shaders/blur.fragment" {
  56270. /** @hidden */
  56271. export var blurPixelShader: {
  56272. name: string;
  56273. shader: string;
  56274. };
  56275. }
  56276. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56277. /** @hidden */
  56278. export var bones300Declaration: {
  56279. name: string;
  56280. shader: string;
  56281. };
  56282. }
  56283. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56284. /** @hidden */
  56285. export var instances300Declaration: {
  56286. name: string;
  56287. shader: string;
  56288. };
  56289. }
  56290. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56291. /** @hidden */
  56292. export var pointCloudVertexDeclaration: {
  56293. name: string;
  56294. shader: string;
  56295. };
  56296. }
  56297. // Mixins
  56298. interface Window {
  56299. mozIndexedDB: IDBFactory;
  56300. webkitIndexedDB: IDBFactory;
  56301. msIndexedDB: IDBFactory;
  56302. webkitURL: typeof URL;
  56303. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56304. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56305. WebGLRenderingContext: WebGLRenderingContext;
  56306. MSGesture: MSGesture;
  56307. CANNON: any;
  56308. AudioContext: AudioContext;
  56309. webkitAudioContext: AudioContext;
  56310. PointerEvent: any;
  56311. Math: Math;
  56312. Uint8Array: Uint8ArrayConstructor;
  56313. Float32Array: Float32ArrayConstructor;
  56314. mozURL: typeof URL;
  56315. msURL: typeof URL;
  56316. VRFrameData: any; // WebVR, from specs 1.1
  56317. DracoDecoderModule: any;
  56318. setImmediate(handler: (...args: any[]) => void): number;
  56319. }
  56320. interface Document {
  56321. mozCancelFullScreen(): void;
  56322. msCancelFullScreen(): void;
  56323. webkitCancelFullScreen(): void;
  56324. requestPointerLock(): void;
  56325. exitPointerLock(): void;
  56326. mozFullScreen: boolean;
  56327. msIsFullScreen: boolean;
  56328. readonly webkitIsFullScreen: boolean;
  56329. readonly pointerLockElement: Element;
  56330. mozPointerLockElement: HTMLElement;
  56331. msPointerLockElement: HTMLElement;
  56332. webkitPointerLockElement: HTMLElement;
  56333. }
  56334. interface HTMLCanvasElement {
  56335. requestPointerLock(): void;
  56336. msRequestPointerLock?(): void;
  56337. mozRequestPointerLock?(): void;
  56338. webkitRequestPointerLock?(): void;
  56339. /** Track wether a record is in progress */
  56340. isRecording: boolean;
  56341. /** Capture Stream method defined by some browsers */
  56342. captureStream(fps?: number): MediaStream;
  56343. }
  56344. interface CanvasRenderingContext2D {
  56345. msImageSmoothingEnabled: boolean;
  56346. }
  56347. interface MouseEvent {
  56348. mozMovementX: number;
  56349. mozMovementY: number;
  56350. webkitMovementX: number;
  56351. webkitMovementY: number;
  56352. msMovementX: number;
  56353. msMovementY: number;
  56354. }
  56355. interface Navigator {
  56356. mozGetVRDevices: (any: any) => any;
  56357. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56358. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56359. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56360. webkitGetGamepads(): Gamepad[];
  56361. msGetGamepads(): Gamepad[];
  56362. webkitGamepads(): Gamepad[];
  56363. }
  56364. interface HTMLVideoElement {
  56365. mozSrcObject: any;
  56366. }
  56367. interface Math {
  56368. fround(x: number): number;
  56369. imul(a: number, b: number): number;
  56370. }
  56371. interface WebGLProgram {
  56372. context?: WebGLRenderingContext;
  56373. vertexShader?: WebGLShader;
  56374. fragmentShader?: WebGLShader;
  56375. isParallelCompiled: boolean;
  56376. onCompiled?: () => void;
  56377. }
  56378. interface WebGLRenderingContext {
  56379. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56380. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56381. vertexAttribDivisor(index: number, divisor: number): void;
  56382. createVertexArray(): any;
  56383. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56384. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56385. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56386. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56387. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56388. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56389. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56390. // Queries
  56391. createQuery(): WebGLQuery;
  56392. deleteQuery(query: WebGLQuery): void;
  56393. beginQuery(target: number, query: WebGLQuery): void;
  56394. endQuery(target: number): void;
  56395. getQueryParameter(query: WebGLQuery, pname: number): any;
  56396. getQuery(target: number, pname: number): any;
  56397. MAX_SAMPLES: number;
  56398. RGBA8: number;
  56399. READ_FRAMEBUFFER: number;
  56400. DRAW_FRAMEBUFFER: number;
  56401. UNIFORM_BUFFER: number;
  56402. HALF_FLOAT_OES: number;
  56403. RGBA16F: number;
  56404. RGBA32F: number;
  56405. R32F: number;
  56406. RG32F: number;
  56407. RGB32F: number;
  56408. R16F: number;
  56409. RG16F: number;
  56410. RGB16F: number;
  56411. RED: number;
  56412. RG: number;
  56413. R8: number;
  56414. RG8: number;
  56415. UNSIGNED_INT_24_8: number;
  56416. DEPTH24_STENCIL8: number;
  56417. /* Multiple Render Targets */
  56418. drawBuffers(buffers: number[]): void;
  56419. readBuffer(src: number): void;
  56420. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56421. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56422. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56423. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56424. // Occlusion Query
  56425. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56426. ANY_SAMPLES_PASSED: number;
  56427. QUERY_RESULT_AVAILABLE: number;
  56428. QUERY_RESULT: number;
  56429. }
  56430. interface WebGLBuffer {
  56431. references: number;
  56432. capacity: number;
  56433. is32Bits: boolean;
  56434. }
  56435. interface WebGLProgram {
  56436. transformFeedback?: WebGLTransformFeedback | null;
  56437. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56438. }
  56439. interface EXT_disjoint_timer_query {
  56440. QUERY_COUNTER_BITS_EXT: number;
  56441. TIME_ELAPSED_EXT: number;
  56442. TIMESTAMP_EXT: number;
  56443. GPU_DISJOINT_EXT: number;
  56444. QUERY_RESULT_EXT: number;
  56445. QUERY_RESULT_AVAILABLE_EXT: number;
  56446. queryCounterEXT(query: WebGLQuery, target: number): void;
  56447. createQueryEXT(): WebGLQuery;
  56448. beginQueryEXT(target: number, query: WebGLQuery): void;
  56449. endQueryEXT(target: number): void;
  56450. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56451. deleteQueryEXT(query: WebGLQuery): void;
  56452. }
  56453. interface WebGLUniformLocation {
  56454. _currentState: any;
  56455. }
  56456. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56457. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56458. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56459. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56460. interface WebGLRenderingContext {
  56461. readonly RASTERIZER_DISCARD: number;
  56462. readonly DEPTH_COMPONENT24: number;
  56463. readonly TEXTURE_3D: number;
  56464. readonly TEXTURE_2D_ARRAY: number;
  56465. readonly TEXTURE_COMPARE_FUNC: number;
  56466. readonly TEXTURE_COMPARE_MODE: number;
  56467. readonly COMPARE_REF_TO_TEXTURE: number;
  56468. readonly TEXTURE_WRAP_R: number;
  56469. readonly HALF_FLOAT: number;
  56470. readonly RGB8: number;
  56471. readonly RED_INTEGER: number;
  56472. readonly RG_INTEGER: number;
  56473. readonly RGB_INTEGER: number;
  56474. readonly RGBA_INTEGER: number;
  56475. readonly R8_SNORM: number;
  56476. readonly RG8_SNORM: number;
  56477. readonly RGB8_SNORM: number;
  56478. readonly RGBA8_SNORM: number;
  56479. readonly R8I: number;
  56480. readonly RG8I: number;
  56481. readonly RGB8I: number;
  56482. readonly RGBA8I: number;
  56483. readonly R8UI: number;
  56484. readonly RG8UI: number;
  56485. readonly RGB8UI: number;
  56486. readonly RGBA8UI: number;
  56487. readonly R16I: number;
  56488. readonly RG16I: number;
  56489. readonly RGB16I: number;
  56490. readonly RGBA16I: number;
  56491. readonly R16UI: number;
  56492. readonly RG16UI: number;
  56493. readonly RGB16UI: number;
  56494. readonly RGBA16UI: number;
  56495. readonly R32I: number;
  56496. readonly RG32I: number;
  56497. readonly RGB32I: number;
  56498. readonly RGBA32I: number;
  56499. readonly R32UI: number;
  56500. readonly RG32UI: number;
  56501. readonly RGB32UI: number;
  56502. readonly RGBA32UI: number;
  56503. readonly RGB10_A2UI: number;
  56504. readonly R11F_G11F_B10F: number;
  56505. readonly RGB9_E5: number;
  56506. readonly RGB10_A2: number;
  56507. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56508. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56509. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56510. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56511. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56512. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56513. 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;
  56514. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56515. readonly TRANSFORM_FEEDBACK: number;
  56516. readonly INTERLEAVED_ATTRIBS: number;
  56517. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56518. createTransformFeedback(): WebGLTransformFeedback;
  56519. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56520. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56521. beginTransformFeedback(primitiveMode: number): void;
  56522. endTransformFeedback(): void;
  56523. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56524. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56525. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56526. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56527. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56528. }
  56529. interface ImageBitmap {
  56530. readonly width: number;
  56531. readonly height: number;
  56532. close(): void;
  56533. }
  56534. interface WebGLQuery extends WebGLObject {
  56535. }
  56536. declare var WebGLQuery: {
  56537. prototype: WebGLQuery;
  56538. new(): WebGLQuery;
  56539. };
  56540. interface WebGLSampler extends WebGLObject {
  56541. }
  56542. declare var WebGLSampler: {
  56543. prototype: WebGLSampler;
  56544. new(): WebGLSampler;
  56545. };
  56546. interface WebGLSync extends WebGLObject {
  56547. }
  56548. declare var WebGLSync: {
  56549. prototype: WebGLSync;
  56550. new(): WebGLSync;
  56551. };
  56552. interface WebGLTransformFeedback extends WebGLObject {
  56553. }
  56554. declare var WebGLTransformFeedback: {
  56555. prototype: WebGLTransformFeedback;
  56556. new(): WebGLTransformFeedback;
  56557. };
  56558. interface WebGLVertexArrayObject extends WebGLObject {
  56559. }
  56560. declare var WebGLVertexArrayObject: {
  56561. prototype: WebGLVertexArrayObject;
  56562. new(): WebGLVertexArrayObject;
  56563. };
  56564. // Type definitions for WebVR API
  56565. // Project: https://w3c.github.io/webvr/
  56566. // Definitions by: six a <https://github.com/lostfictions>
  56567. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56568. interface VRDisplay extends EventTarget {
  56569. /**
  56570. * Dictionary of capabilities describing the VRDisplay.
  56571. */
  56572. readonly capabilities: VRDisplayCapabilities;
  56573. /**
  56574. * z-depth defining the far plane of the eye view frustum
  56575. * enables mapping of values in the render target depth
  56576. * attachment to scene coordinates. Initially set to 10000.0.
  56577. */
  56578. depthFar: number;
  56579. /**
  56580. * z-depth defining the near plane of the eye view frustum
  56581. * enables mapping of values in the render target depth
  56582. * attachment to scene coordinates. Initially set to 0.01.
  56583. */
  56584. depthNear: number;
  56585. /**
  56586. * An identifier for this distinct VRDisplay. Used as an
  56587. * association point in the Gamepad API.
  56588. */
  56589. readonly displayId: number;
  56590. /**
  56591. * A display name, a user-readable name identifying it.
  56592. */
  56593. readonly displayName: string;
  56594. readonly isConnected: boolean;
  56595. readonly isPresenting: boolean;
  56596. /**
  56597. * If this VRDisplay supports room-scale experiences, the optional
  56598. * stage attribute contains details on the room-scale parameters.
  56599. */
  56600. readonly stageParameters: VRStageParameters | null;
  56601. /**
  56602. * Passing the value returned by `requestAnimationFrame` to
  56603. * `cancelAnimationFrame` will unregister the callback.
  56604. * @param handle Define the hanle of the request to cancel
  56605. */
  56606. cancelAnimationFrame(handle: number): void;
  56607. /**
  56608. * Stops presenting to the VRDisplay.
  56609. * @returns a promise to know when it stopped
  56610. */
  56611. exitPresent(): Promise<void>;
  56612. /**
  56613. * Return the current VREyeParameters for the given eye.
  56614. * @param whichEye Define the eye we want the parameter for
  56615. * @returns the eye parameters
  56616. */
  56617. getEyeParameters(whichEye: string): VREyeParameters;
  56618. /**
  56619. * Populates the passed VRFrameData with the information required to render
  56620. * the current frame.
  56621. * @param frameData Define the data structure to populate
  56622. * @returns true if ok otherwise false
  56623. */
  56624. getFrameData(frameData: VRFrameData): boolean;
  56625. /**
  56626. * Get the layers currently being presented.
  56627. * @returns the list of VR layers
  56628. */
  56629. getLayers(): VRLayer[];
  56630. /**
  56631. * Return a VRPose containing the future predicted pose of the VRDisplay
  56632. * when the current frame will be presented. The value returned will not
  56633. * change until JavaScript has returned control to the browser.
  56634. *
  56635. * The VRPose will contain the position, orientation, velocity,
  56636. * and acceleration of each of these properties.
  56637. * @returns the pose object
  56638. */
  56639. getPose(): VRPose;
  56640. /**
  56641. * Return the current instantaneous pose of the VRDisplay, with no
  56642. * prediction applied.
  56643. * @returns the current instantaneous pose
  56644. */
  56645. getImmediatePose(): VRPose;
  56646. /**
  56647. * The callback passed to `requestAnimationFrame` will be called
  56648. * any time a new frame should be rendered. When the VRDisplay is
  56649. * presenting the callback will be called at the native refresh
  56650. * rate of the HMD. When not presenting this function acts
  56651. * identically to how window.requestAnimationFrame acts. Content should
  56652. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56653. * asynchronously from other displays and at differing refresh rates.
  56654. * @param callback Define the eaction to run next frame
  56655. * @returns the request handle it
  56656. */
  56657. requestAnimationFrame(callback: FrameRequestCallback): number;
  56658. /**
  56659. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56660. * Repeat calls while already presenting will update the VRLayers being displayed.
  56661. * @param layers Define the list of layer to present
  56662. * @returns a promise to know when the request has been fulfilled
  56663. */
  56664. requestPresent(layers: VRLayer[]): Promise<void>;
  56665. /**
  56666. * Reset the pose for this display, treating its current position and
  56667. * orientation as the "origin/zero" values. VRPose.position,
  56668. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56669. * updated when calling resetPose(). This should be called in only
  56670. * sitting-space experiences.
  56671. */
  56672. resetPose(): void;
  56673. /**
  56674. * The VRLayer provided to the VRDisplay will be captured and presented
  56675. * in the HMD. Calling this function has the same effect on the source
  56676. * canvas as any other operation that uses its source image, and canvases
  56677. * created without preserveDrawingBuffer set to true will be cleared.
  56678. * @param pose Define the pose to submit
  56679. */
  56680. submitFrame(pose?: VRPose): void;
  56681. }
  56682. declare var VRDisplay: {
  56683. prototype: VRDisplay;
  56684. new(): VRDisplay;
  56685. };
  56686. interface VRLayer {
  56687. leftBounds?: number[] | Float32Array | null;
  56688. rightBounds?: number[] | Float32Array | null;
  56689. source?: HTMLCanvasElement | null;
  56690. }
  56691. interface VRDisplayCapabilities {
  56692. readonly canPresent: boolean;
  56693. readonly hasExternalDisplay: boolean;
  56694. readonly hasOrientation: boolean;
  56695. readonly hasPosition: boolean;
  56696. readonly maxLayers: number;
  56697. }
  56698. interface VREyeParameters {
  56699. /** @deprecated */
  56700. readonly fieldOfView: VRFieldOfView;
  56701. readonly offset: Float32Array;
  56702. readonly renderHeight: number;
  56703. readonly renderWidth: number;
  56704. }
  56705. interface VRFieldOfView {
  56706. readonly downDegrees: number;
  56707. readonly leftDegrees: number;
  56708. readonly rightDegrees: number;
  56709. readonly upDegrees: number;
  56710. }
  56711. interface VRFrameData {
  56712. readonly leftProjectionMatrix: Float32Array;
  56713. readonly leftViewMatrix: Float32Array;
  56714. readonly pose: VRPose;
  56715. readonly rightProjectionMatrix: Float32Array;
  56716. readonly rightViewMatrix: Float32Array;
  56717. readonly timestamp: number;
  56718. }
  56719. interface VRPose {
  56720. readonly angularAcceleration: Float32Array | null;
  56721. readonly angularVelocity: Float32Array | null;
  56722. readonly linearAcceleration: Float32Array | null;
  56723. readonly linearVelocity: Float32Array | null;
  56724. readonly orientation: Float32Array | null;
  56725. readonly position: Float32Array | null;
  56726. readonly timestamp: number;
  56727. }
  56728. interface VRStageParameters {
  56729. sittingToStandingTransform?: Float32Array;
  56730. sizeX?: number;
  56731. sizeY?: number;
  56732. }
  56733. interface Navigator {
  56734. getVRDisplays(): Promise<VRDisplay[]>;
  56735. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56736. }
  56737. interface Window {
  56738. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56739. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56740. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56741. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56742. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56743. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56744. }
  56745. interface Gamepad {
  56746. readonly displayId: number;
  56747. }
  56748. interface XRDevice {
  56749. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56750. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56751. }
  56752. interface XRSession {
  56753. getInputSources(): Array<any>;
  56754. baseLayer: XRWebGLLayer;
  56755. requestFrameOfReference(type: string): Promise<void>;
  56756. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56757. end(): Promise<void>;
  56758. requestAnimationFrame: Function;
  56759. addEventListener: Function;
  56760. }
  56761. interface XRSessionCreationOptions {
  56762. outputContext?: WebGLRenderingContext | null;
  56763. immersive?: boolean;
  56764. environmentIntegration?: boolean;
  56765. }
  56766. interface XRLayer {
  56767. getViewport: Function;
  56768. framebufferWidth: number;
  56769. framebufferHeight: number;
  56770. }
  56771. interface XRView {
  56772. projectionMatrix: Float32Array;
  56773. }
  56774. interface XRFrame {
  56775. getDevicePose: Function;
  56776. getInputPose: Function;
  56777. views: Array<XRView>;
  56778. baseLayer: XRLayer;
  56779. }
  56780. interface XRFrameOfReference {
  56781. }
  56782. interface XRWebGLLayer extends XRLayer {
  56783. framebuffer: WebGLFramebuffer;
  56784. }
  56785. declare var XRWebGLLayer: {
  56786. prototype: XRWebGLLayer;
  56787. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56788. };
  56789. declare module "babylonjs" {
  56790. export * from "babylonjs/Legacy/legacy";
  56791. }
  56792. declare module BABYLON {
  56793. /** Alias type for value that can be null */
  56794. export type Nullable<T> = T | null;
  56795. /**
  56796. * Alias type for number that are floats
  56797. * @ignorenaming
  56798. */
  56799. export type float = number;
  56800. /**
  56801. * Alias type for number that are doubles.
  56802. * @ignorenaming
  56803. */
  56804. export type double = number;
  56805. /**
  56806. * Alias type for number that are integer
  56807. * @ignorenaming
  56808. */
  56809. export type int = number;
  56810. /** Alias type for number array or Float32Array */
  56811. export type FloatArray = number[] | Float32Array;
  56812. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56813. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56814. /**
  56815. * Alias for types that can be used by a Buffer or VertexBuffer.
  56816. */
  56817. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56818. /**
  56819. * Alias type for primitive types
  56820. * @ignorenaming
  56821. */
  56822. type Primitive = undefined | null | boolean | string | number | Function;
  56823. /**
  56824. * Type modifier to make all the properties of an object Readonly
  56825. */
  56826. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56827. /**
  56828. * Type modifier to make all the properties of an object Readonly recursively
  56829. */
  56830. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56831. /** @hidden */
  56832. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56833. }
  56834. /** @hidden */
  56835. /** @hidden */
  56836. type DeepImmutableObject<T> = {
  56837. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56838. };
  56839. }
  56840. declare module BABYLON {
  56841. /**
  56842. * Class containing a set of static utilities functions for arrays.
  56843. */
  56844. export class ArrayTools {
  56845. /**
  56846. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56847. * @param size the number of element to construct and put in the array
  56848. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56849. * @returns a new array filled with new objects
  56850. */
  56851. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56852. }
  56853. }
  56854. declare module BABYLON {
  56855. /**
  56856. * Scalar computation library
  56857. */
  56858. export class Scalar {
  56859. /**
  56860. * Two pi constants convenient for computation.
  56861. */
  56862. static TwoPi: number;
  56863. /**
  56864. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56865. * @param a number
  56866. * @param b number
  56867. * @param epsilon (default = 1.401298E-45)
  56868. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56869. */
  56870. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56871. /**
  56872. * Returns a string : the upper case translation of the number i to hexadecimal.
  56873. * @param i number
  56874. * @returns the upper case translation of the number i to hexadecimal.
  56875. */
  56876. static ToHex(i: number): string;
  56877. /**
  56878. * Returns -1 if value is negative and +1 is value is positive.
  56879. * @param value the value
  56880. * @returns the value itself if it's equal to zero.
  56881. */
  56882. static Sign(value: number): number;
  56883. /**
  56884. * Returns the value itself if it's between min and max.
  56885. * Returns min if the value is lower than min.
  56886. * Returns max if the value is greater than max.
  56887. * @param value the value to clmap
  56888. * @param min the min value to clamp to (default: 0)
  56889. * @param max the max value to clamp to (default: 1)
  56890. * @returns the clamped value
  56891. */
  56892. static Clamp(value: number, min?: number, max?: number): number;
  56893. /**
  56894. * the log2 of value.
  56895. * @param value the value to compute log2 of
  56896. * @returns the log2 of value.
  56897. */
  56898. static Log2(value: number): number;
  56899. /**
  56900. * Loops the value, so that it is never larger than length and never smaller than 0.
  56901. *
  56902. * This is similar to the modulo operator but it works with floating point numbers.
  56903. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56904. * With t = 5 and length = 2.5, the result would be 0.0.
  56905. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56906. * @param value the value
  56907. * @param length the length
  56908. * @returns the looped value
  56909. */
  56910. static Repeat(value: number, length: number): number;
  56911. /**
  56912. * Normalize the value between 0.0 and 1.0 using min and max values
  56913. * @param value value to normalize
  56914. * @param min max to normalize between
  56915. * @param max min to normalize between
  56916. * @returns the normalized value
  56917. */
  56918. static Normalize(value: number, min: number, max: number): number;
  56919. /**
  56920. * Denormalize the value from 0.0 and 1.0 using min and max values
  56921. * @param normalized value to denormalize
  56922. * @param min max to denormalize between
  56923. * @param max min to denormalize between
  56924. * @returns the denormalized value
  56925. */
  56926. static Denormalize(normalized: number, min: number, max: number): number;
  56927. /**
  56928. * Calculates the shortest difference between two given angles given in degrees.
  56929. * @param current current angle in degrees
  56930. * @param target target angle in degrees
  56931. * @returns the delta
  56932. */
  56933. static DeltaAngle(current: number, target: number): number;
  56934. /**
  56935. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56936. * @param tx value
  56937. * @param length length
  56938. * @returns The returned value will move back and forth between 0 and length
  56939. */
  56940. static PingPong(tx: number, length: number): number;
  56941. /**
  56942. * Interpolates between min and max with smoothing at the limits.
  56943. *
  56944. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56945. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56946. * @param from from
  56947. * @param to to
  56948. * @param tx value
  56949. * @returns the smooth stepped value
  56950. */
  56951. static SmoothStep(from: number, to: number, tx: number): number;
  56952. /**
  56953. * Moves a value current towards target.
  56954. *
  56955. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56956. * Negative values of maxDelta pushes the value away from target.
  56957. * @param current current value
  56958. * @param target target value
  56959. * @param maxDelta max distance to move
  56960. * @returns resulting value
  56961. */
  56962. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56963. /**
  56964. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56965. *
  56966. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56967. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56968. * @param current current value
  56969. * @param target target value
  56970. * @param maxDelta max distance to move
  56971. * @returns resulting angle
  56972. */
  56973. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56974. /**
  56975. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56976. * @param start start value
  56977. * @param end target value
  56978. * @param amount amount to lerp between
  56979. * @returns the lerped value
  56980. */
  56981. static Lerp(start: number, end: number, amount: number): number;
  56982. /**
  56983. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56984. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56985. * @param start start value
  56986. * @param end target value
  56987. * @param amount amount to lerp between
  56988. * @returns the lerped value
  56989. */
  56990. static LerpAngle(start: number, end: number, amount: number): number;
  56991. /**
  56992. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56993. * @param a start value
  56994. * @param b target value
  56995. * @param value value between a and b
  56996. * @returns the inverseLerp value
  56997. */
  56998. static InverseLerp(a: number, b: number, value: number): number;
  56999. /**
  57000. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57001. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57002. * @param value1 spline value
  57003. * @param tangent1 spline value
  57004. * @param value2 spline value
  57005. * @param tangent2 spline value
  57006. * @param amount input value
  57007. * @returns hermite result
  57008. */
  57009. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57010. /**
  57011. * Returns a random float number between and min and max values
  57012. * @param min min value of random
  57013. * @param max max value of random
  57014. * @returns random value
  57015. */
  57016. static RandomRange(min: number, max: number): number;
  57017. /**
  57018. * This function returns percentage of a number in a given range.
  57019. *
  57020. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57021. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57022. * @param number to convert to percentage
  57023. * @param min min range
  57024. * @param max max range
  57025. * @returns the percentage
  57026. */
  57027. static RangeToPercent(number: number, min: number, max: number): number;
  57028. /**
  57029. * This function returns number that corresponds to the percentage in a given range.
  57030. *
  57031. * PercentToRange(0.34,0,100) will return 34.
  57032. * @param percent to convert to number
  57033. * @param min min range
  57034. * @param max max range
  57035. * @returns the number
  57036. */
  57037. static PercentToRange(percent: number, min: number, max: number): number;
  57038. /**
  57039. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57040. * @param angle The angle to normalize in radian.
  57041. * @return The converted angle.
  57042. */
  57043. static NormalizeRadians(angle: number): number;
  57044. }
  57045. }
  57046. declare module BABYLON {
  57047. /**
  57048. * Constant used to convert a value to gamma space
  57049. * @ignorenaming
  57050. */
  57051. export const ToGammaSpace: number;
  57052. /**
  57053. * Constant used to convert a value to linear space
  57054. * @ignorenaming
  57055. */
  57056. export const ToLinearSpace = 2.2;
  57057. /**
  57058. * Constant used to define the minimal number value in Babylon.js
  57059. * @ignorenaming
  57060. */
  57061. export const Epsilon = 0.001;
  57062. /**
  57063. * Class used to hold a RBG color
  57064. */
  57065. export class Color3 {
  57066. /**
  57067. * Defines the red component (between 0 and 1, default is 0)
  57068. */
  57069. r: number;
  57070. /**
  57071. * Defines the green component (between 0 and 1, default is 0)
  57072. */
  57073. g: number;
  57074. /**
  57075. * Defines the blue component (between 0 and 1, default is 0)
  57076. */
  57077. b: number;
  57078. /**
  57079. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57080. * @param r defines the red component (between 0 and 1, default is 0)
  57081. * @param g defines the green component (between 0 and 1, default is 0)
  57082. * @param b defines the blue component (between 0 and 1, default is 0)
  57083. */
  57084. constructor(
  57085. /**
  57086. * Defines the red component (between 0 and 1, default is 0)
  57087. */
  57088. r?: number,
  57089. /**
  57090. * Defines the green component (between 0 and 1, default is 0)
  57091. */
  57092. g?: number,
  57093. /**
  57094. * Defines the blue component (between 0 and 1, default is 0)
  57095. */
  57096. b?: number);
  57097. /**
  57098. * Creates a string with the Color3 current values
  57099. * @returns the string representation of the Color3 object
  57100. */
  57101. toString(): string;
  57102. /**
  57103. * Returns the string "Color3"
  57104. * @returns "Color3"
  57105. */
  57106. getClassName(): string;
  57107. /**
  57108. * Compute the Color3 hash code
  57109. * @returns an unique number that can be used to hash Color3 objects
  57110. */
  57111. getHashCode(): number;
  57112. /**
  57113. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57114. * @param array defines the array where to store the r,g,b components
  57115. * @param index defines an optional index in the target array to define where to start storing values
  57116. * @returns the current Color3 object
  57117. */
  57118. toArray(array: FloatArray, index?: number): Color3;
  57119. /**
  57120. * Returns a new Color4 object from the current Color3 and the given alpha
  57121. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57122. * @returns a new Color4 object
  57123. */
  57124. toColor4(alpha?: number): Color4;
  57125. /**
  57126. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57127. * @returns the new array
  57128. */
  57129. asArray(): number[];
  57130. /**
  57131. * Returns the luminance value
  57132. * @returns a float value
  57133. */
  57134. toLuminance(): number;
  57135. /**
  57136. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57137. * @param otherColor defines the second operand
  57138. * @returns the new Color3 object
  57139. */
  57140. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57141. /**
  57142. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57143. * @param otherColor defines the second operand
  57144. * @param result defines the Color3 object where to store the result
  57145. * @returns the current Color3
  57146. */
  57147. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57148. /**
  57149. * Determines equality between Color3 objects
  57150. * @param otherColor defines the second operand
  57151. * @returns true if the rgb values are equal to the given ones
  57152. */
  57153. equals(otherColor: DeepImmutable<Color3>): boolean;
  57154. /**
  57155. * Determines equality between the current Color3 object and a set of r,b,g values
  57156. * @param r defines the red component to check
  57157. * @param g defines the green component to check
  57158. * @param b defines the blue component to check
  57159. * @returns true if the rgb values are equal to the given ones
  57160. */
  57161. equalsFloats(r: number, g: number, b: number): boolean;
  57162. /**
  57163. * Multiplies in place each rgb value by scale
  57164. * @param scale defines the scaling factor
  57165. * @returns the updated Color3
  57166. */
  57167. scale(scale: number): Color3;
  57168. /**
  57169. * Multiplies the rgb values by scale and stores the result into "result"
  57170. * @param scale defines the scaling factor
  57171. * @param result defines the Color3 object where to store the result
  57172. * @returns the unmodified current Color3
  57173. */
  57174. scaleToRef(scale: number, result: Color3): Color3;
  57175. /**
  57176. * Scale the current Color3 values by a factor and add the result to a given Color3
  57177. * @param scale defines the scale factor
  57178. * @param result defines color to store the result into
  57179. * @returns the unmodified current Color3
  57180. */
  57181. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57182. /**
  57183. * Clamps the rgb values by the min and max values and stores the result into "result"
  57184. * @param min defines minimum clamping value (default is 0)
  57185. * @param max defines maximum clamping value (default is 1)
  57186. * @param result defines color to store the result into
  57187. * @returns the original Color3
  57188. */
  57189. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57190. /**
  57191. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57192. * @param otherColor defines the second operand
  57193. * @returns the new Color3
  57194. */
  57195. add(otherColor: DeepImmutable<Color3>): Color3;
  57196. /**
  57197. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57198. * @param otherColor defines the second operand
  57199. * @param result defines Color3 object to store the result into
  57200. * @returns the unmodified current Color3
  57201. */
  57202. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57203. /**
  57204. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57205. * @param otherColor defines the second operand
  57206. * @returns the new Color3
  57207. */
  57208. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57209. /**
  57210. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57211. * @param otherColor defines the second operand
  57212. * @param result defines Color3 object to store the result into
  57213. * @returns the unmodified current Color3
  57214. */
  57215. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57216. /**
  57217. * Copy the current object
  57218. * @returns a new Color3 copied the current one
  57219. */
  57220. clone(): Color3;
  57221. /**
  57222. * Copies the rgb values from the source in the current Color3
  57223. * @param source defines the source Color3 object
  57224. * @returns the updated Color3 object
  57225. */
  57226. copyFrom(source: DeepImmutable<Color3>): Color3;
  57227. /**
  57228. * Updates the Color3 rgb values from the given floats
  57229. * @param r defines the red component to read from
  57230. * @param g defines the green component to read from
  57231. * @param b defines the blue component to read from
  57232. * @returns the current Color3 object
  57233. */
  57234. copyFromFloats(r: number, g: number, b: number): Color3;
  57235. /**
  57236. * Updates the Color3 rgb values from the given floats
  57237. * @param r defines the red component to read from
  57238. * @param g defines the green component to read from
  57239. * @param b defines the blue component to read from
  57240. * @returns the current Color3 object
  57241. */
  57242. set(r: number, g: number, b: number): Color3;
  57243. /**
  57244. * Compute the Color3 hexadecimal code as a string
  57245. * @returns a string containing the hexadecimal representation of the Color3 object
  57246. */
  57247. toHexString(): string;
  57248. /**
  57249. * Computes a new Color3 converted from the current one to linear space
  57250. * @returns a new Color3 object
  57251. */
  57252. toLinearSpace(): Color3;
  57253. /**
  57254. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57255. * @param convertedColor defines the Color3 object where to store the linear space version
  57256. * @returns the unmodified Color3
  57257. */
  57258. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57259. /**
  57260. * Computes a new Color3 converted from the current one to gamma space
  57261. * @returns a new Color3 object
  57262. */
  57263. toGammaSpace(): Color3;
  57264. /**
  57265. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57266. * @param convertedColor defines the Color3 object where to store the gamma space version
  57267. * @returns the unmodified Color3
  57268. */
  57269. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57270. private static _BlackReadOnly;
  57271. /**
  57272. * Creates a new Color3 from the string containing valid hexadecimal values
  57273. * @param hex defines a string containing valid hexadecimal values
  57274. * @returns a new Color3 object
  57275. */
  57276. static FromHexString(hex: string): Color3;
  57277. /**
  57278. * Creates a new Vector3 from the starting index of the given array
  57279. * @param array defines the source array
  57280. * @param offset defines an offset in the source array
  57281. * @returns a new Color3 object
  57282. */
  57283. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57284. /**
  57285. * Creates a new Color3 from integer values (< 256)
  57286. * @param r defines the red component to read from (value between 0 and 255)
  57287. * @param g defines the green component to read from (value between 0 and 255)
  57288. * @param b defines the blue component to read from (value between 0 and 255)
  57289. * @returns a new Color3 object
  57290. */
  57291. static FromInts(r: number, g: number, b: number): Color3;
  57292. /**
  57293. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57294. * @param start defines the start Color3 value
  57295. * @param end defines the end Color3 value
  57296. * @param amount defines the gradient value between start and end
  57297. * @returns a new Color3 object
  57298. */
  57299. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57300. /**
  57301. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57302. * @param left defines the start value
  57303. * @param right defines the end value
  57304. * @param amount defines the gradient factor
  57305. * @param result defines the Color3 object where to store the result
  57306. */
  57307. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57308. /**
  57309. * Returns a Color3 value containing a red color
  57310. * @returns a new Color3 object
  57311. */
  57312. static Red(): Color3;
  57313. /**
  57314. * Returns a Color3 value containing a green color
  57315. * @returns a new Color3 object
  57316. */
  57317. static Green(): Color3;
  57318. /**
  57319. * Returns a Color3 value containing a blue color
  57320. * @returns a new Color3 object
  57321. */
  57322. static Blue(): Color3;
  57323. /**
  57324. * Returns a Color3 value containing a black color
  57325. * @returns a new Color3 object
  57326. */
  57327. static Black(): Color3;
  57328. /**
  57329. * Gets a Color3 value containing a black color that must not be updated
  57330. */
  57331. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57332. /**
  57333. * Returns a Color3 value containing a white color
  57334. * @returns a new Color3 object
  57335. */
  57336. static White(): Color3;
  57337. /**
  57338. * Returns a Color3 value containing a purple color
  57339. * @returns a new Color3 object
  57340. */
  57341. static Purple(): Color3;
  57342. /**
  57343. * Returns a Color3 value containing a magenta color
  57344. * @returns a new Color3 object
  57345. */
  57346. static Magenta(): Color3;
  57347. /**
  57348. * Returns a Color3 value containing a yellow color
  57349. * @returns a new Color3 object
  57350. */
  57351. static Yellow(): Color3;
  57352. /**
  57353. * Returns a Color3 value containing a gray color
  57354. * @returns a new Color3 object
  57355. */
  57356. static Gray(): Color3;
  57357. /**
  57358. * Returns a Color3 value containing a teal color
  57359. * @returns a new Color3 object
  57360. */
  57361. static Teal(): Color3;
  57362. /**
  57363. * Returns a Color3 value containing a random color
  57364. * @returns a new Color3 object
  57365. */
  57366. static Random(): Color3;
  57367. }
  57368. /**
  57369. * Class used to hold a RBGA color
  57370. */
  57371. export class Color4 {
  57372. /**
  57373. * Defines the red component (between 0 and 1, default is 0)
  57374. */
  57375. r: number;
  57376. /**
  57377. * Defines the green component (between 0 and 1, default is 0)
  57378. */
  57379. g: number;
  57380. /**
  57381. * Defines the blue component (between 0 and 1, default is 0)
  57382. */
  57383. b: number;
  57384. /**
  57385. * Defines the alpha component (between 0 and 1, default is 1)
  57386. */
  57387. a: number;
  57388. /**
  57389. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57390. * @param r defines the red component (between 0 and 1, default is 0)
  57391. * @param g defines the green component (between 0 and 1, default is 0)
  57392. * @param b defines the blue component (between 0 and 1, default is 0)
  57393. * @param a defines the alpha component (between 0 and 1, default is 1)
  57394. */
  57395. constructor(
  57396. /**
  57397. * Defines the red component (between 0 and 1, default is 0)
  57398. */
  57399. r?: number,
  57400. /**
  57401. * Defines the green component (between 0 and 1, default is 0)
  57402. */
  57403. g?: number,
  57404. /**
  57405. * Defines the blue component (between 0 and 1, default is 0)
  57406. */
  57407. b?: number,
  57408. /**
  57409. * Defines the alpha component (between 0 and 1, default is 1)
  57410. */
  57411. a?: number);
  57412. /**
  57413. * Adds in place the given Color4 values to the current Color4 object
  57414. * @param right defines the second operand
  57415. * @returns the current updated Color4 object
  57416. */
  57417. addInPlace(right: DeepImmutable<Color4>): Color4;
  57418. /**
  57419. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57420. * @returns the new array
  57421. */
  57422. asArray(): number[];
  57423. /**
  57424. * Stores from the starting index in the given array the Color4 successive values
  57425. * @param array defines the array where to store the r,g,b components
  57426. * @param index defines an optional index in the target array to define where to start storing values
  57427. * @returns the current Color4 object
  57428. */
  57429. toArray(array: number[], index?: number): Color4;
  57430. /**
  57431. * Determines equality between Color4 objects
  57432. * @param otherColor defines the second operand
  57433. * @returns true if the rgba values are equal to the given ones
  57434. */
  57435. equals(otherColor: DeepImmutable<Color4>): boolean;
  57436. /**
  57437. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57438. * @param right defines the second operand
  57439. * @returns a new Color4 object
  57440. */
  57441. add(right: DeepImmutable<Color4>): Color4;
  57442. /**
  57443. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57444. * @param right defines the second operand
  57445. * @returns a new Color4 object
  57446. */
  57447. subtract(right: DeepImmutable<Color4>): Color4;
  57448. /**
  57449. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57450. * @param right defines the second operand
  57451. * @param result defines the Color4 object where to store the result
  57452. * @returns the current Color4 object
  57453. */
  57454. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57455. /**
  57456. * Creates a new Color4 with the current Color4 values multiplied by scale
  57457. * @param scale defines the scaling factor to apply
  57458. * @returns a new Color4 object
  57459. */
  57460. scale(scale: number): Color4;
  57461. /**
  57462. * Multiplies the current Color4 values by scale and stores the result in "result"
  57463. * @param scale defines the scaling factor to apply
  57464. * @param result defines the Color4 object where to store the result
  57465. * @returns the current unmodified Color4
  57466. */
  57467. scaleToRef(scale: number, result: Color4): Color4;
  57468. /**
  57469. * Scale the current Color4 values by a factor and add the result to a given Color4
  57470. * @param scale defines the scale factor
  57471. * @param result defines the Color4 object where to store the result
  57472. * @returns the unmodified current Color4
  57473. */
  57474. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57475. /**
  57476. * Clamps the rgb values by the min and max values and stores the result into "result"
  57477. * @param min defines minimum clamping value (default is 0)
  57478. * @param max defines maximum clamping value (default is 1)
  57479. * @param result defines color to store the result into.
  57480. * @returns the cuurent Color4
  57481. */
  57482. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57483. /**
  57484. * Multipy an Color4 value by another and return a new Color4 object
  57485. * @param color defines the Color4 value to multiply by
  57486. * @returns a new Color4 object
  57487. */
  57488. multiply(color: Color4): Color4;
  57489. /**
  57490. * Multipy a Color4 value by another and push the result in a reference value
  57491. * @param color defines the Color4 value to multiply by
  57492. * @param result defines the Color4 to fill the result in
  57493. * @returns the result Color4
  57494. */
  57495. multiplyToRef(color: Color4, result: Color4): Color4;
  57496. /**
  57497. * Creates a string with the Color4 current values
  57498. * @returns the string representation of the Color4 object
  57499. */
  57500. toString(): string;
  57501. /**
  57502. * Returns the string "Color4"
  57503. * @returns "Color4"
  57504. */
  57505. getClassName(): string;
  57506. /**
  57507. * Compute the Color4 hash code
  57508. * @returns an unique number that can be used to hash Color4 objects
  57509. */
  57510. getHashCode(): number;
  57511. /**
  57512. * Creates a new Color4 copied from the current one
  57513. * @returns a new Color4 object
  57514. */
  57515. clone(): Color4;
  57516. /**
  57517. * Copies the given Color4 values into the current one
  57518. * @param source defines the source Color4 object
  57519. * @returns the current updated Color4 object
  57520. */
  57521. copyFrom(source: Color4): Color4;
  57522. /**
  57523. * Copies the given float values into the current one
  57524. * @param r defines the red component to read from
  57525. * @param g defines the green component to read from
  57526. * @param b defines the blue component to read from
  57527. * @param a defines the alpha component to read from
  57528. * @returns the current updated Color4 object
  57529. */
  57530. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57531. /**
  57532. * Copies the given float values into the current one
  57533. * @param r defines the red component to read from
  57534. * @param g defines the green component to read from
  57535. * @param b defines the blue component to read from
  57536. * @param a defines the alpha component to read from
  57537. * @returns the current updated Color4 object
  57538. */
  57539. set(r: number, g: number, b: number, a: number): Color4;
  57540. /**
  57541. * Compute the Color4 hexadecimal code as a string
  57542. * @returns a string containing the hexadecimal representation of the Color4 object
  57543. */
  57544. toHexString(): string;
  57545. /**
  57546. * Computes a new Color4 converted from the current one to linear space
  57547. * @returns a new Color4 object
  57548. */
  57549. toLinearSpace(): Color4;
  57550. /**
  57551. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57552. * @param convertedColor defines the Color4 object where to store the linear space version
  57553. * @returns the unmodified Color4
  57554. */
  57555. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57556. /**
  57557. * Computes a new Color4 converted from the current one to gamma space
  57558. * @returns a new Color4 object
  57559. */
  57560. toGammaSpace(): Color4;
  57561. /**
  57562. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57563. * @param convertedColor defines the Color4 object where to store the gamma space version
  57564. * @returns the unmodified Color4
  57565. */
  57566. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57567. /**
  57568. * Creates a new Color4 from the string containing valid hexadecimal values
  57569. * @param hex defines a string containing valid hexadecimal values
  57570. * @returns a new Color4 object
  57571. */
  57572. static FromHexString(hex: string): Color4;
  57573. /**
  57574. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57575. * @param left defines the start value
  57576. * @param right defines the end value
  57577. * @param amount defines the gradient factor
  57578. * @returns a new Color4 object
  57579. */
  57580. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57581. /**
  57582. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57583. * @param left defines the start value
  57584. * @param right defines the end value
  57585. * @param amount defines the gradient factor
  57586. * @param result defines the Color4 object where to store data
  57587. */
  57588. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57589. /**
  57590. * Creates a new Color4 from a Color3 and an alpha value
  57591. * @param color3 defines the source Color3 to read from
  57592. * @param alpha defines the alpha component (1.0 by default)
  57593. * @returns a new Color4 object
  57594. */
  57595. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57596. /**
  57597. * Creates a new Color4 from the starting index element of the given array
  57598. * @param array defines the source array to read from
  57599. * @param offset defines the offset in the source array
  57600. * @returns a new Color4 object
  57601. */
  57602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57603. /**
  57604. * Creates a new Color3 from integer values (< 256)
  57605. * @param r defines the red component to read from (value between 0 and 255)
  57606. * @param g defines the green component to read from (value between 0 and 255)
  57607. * @param b defines the blue component to read from (value between 0 and 255)
  57608. * @param a defines the alpha component to read from (value between 0 and 255)
  57609. * @returns a new Color3 object
  57610. */
  57611. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57612. /**
  57613. * Check the content of a given array and convert it to an array containing RGBA data
  57614. * If the original array was already containing count * 4 values then it is returned directly
  57615. * @param colors defines the array to check
  57616. * @param count defines the number of RGBA data to expect
  57617. * @returns an array containing count * 4 values (RGBA)
  57618. */
  57619. static CheckColors4(colors: number[], count: number): number[];
  57620. }
  57621. /**
  57622. * Class representing a vector containing 2 coordinates
  57623. */
  57624. export class Vector2 {
  57625. /** defines the first coordinate */
  57626. x: number;
  57627. /** defines the second coordinate */
  57628. y: number;
  57629. /**
  57630. * Creates a new Vector2 from the given x and y coordinates
  57631. * @param x defines the first coordinate
  57632. * @param y defines the second coordinate
  57633. */
  57634. constructor(
  57635. /** defines the first coordinate */
  57636. x?: number,
  57637. /** defines the second coordinate */
  57638. y?: number);
  57639. /**
  57640. * Gets a string with the Vector2 coordinates
  57641. * @returns a string with the Vector2 coordinates
  57642. */
  57643. toString(): string;
  57644. /**
  57645. * Gets class name
  57646. * @returns the string "Vector2"
  57647. */
  57648. getClassName(): string;
  57649. /**
  57650. * Gets current vector hash code
  57651. * @returns the Vector2 hash code as a number
  57652. */
  57653. getHashCode(): number;
  57654. /**
  57655. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57656. * @param array defines the source array
  57657. * @param index defines the offset in source array
  57658. * @returns the current Vector2
  57659. */
  57660. toArray(array: FloatArray, index?: number): Vector2;
  57661. /**
  57662. * Copy the current vector to an array
  57663. * @returns a new array with 2 elements: the Vector2 coordinates.
  57664. */
  57665. asArray(): number[];
  57666. /**
  57667. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57668. * @param source defines the source Vector2
  57669. * @returns the current updated Vector2
  57670. */
  57671. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57672. /**
  57673. * Sets the Vector2 coordinates with the given floats
  57674. * @param x defines the first coordinate
  57675. * @param y defines the second coordinate
  57676. * @returns the current updated Vector2
  57677. */
  57678. copyFromFloats(x: number, y: number): Vector2;
  57679. /**
  57680. * Sets the Vector2 coordinates with the given floats
  57681. * @param x defines the first coordinate
  57682. * @param y defines the second coordinate
  57683. * @returns the current updated Vector2
  57684. */
  57685. set(x: number, y: number): Vector2;
  57686. /**
  57687. * Add another vector with the current one
  57688. * @param otherVector defines the other vector
  57689. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57690. */
  57691. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57692. /**
  57693. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57694. * @param otherVector defines the other vector
  57695. * @param result defines the target vector
  57696. * @returns the unmodified current Vector2
  57697. */
  57698. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57699. /**
  57700. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57701. * @param otherVector defines the other vector
  57702. * @returns the current updated Vector2
  57703. */
  57704. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57705. /**
  57706. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57707. * @param otherVector defines the other vector
  57708. * @returns a new Vector2
  57709. */
  57710. addVector3(otherVector: Vector3): Vector2;
  57711. /**
  57712. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57713. * @param otherVector defines the other vector
  57714. * @returns a new Vector2
  57715. */
  57716. subtract(otherVector: Vector2): Vector2;
  57717. /**
  57718. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57719. * @param otherVector defines the other vector
  57720. * @param result defines the target vector
  57721. * @returns the unmodified current Vector2
  57722. */
  57723. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57724. /**
  57725. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57726. * @param otherVector defines the other vector
  57727. * @returns the current updated Vector2
  57728. */
  57729. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57730. /**
  57731. * Multiplies in place the current Vector2 coordinates by the given ones
  57732. * @param otherVector defines the other vector
  57733. * @returns the current updated Vector2
  57734. */
  57735. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57736. /**
  57737. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57738. * @param otherVector defines the other vector
  57739. * @returns a new Vector2
  57740. */
  57741. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57742. /**
  57743. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57744. * @param otherVector defines the other vector
  57745. * @param result defines the target vector
  57746. * @returns the unmodified current Vector2
  57747. */
  57748. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57749. /**
  57750. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57751. * @param x defines the first coordinate
  57752. * @param y defines the second coordinate
  57753. * @returns a new Vector2
  57754. */
  57755. multiplyByFloats(x: number, y: number): Vector2;
  57756. /**
  57757. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57758. * @param otherVector defines the other vector
  57759. * @returns a new Vector2
  57760. */
  57761. divide(otherVector: Vector2): Vector2;
  57762. /**
  57763. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57764. * @param otherVector defines the other vector
  57765. * @param result defines the target vector
  57766. * @returns the unmodified current Vector2
  57767. */
  57768. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57769. /**
  57770. * Divides the current Vector2 coordinates by the given ones
  57771. * @param otherVector defines the other vector
  57772. * @returns the current updated Vector2
  57773. */
  57774. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57775. /**
  57776. * Gets a new Vector2 with current Vector2 negated coordinates
  57777. * @returns a new Vector2
  57778. */
  57779. negate(): Vector2;
  57780. /**
  57781. * Multiply the Vector2 coordinates by scale
  57782. * @param scale defines the scaling factor
  57783. * @returns the current updated Vector2
  57784. */
  57785. scaleInPlace(scale: number): Vector2;
  57786. /**
  57787. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57788. * @param scale defines the scaling factor
  57789. * @returns a new Vector2
  57790. */
  57791. scale(scale: number): Vector2;
  57792. /**
  57793. * Scale the current Vector2 values by a factor to a given Vector2
  57794. * @param scale defines the scale factor
  57795. * @param result defines the Vector2 object where to store the result
  57796. * @returns the unmodified current Vector2
  57797. */
  57798. scaleToRef(scale: number, result: Vector2): Vector2;
  57799. /**
  57800. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57801. * @param scale defines the scale factor
  57802. * @param result defines the Vector2 object where to store the result
  57803. * @returns the unmodified current Vector2
  57804. */
  57805. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57806. /**
  57807. * Gets a boolean if two vectors are equals
  57808. * @param otherVector defines the other vector
  57809. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57810. */
  57811. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57812. /**
  57813. * Gets a boolean if two vectors are equals (using an epsilon value)
  57814. * @param otherVector defines the other vector
  57815. * @param epsilon defines the minimal distance to consider equality
  57816. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57817. */
  57818. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57819. /**
  57820. * Gets a new Vector2 from current Vector2 floored values
  57821. * @returns a new Vector2
  57822. */
  57823. floor(): Vector2;
  57824. /**
  57825. * Gets a new Vector2 from current Vector2 floored values
  57826. * @returns a new Vector2
  57827. */
  57828. fract(): Vector2;
  57829. /**
  57830. * Gets the length of the vector
  57831. * @returns the vector length (float)
  57832. */
  57833. length(): number;
  57834. /**
  57835. * Gets the vector squared length
  57836. * @returns the vector squared length (float)
  57837. */
  57838. lengthSquared(): number;
  57839. /**
  57840. * Normalize the vector
  57841. * @returns the current updated Vector2
  57842. */
  57843. normalize(): Vector2;
  57844. /**
  57845. * Gets a new Vector2 copied from the Vector2
  57846. * @returns a new Vector2
  57847. */
  57848. clone(): Vector2;
  57849. /**
  57850. * Gets a new Vector2(0, 0)
  57851. * @returns a new Vector2
  57852. */
  57853. static Zero(): Vector2;
  57854. /**
  57855. * Gets a new Vector2(1, 1)
  57856. * @returns a new Vector2
  57857. */
  57858. static One(): Vector2;
  57859. /**
  57860. * Gets a new Vector2 set from the given index element of the given array
  57861. * @param array defines the data source
  57862. * @param offset defines the offset in the data source
  57863. * @returns a new Vector2
  57864. */
  57865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57866. /**
  57867. * Sets "result" from the given index element of the given array
  57868. * @param array defines the data source
  57869. * @param offset defines the offset in the data source
  57870. * @param result defines the target vector
  57871. */
  57872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57873. /**
  57874. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57875. * @param value1 defines 1st point of control
  57876. * @param value2 defines 2nd point of control
  57877. * @param value3 defines 3rd point of control
  57878. * @param value4 defines 4th point of control
  57879. * @param amount defines the interpolation factor
  57880. * @returns a new Vector2
  57881. */
  57882. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57883. /**
  57884. * 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".
  57885. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57886. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57887. * @param value defines the value to clamp
  57888. * @param min defines the lower limit
  57889. * @param max defines the upper limit
  57890. * @returns a new Vector2
  57891. */
  57892. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57893. /**
  57894. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57895. * @param value1 defines the 1st control point
  57896. * @param tangent1 defines the outgoing tangent
  57897. * @param value2 defines the 2nd control point
  57898. * @param tangent2 defines the incoming tangent
  57899. * @param amount defines the interpolation factor
  57900. * @returns a new Vector2
  57901. */
  57902. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57903. /**
  57904. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57905. * @param start defines the start vector
  57906. * @param end defines the end vector
  57907. * @param amount defines the interpolation factor
  57908. * @returns a new Vector2
  57909. */
  57910. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57911. /**
  57912. * Gets the dot product of the vector "left" and the vector "right"
  57913. * @param left defines first vector
  57914. * @param right defines second vector
  57915. * @returns the dot product (float)
  57916. */
  57917. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57918. /**
  57919. * Returns a new Vector2 equal to the normalized given vector
  57920. * @param vector defines the vector to normalize
  57921. * @returns a new Vector2
  57922. */
  57923. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57924. /**
  57925. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57926. * @param left defines 1st vector
  57927. * @param right defines 2nd vector
  57928. * @returns a new Vector2
  57929. */
  57930. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57931. /**
  57932. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57933. * @param left defines 1st vector
  57934. * @param right defines 2nd vector
  57935. * @returns a new Vector2
  57936. */
  57937. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57938. /**
  57939. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57940. * @param vector defines the vector to transform
  57941. * @param transformation defines the matrix to apply
  57942. * @returns a new Vector2
  57943. */
  57944. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57945. /**
  57946. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57947. * @param vector defines the vector to transform
  57948. * @param transformation defines the matrix to apply
  57949. * @param result defines the target vector
  57950. */
  57951. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57952. /**
  57953. * Determines if a given vector is included in a triangle
  57954. * @param p defines the vector to test
  57955. * @param p0 defines 1st triangle point
  57956. * @param p1 defines 2nd triangle point
  57957. * @param p2 defines 3rd triangle point
  57958. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57959. */
  57960. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57961. /**
  57962. * Gets the distance between the vectors "value1" and "value2"
  57963. * @param value1 defines first vector
  57964. * @param value2 defines second vector
  57965. * @returns the distance between vectors
  57966. */
  57967. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57968. /**
  57969. * Returns the squared distance between the vectors "value1" and "value2"
  57970. * @param value1 defines first vector
  57971. * @param value2 defines second vector
  57972. * @returns the squared distance between vectors
  57973. */
  57974. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57975. /**
  57976. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57977. * @param value1 defines first vector
  57978. * @param value2 defines second vector
  57979. * @returns a new Vector2
  57980. */
  57981. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57982. /**
  57983. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57984. * @param p defines the middle point
  57985. * @param segA defines one point of the segment
  57986. * @param segB defines the other point of the segment
  57987. * @returns the shortest distance
  57988. */
  57989. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57990. }
  57991. /**
  57992. * Classed used to store (x,y,z) vector representation
  57993. * A Vector3 is the main object used in 3D geometry
  57994. * It can represent etiher the coordinates of a point the space, either a direction
  57995. * Reminder: js uses a left handed forward facing system
  57996. */
  57997. export class Vector3 {
  57998. /**
  57999. * Defines the first coordinates (on X axis)
  58000. */
  58001. x: number;
  58002. /**
  58003. * Defines the second coordinates (on Y axis)
  58004. */
  58005. y: number;
  58006. /**
  58007. * Defines the third coordinates (on Z axis)
  58008. */
  58009. z: number;
  58010. private static _UpReadOnly;
  58011. /**
  58012. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58013. * @param x defines the first coordinates (on X axis)
  58014. * @param y defines the second coordinates (on Y axis)
  58015. * @param z defines the third coordinates (on Z axis)
  58016. */
  58017. constructor(
  58018. /**
  58019. * Defines the first coordinates (on X axis)
  58020. */
  58021. x?: number,
  58022. /**
  58023. * Defines the second coordinates (on Y axis)
  58024. */
  58025. y?: number,
  58026. /**
  58027. * Defines the third coordinates (on Z axis)
  58028. */
  58029. z?: number);
  58030. /**
  58031. * Creates a string representation of the Vector3
  58032. * @returns a string with the Vector3 coordinates.
  58033. */
  58034. toString(): string;
  58035. /**
  58036. * Gets the class name
  58037. * @returns the string "Vector3"
  58038. */
  58039. getClassName(): string;
  58040. /**
  58041. * Creates the Vector3 hash code
  58042. * @returns a number which tends to be unique between Vector3 instances
  58043. */
  58044. getHashCode(): number;
  58045. /**
  58046. * Creates an array containing three elements : the coordinates of the Vector3
  58047. * @returns a new array of numbers
  58048. */
  58049. asArray(): number[];
  58050. /**
  58051. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58052. * @param array defines the destination array
  58053. * @param index defines the offset in the destination array
  58054. * @returns the current Vector3
  58055. */
  58056. toArray(array: FloatArray, index?: number): Vector3;
  58057. /**
  58058. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58059. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58060. */
  58061. toQuaternion(): Quaternion;
  58062. /**
  58063. * Adds the given vector to the current Vector3
  58064. * @param otherVector defines the second operand
  58065. * @returns the current updated Vector3
  58066. */
  58067. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58068. /**
  58069. * Adds the given coordinates to the current Vector3
  58070. * @param x defines the x coordinate of the operand
  58071. * @param y defines the y coordinate of the operand
  58072. * @param z defines the z coordinate of the operand
  58073. * @returns the current updated Vector3
  58074. */
  58075. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58076. /**
  58077. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58078. * @param otherVector defines the second operand
  58079. * @returns the resulting Vector3
  58080. */
  58081. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58082. /**
  58083. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58084. * @param otherVector defines the second operand
  58085. * @param result defines the Vector3 object where to store the result
  58086. * @returns the current Vector3
  58087. */
  58088. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58089. /**
  58090. * Subtract the given vector from the current Vector3
  58091. * @param otherVector defines the second operand
  58092. * @returns the current updated Vector3
  58093. */
  58094. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58095. /**
  58096. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58097. * @param otherVector defines the second operand
  58098. * @returns the resulting Vector3
  58099. */
  58100. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58101. /**
  58102. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58103. * @param otherVector defines the second operand
  58104. * @param result defines the Vector3 object where to store the result
  58105. * @returns the current Vector3
  58106. */
  58107. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58108. /**
  58109. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58110. * @param x defines the x coordinate of the operand
  58111. * @param y defines the y coordinate of the operand
  58112. * @param z defines the z coordinate of the operand
  58113. * @returns the resulting Vector3
  58114. */
  58115. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58116. /**
  58117. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58118. * @param x defines the x coordinate of the operand
  58119. * @param y defines the y coordinate of the operand
  58120. * @param z defines the z coordinate of the operand
  58121. * @param result defines the Vector3 object where to store the result
  58122. * @returns the current Vector3
  58123. */
  58124. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58125. /**
  58126. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58127. * @returns a new Vector3
  58128. */
  58129. negate(): Vector3;
  58130. /**
  58131. * Multiplies the Vector3 coordinates by the float "scale"
  58132. * @param scale defines the multiplier factor
  58133. * @returns the current updated Vector3
  58134. */
  58135. scaleInPlace(scale: number): Vector3;
  58136. /**
  58137. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58138. * @param scale defines the multiplier factor
  58139. * @returns a new Vector3
  58140. */
  58141. scale(scale: number): Vector3;
  58142. /**
  58143. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58144. * @param scale defines the multiplier factor
  58145. * @param result defines the Vector3 object where to store the result
  58146. * @returns the current Vector3
  58147. */
  58148. scaleToRef(scale: number, result: Vector3): Vector3;
  58149. /**
  58150. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58151. * @param scale defines the scale factor
  58152. * @param result defines the Vector3 object where to store the result
  58153. * @returns the unmodified current Vector3
  58154. */
  58155. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58156. /**
  58157. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58158. * @param otherVector defines the second operand
  58159. * @returns true if both vectors are equals
  58160. */
  58161. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58162. /**
  58163. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58164. * @param otherVector defines the second operand
  58165. * @param epsilon defines the minimal distance to define values as equals
  58166. * @returns true if both vectors are distant less than epsilon
  58167. */
  58168. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58169. /**
  58170. * Returns true if the current Vector3 coordinates equals the given floats
  58171. * @param x defines the x coordinate of the operand
  58172. * @param y defines the y coordinate of the operand
  58173. * @param z defines the z coordinate of the operand
  58174. * @returns true if both vectors are equals
  58175. */
  58176. equalsToFloats(x: number, y: number, z: number): boolean;
  58177. /**
  58178. * Multiplies the current Vector3 coordinates by the given ones
  58179. * @param otherVector defines the second operand
  58180. * @returns the current updated Vector3
  58181. */
  58182. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58183. /**
  58184. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58185. * @param otherVector defines the second operand
  58186. * @returns the new Vector3
  58187. */
  58188. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58189. /**
  58190. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58191. * @param otherVector defines the second operand
  58192. * @param result defines the Vector3 object where to store the result
  58193. * @returns the current Vector3
  58194. */
  58195. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58196. /**
  58197. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58198. * @param x defines the x coordinate of the operand
  58199. * @param y defines the y coordinate of the operand
  58200. * @param z defines the z coordinate of the operand
  58201. * @returns the new Vector3
  58202. */
  58203. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58204. /**
  58205. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58206. * @param otherVector defines the second operand
  58207. * @returns the new Vector3
  58208. */
  58209. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58210. /**
  58211. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58212. * @param otherVector defines the second operand
  58213. * @param result defines the Vector3 object where to store the result
  58214. * @returns the current Vector3
  58215. */
  58216. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58217. /**
  58218. * Divides the current Vector3 coordinates by the given ones.
  58219. * @param otherVector defines the second operand
  58220. * @returns the current updated Vector3
  58221. */
  58222. divideInPlace(otherVector: Vector3): Vector3;
  58223. /**
  58224. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58225. * @param other defines the second operand
  58226. * @returns the current updated Vector3
  58227. */
  58228. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58229. /**
  58230. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58231. * @param other defines the second operand
  58232. * @returns the current updated Vector3
  58233. */
  58234. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58235. /**
  58236. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58237. * @param x defines the x coordinate of the operand
  58238. * @param y defines the y coordinate of the operand
  58239. * @param z defines the z coordinate of the operand
  58240. * @returns the current updated Vector3
  58241. */
  58242. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58243. /**
  58244. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58245. * @param x defines the x coordinate of the operand
  58246. * @param y defines the y coordinate of the operand
  58247. * @param z defines the z coordinate of the operand
  58248. * @returns the current updated Vector3
  58249. */
  58250. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58251. /**
  58252. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58253. * Check if is non uniform within a certain amount of decimal places to account for this
  58254. * @param epsilon the amount the values can differ
  58255. * @returns if the the vector is non uniform to a certain number of decimal places
  58256. */
  58257. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58258. /**
  58259. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58260. */
  58261. readonly isNonUniform: boolean;
  58262. /**
  58263. * Gets a new Vector3 from current Vector3 floored values
  58264. * @returns a new Vector3
  58265. */
  58266. floor(): Vector3;
  58267. /**
  58268. * Gets a new Vector3 from current Vector3 floored values
  58269. * @returns a new Vector3
  58270. */
  58271. fract(): Vector3;
  58272. /**
  58273. * Gets the length of the Vector3
  58274. * @returns the length of the Vecto3
  58275. */
  58276. length(): number;
  58277. /**
  58278. * Gets the squared length of the Vector3
  58279. * @returns squared length of the Vector3
  58280. */
  58281. lengthSquared(): number;
  58282. /**
  58283. * Normalize the current Vector3.
  58284. * Please note that this is an in place operation.
  58285. * @returns the current updated Vector3
  58286. */
  58287. normalize(): Vector3;
  58288. /**
  58289. * Reorders the x y z properties of the vector in place
  58290. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58291. * @returns the current updated vector
  58292. */
  58293. reorderInPlace(order: string): this;
  58294. /**
  58295. * Rotates the vector around 0,0,0 by a quaternion
  58296. * @param quaternion the rotation quaternion
  58297. * @param result vector to store the result
  58298. * @returns the resulting vector
  58299. */
  58300. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58301. /**
  58302. * Rotates a vector around a given point
  58303. * @param quaternion the rotation quaternion
  58304. * @param point the point to rotate around
  58305. * @param result vector to store the result
  58306. * @returns the resulting vector
  58307. */
  58308. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58309. /**
  58310. * Normalize the current Vector3 with the given input length.
  58311. * Please note that this is an in place operation.
  58312. * @param len the length of the vector
  58313. * @returns the current updated Vector3
  58314. */
  58315. normalizeFromLength(len: number): Vector3;
  58316. /**
  58317. * Normalize the current Vector3 to a new vector
  58318. * @returns the new Vector3
  58319. */
  58320. normalizeToNew(): Vector3;
  58321. /**
  58322. * Normalize the current Vector3 to the reference
  58323. * @param reference define the Vector3 to update
  58324. * @returns the updated Vector3
  58325. */
  58326. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58327. /**
  58328. * Creates a new Vector3 copied from the current Vector3
  58329. * @returns the new Vector3
  58330. */
  58331. clone(): Vector3;
  58332. /**
  58333. * Copies the given vector coordinates to the current Vector3 ones
  58334. * @param source defines the source Vector3
  58335. * @returns the current updated Vector3
  58336. */
  58337. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58338. /**
  58339. * Copies the given floats to the current Vector3 coordinates
  58340. * @param x defines the x coordinate of the operand
  58341. * @param y defines the y coordinate of the operand
  58342. * @param z defines the z coordinate of the operand
  58343. * @returns the current updated Vector3
  58344. */
  58345. copyFromFloats(x: number, y: number, z: number): Vector3;
  58346. /**
  58347. * Copies the given floats to the current Vector3 coordinates
  58348. * @param x defines the x coordinate of the operand
  58349. * @param y defines the y coordinate of the operand
  58350. * @param z defines the z coordinate of the operand
  58351. * @returns the current updated Vector3
  58352. */
  58353. set(x: number, y: number, z: number): Vector3;
  58354. /**
  58355. * Copies the given float to the current Vector3 coordinates
  58356. * @param v defines the x, y and z coordinates of the operand
  58357. * @returns the current updated Vector3
  58358. */
  58359. setAll(v: number): Vector3;
  58360. /**
  58361. * Get the clip factor between two vectors
  58362. * @param vector0 defines the first operand
  58363. * @param vector1 defines the second operand
  58364. * @param axis defines the axis to use
  58365. * @param size defines the size along the axis
  58366. * @returns the clip factor
  58367. */
  58368. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58369. /**
  58370. * Get angle between two vectors
  58371. * @param vector0 angle between vector0 and vector1
  58372. * @param vector1 angle between vector0 and vector1
  58373. * @param normal direction of the normal
  58374. * @return the angle between vector0 and vector1
  58375. */
  58376. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58377. /**
  58378. * Returns a new Vector3 set from the index "offset" of the given array
  58379. * @param array defines the source array
  58380. * @param offset defines the offset in the source array
  58381. * @returns the new Vector3
  58382. */
  58383. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58384. /**
  58385. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58386. * This function is deprecated. Use FromArray instead
  58387. * @param array defines the source array
  58388. * @param offset defines the offset in the source array
  58389. * @returns the new Vector3
  58390. */
  58391. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58392. /**
  58393. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58394. * @param array defines the source array
  58395. * @param offset defines the offset in the source array
  58396. * @param result defines the Vector3 where to store the result
  58397. */
  58398. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58399. /**
  58400. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58401. * This function is deprecated. Use FromArrayToRef instead.
  58402. * @param array defines the source array
  58403. * @param offset defines the offset in the source array
  58404. * @param result defines the Vector3 where to store the result
  58405. */
  58406. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58407. /**
  58408. * Sets the given vector "result" with the given floats.
  58409. * @param x defines the x coordinate of the source
  58410. * @param y defines the y coordinate of the source
  58411. * @param z defines the z coordinate of the source
  58412. * @param result defines the Vector3 where to store the result
  58413. */
  58414. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58415. /**
  58416. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58417. * @returns a new empty Vector3
  58418. */
  58419. static Zero(): Vector3;
  58420. /**
  58421. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58422. * @returns a new unit Vector3
  58423. */
  58424. static One(): Vector3;
  58425. /**
  58426. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58427. * @returns a new up Vector3
  58428. */
  58429. static Up(): Vector3;
  58430. /**
  58431. * Gets a up Vector3 that must not be updated
  58432. */
  58433. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58434. /**
  58435. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58436. * @returns a new down Vector3
  58437. */
  58438. static Down(): Vector3;
  58439. /**
  58440. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58441. * @returns a new forward Vector3
  58442. */
  58443. static Forward(): Vector3;
  58444. /**
  58445. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58446. * @returns a new forward Vector3
  58447. */
  58448. static Backward(): Vector3;
  58449. /**
  58450. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58451. * @returns a new right Vector3
  58452. */
  58453. static Right(): Vector3;
  58454. /**
  58455. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58456. * @returns a new left Vector3
  58457. */
  58458. static Left(): Vector3;
  58459. /**
  58460. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58461. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58462. * @param vector defines the Vector3 to transform
  58463. * @param transformation defines the transformation matrix
  58464. * @returns the transformed Vector3
  58465. */
  58466. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58467. /**
  58468. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58469. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58470. * @param vector defines the Vector3 to transform
  58471. * @param transformation defines the transformation matrix
  58472. * @param result defines the Vector3 where to store the result
  58473. */
  58474. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58475. /**
  58476. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58477. * This method computes tranformed coordinates only, not transformed direction vectors
  58478. * @param x define the x coordinate of the source vector
  58479. * @param y define the y coordinate of the source vector
  58480. * @param z define the z coordinate of the source vector
  58481. * @param transformation defines the transformation matrix
  58482. * @param result defines the Vector3 where to store the result
  58483. */
  58484. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58485. /**
  58486. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58487. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58488. * @param vector defines the Vector3 to transform
  58489. * @param transformation defines the transformation matrix
  58490. * @returns the new Vector3
  58491. */
  58492. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58493. /**
  58494. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58495. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58496. * @param vector defines the Vector3 to transform
  58497. * @param transformation defines the transformation matrix
  58498. * @param result defines the Vector3 where to store the result
  58499. */
  58500. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58501. /**
  58502. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58503. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58504. * @param x define the x coordinate of the source vector
  58505. * @param y define the y coordinate of the source vector
  58506. * @param z define the z coordinate of the source vector
  58507. * @param transformation defines the transformation matrix
  58508. * @param result defines the Vector3 where to store the result
  58509. */
  58510. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58511. /**
  58512. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58513. * @param value1 defines the first control point
  58514. * @param value2 defines the second control point
  58515. * @param value3 defines the third control point
  58516. * @param value4 defines the fourth control point
  58517. * @param amount defines the amount on the spline to use
  58518. * @returns the new Vector3
  58519. */
  58520. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58521. /**
  58522. * 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"
  58523. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58524. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58525. * @param value defines the current value
  58526. * @param min defines the lower range value
  58527. * @param max defines the upper range value
  58528. * @returns the new Vector3
  58529. */
  58530. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58531. /**
  58532. * 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"
  58533. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58534. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58535. * @param value defines the current value
  58536. * @param min defines the lower range value
  58537. * @param max defines the upper range value
  58538. * @param result defines the Vector3 where to store the result
  58539. */
  58540. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58541. /**
  58542. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58543. * @param value1 defines the first control point
  58544. * @param tangent1 defines the first tangent vector
  58545. * @param value2 defines the second control point
  58546. * @param tangent2 defines the second tangent vector
  58547. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58548. * @returns the new Vector3
  58549. */
  58550. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58551. /**
  58552. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58553. * @param start defines the start value
  58554. * @param end defines the end value
  58555. * @param amount max defines amount between both (between 0 and 1)
  58556. * @returns the new Vector3
  58557. */
  58558. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58559. /**
  58560. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58561. * @param start defines the start value
  58562. * @param end defines the end value
  58563. * @param amount max defines amount between both (between 0 and 1)
  58564. * @param result defines the Vector3 where to store the result
  58565. */
  58566. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58567. /**
  58568. * Returns the dot product (float) between the vectors "left" and "right"
  58569. * @param left defines the left operand
  58570. * @param right defines the right operand
  58571. * @returns the dot product
  58572. */
  58573. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58574. /**
  58575. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58576. * The cross product is then orthogonal to both "left" and "right"
  58577. * @param left defines the left operand
  58578. * @param right defines the right operand
  58579. * @returns the cross product
  58580. */
  58581. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58582. /**
  58583. * Sets the given vector "result" with the cross product of "left" and "right"
  58584. * The cross product is then orthogonal to both "left" and "right"
  58585. * @param left defines the left operand
  58586. * @param right defines the right operand
  58587. * @param result defines the Vector3 where to store the result
  58588. */
  58589. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58590. /**
  58591. * Returns a new Vector3 as the normalization of the given vector
  58592. * @param vector defines the Vector3 to normalize
  58593. * @returns the new Vector3
  58594. */
  58595. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58596. /**
  58597. * Sets the given vector "result" with the normalization of the given first vector
  58598. * @param vector defines the Vector3 to normalize
  58599. * @param result defines the Vector3 where to store the result
  58600. */
  58601. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58602. /**
  58603. * Project a Vector3 onto screen space
  58604. * @param vector defines the Vector3 to project
  58605. * @param world defines the world matrix to use
  58606. * @param transform defines the transform (view x projection) matrix to use
  58607. * @param viewport defines the screen viewport to use
  58608. * @returns the new Vector3
  58609. */
  58610. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58611. /** @hidden */
  58612. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58613. /**
  58614. * Unproject from screen space to object space
  58615. * @param source defines the screen space Vector3 to use
  58616. * @param viewportWidth defines the current width of the viewport
  58617. * @param viewportHeight defines the current height of the viewport
  58618. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58619. * @param transform defines the transform (view x projection) matrix to use
  58620. * @returns the new Vector3
  58621. */
  58622. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58623. /**
  58624. * Unproject from screen space to object space
  58625. * @param source defines the screen space Vector3 to use
  58626. * @param viewportWidth defines the current width of the viewport
  58627. * @param viewportHeight defines the current height of the viewport
  58628. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58629. * @param view defines the view matrix to use
  58630. * @param projection defines the projection matrix to use
  58631. * @returns the new Vector3
  58632. */
  58633. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58634. /**
  58635. * Unproject from screen space to object space
  58636. * @param source defines the screen space Vector3 to use
  58637. * @param viewportWidth defines the current width of the viewport
  58638. * @param viewportHeight defines the current height of the viewport
  58639. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58640. * @param view defines the view matrix to use
  58641. * @param projection defines the projection matrix to use
  58642. * @param result defines the Vector3 where to store the result
  58643. */
  58644. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58645. /**
  58646. * Unproject from screen space to object space
  58647. * @param sourceX defines the screen space x coordinate to use
  58648. * @param sourceY defines the screen space y coordinate to use
  58649. * @param sourceZ defines the screen space z coordinate to use
  58650. * @param viewportWidth defines the current width of the viewport
  58651. * @param viewportHeight defines the current height of the viewport
  58652. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58653. * @param view defines the view matrix to use
  58654. * @param projection defines the projection matrix to use
  58655. * @param result defines the Vector3 where to store the result
  58656. */
  58657. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58658. /**
  58659. * Gets the minimal coordinate values between two Vector3
  58660. * @param left defines the first operand
  58661. * @param right defines the second operand
  58662. * @returns the new Vector3
  58663. */
  58664. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58665. /**
  58666. * Gets the maximal coordinate values between two Vector3
  58667. * @param left defines the first operand
  58668. * @param right defines the second operand
  58669. * @returns the new Vector3
  58670. */
  58671. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58672. /**
  58673. * Returns the distance between the vectors "value1" and "value2"
  58674. * @param value1 defines the first operand
  58675. * @param value2 defines the second operand
  58676. * @returns the distance
  58677. */
  58678. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58679. /**
  58680. * Returns the squared distance between the vectors "value1" and "value2"
  58681. * @param value1 defines the first operand
  58682. * @param value2 defines the second operand
  58683. * @returns the squared distance
  58684. */
  58685. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58686. /**
  58687. * Returns a new Vector3 located at the center between "value1" and "value2"
  58688. * @param value1 defines the first operand
  58689. * @param value2 defines the second operand
  58690. * @returns the new Vector3
  58691. */
  58692. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58693. /**
  58694. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58695. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58696. * to something in order to rotate it from its local system to the given target system
  58697. * Note: axis1, axis2 and axis3 are normalized during this operation
  58698. * @param axis1 defines the first axis
  58699. * @param axis2 defines the second axis
  58700. * @param axis3 defines the third axis
  58701. * @returns a new Vector3
  58702. */
  58703. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58704. /**
  58705. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58706. * @param axis1 defines the first axis
  58707. * @param axis2 defines the second axis
  58708. * @param axis3 defines the third axis
  58709. * @param ref defines the Vector3 where to store the result
  58710. */
  58711. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58712. }
  58713. /**
  58714. * Vector4 class created for EulerAngle class conversion to Quaternion
  58715. */
  58716. export class Vector4 {
  58717. /** x value of the vector */
  58718. x: number;
  58719. /** y value of the vector */
  58720. y: number;
  58721. /** z value of the vector */
  58722. z: number;
  58723. /** w value of the vector */
  58724. w: number;
  58725. /**
  58726. * Creates a Vector4 object from the given floats.
  58727. * @param x x value of the vector
  58728. * @param y y value of the vector
  58729. * @param z z value of the vector
  58730. * @param w w value of the vector
  58731. */
  58732. constructor(
  58733. /** x value of the vector */
  58734. x: number,
  58735. /** y value of the vector */
  58736. y: number,
  58737. /** z value of the vector */
  58738. z: number,
  58739. /** w value of the vector */
  58740. w: number);
  58741. /**
  58742. * Returns the string with the Vector4 coordinates.
  58743. * @returns a string containing all the vector values
  58744. */
  58745. toString(): string;
  58746. /**
  58747. * Returns the string "Vector4".
  58748. * @returns "Vector4"
  58749. */
  58750. getClassName(): string;
  58751. /**
  58752. * Returns the Vector4 hash code.
  58753. * @returns a unique hash code
  58754. */
  58755. getHashCode(): number;
  58756. /**
  58757. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58758. * @returns the resulting array
  58759. */
  58760. asArray(): number[];
  58761. /**
  58762. * Populates the given array from the given index with the Vector4 coordinates.
  58763. * @param array array to populate
  58764. * @param index index of the array to start at (default: 0)
  58765. * @returns the Vector4.
  58766. */
  58767. toArray(array: FloatArray, index?: number): Vector4;
  58768. /**
  58769. * Adds the given vector to the current Vector4.
  58770. * @param otherVector the vector to add
  58771. * @returns the updated Vector4.
  58772. */
  58773. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58774. /**
  58775. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58776. * @param otherVector the vector to add
  58777. * @returns the resulting vector
  58778. */
  58779. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58780. /**
  58781. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58782. * @param otherVector the vector to add
  58783. * @param result the vector to store the result
  58784. * @returns the current Vector4.
  58785. */
  58786. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58787. /**
  58788. * Subtract in place the given vector from the current Vector4.
  58789. * @param otherVector the vector to subtract
  58790. * @returns the updated Vector4.
  58791. */
  58792. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58793. /**
  58794. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58795. * @param otherVector the vector to add
  58796. * @returns the new vector with the result
  58797. */
  58798. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58799. /**
  58800. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58801. * @param otherVector the vector to subtract
  58802. * @param result the vector to store the result
  58803. * @returns the current Vector4.
  58804. */
  58805. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58806. /**
  58807. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58808. */
  58809. /**
  58810. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58811. * @param x value to subtract
  58812. * @param y value to subtract
  58813. * @param z value to subtract
  58814. * @param w value to subtract
  58815. * @returns new vector containing the result
  58816. */
  58817. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58818. /**
  58819. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58820. * @param x value to subtract
  58821. * @param y value to subtract
  58822. * @param z value to subtract
  58823. * @param w value to subtract
  58824. * @param result the vector to store the result in
  58825. * @returns the current Vector4.
  58826. */
  58827. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58828. /**
  58829. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58830. * @returns a new vector with the negated values
  58831. */
  58832. negate(): Vector4;
  58833. /**
  58834. * Multiplies the current Vector4 coordinates by scale (float).
  58835. * @param scale the number to scale with
  58836. * @returns the updated Vector4.
  58837. */
  58838. scaleInPlace(scale: number): Vector4;
  58839. /**
  58840. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58841. * @param scale the number to scale with
  58842. * @returns a new vector with the result
  58843. */
  58844. scale(scale: number): Vector4;
  58845. /**
  58846. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58847. * @param scale the number to scale with
  58848. * @param result a vector to store the result in
  58849. * @returns the current Vector4.
  58850. */
  58851. scaleToRef(scale: number, result: Vector4): Vector4;
  58852. /**
  58853. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58854. * @param scale defines the scale factor
  58855. * @param result defines the Vector4 object where to store the result
  58856. * @returns the unmodified current Vector4
  58857. */
  58858. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58859. /**
  58860. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58861. * @param otherVector the vector to compare against
  58862. * @returns true if they are equal
  58863. */
  58864. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58865. /**
  58866. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58867. * @param otherVector vector to compare against
  58868. * @param epsilon (Default: very small number)
  58869. * @returns true if they are equal
  58870. */
  58871. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58872. /**
  58873. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58874. * @param x x value to compare against
  58875. * @param y y value to compare against
  58876. * @param z z value to compare against
  58877. * @param w w value to compare against
  58878. * @returns true if equal
  58879. */
  58880. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58881. /**
  58882. * Multiplies in place the current Vector4 by the given one.
  58883. * @param otherVector vector to multiple with
  58884. * @returns the updated Vector4.
  58885. */
  58886. multiplyInPlace(otherVector: Vector4): Vector4;
  58887. /**
  58888. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58889. * @param otherVector vector to multiple with
  58890. * @returns resulting new vector
  58891. */
  58892. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58893. /**
  58894. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58895. * @param otherVector vector to multiple with
  58896. * @param result vector to store the result
  58897. * @returns the current Vector4.
  58898. */
  58899. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58900. /**
  58901. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58902. * @param x x value multiply with
  58903. * @param y y value multiply with
  58904. * @param z z value multiply with
  58905. * @param w w value multiply with
  58906. * @returns resulting new vector
  58907. */
  58908. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58909. /**
  58910. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58911. * @param otherVector vector to devide with
  58912. * @returns resulting new vector
  58913. */
  58914. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58915. /**
  58916. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58917. * @param otherVector vector to devide with
  58918. * @param result vector to store the result
  58919. * @returns the current Vector4.
  58920. */
  58921. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58922. /**
  58923. * Divides the current Vector3 coordinates by the given ones.
  58924. * @param otherVector vector to devide with
  58925. * @returns the updated Vector3.
  58926. */
  58927. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58928. /**
  58929. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58930. * @param other defines the second operand
  58931. * @returns the current updated Vector4
  58932. */
  58933. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58934. /**
  58935. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58936. * @param other defines the second operand
  58937. * @returns the current updated Vector4
  58938. */
  58939. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58940. /**
  58941. * Gets a new Vector4 from current Vector4 floored values
  58942. * @returns a new Vector4
  58943. */
  58944. floor(): Vector4;
  58945. /**
  58946. * Gets a new Vector4 from current Vector3 floored values
  58947. * @returns a new Vector4
  58948. */
  58949. fract(): Vector4;
  58950. /**
  58951. * Returns the Vector4 length (float).
  58952. * @returns the length
  58953. */
  58954. length(): number;
  58955. /**
  58956. * Returns the Vector4 squared length (float).
  58957. * @returns the length squared
  58958. */
  58959. lengthSquared(): number;
  58960. /**
  58961. * Normalizes in place the Vector4.
  58962. * @returns the updated Vector4.
  58963. */
  58964. normalize(): Vector4;
  58965. /**
  58966. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58967. * @returns this converted to a new vector3
  58968. */
  58969. toVector3(): Vector3;
  58970. /**
  58971. * Returns a new Vector4 copied from the current one.
  58972. * @returns the new cloned vector
  58973. */
  58974. clone(): Vector4;
  58975. /**
  58976. * Updates the current Vector4 with the given one coordinates.
  58977. * @param source the source vector to copy from
  58978. * @returns the updated Vector4.
  58979. */
  58980. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58981. /**
  58982. * Updates the current Vector4 coordinates with the given floats.
  58983. * @param x float to copy from
  58984. * @param y float to copy from
  58985. * @param z float to copy from
  58986. * @param w float to copy from
  58987. * @returns the updated Vector4.
  58988. */
  58989. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58990. /**
  58991. * Updates the current Vector4 coordinates with the given floats.
  58992. * @param x float to set from
  58993. * @param y float to set from
  58994. * @param z float to set from
  58995. * @param w float to set from
  58996. * @returns the updated Vector4.
  58997. */
  58998. set(x: number, y: number, z: number, w: number): Vector4;
  58999. /**
  59000. * Copies the given float to the current Vector3 coordinates
  59001. * @param v defines the x, y, z and w coordinates of the operand
  59002. * @returns the current updated Vector3
  59003. */
  59004. setAll(v: number): Vector4;
  59005. /**
  59006. * Returns a new Vector4 set from the starting index of the given array.
  59007. * @param array the array to pull values from
  59008. * @param offset the offset into the array to start at
  59009. * @returns the new vector
  59010. */
  59011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59012. /**
  59013. * Updates the given vector "result" from the starting index of the given array.
  59014. * @param array the array to pull values from
  59015. * @param offset the offset into the array to start at
  59016. * @param result the vector to store the result in
  59017. */
  59018. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59019. /**
  59020. * Updates the given vector "result" from the starting index of the given Float32Array.
  59021. * @param array the array to pull values from
  59022. * @param offset the offset into the array to start at
  59023. * @param result the vector to store the result in
  59024. */
  59025. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59026. /**
  59027. * Updates the given vector "result" coordinates from the given floats.
  59028. * @param x float to set from
  59029. * @param y float to set from
  59030. * @param z float to set from
  59031. * @param w float to set from
  59032. * @param result the vector to the floats in
  59033. */
  59034. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59035. /**
  59036. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59037. * @returns the new vector
  59038. */
  59039. static Zero(): Vector4;
  59040. /**
  59041. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59042. * @returns the new vector
  59043. */
  59044. static One(): Vector4;
  59045. /**
  59046. * Returns a new normalized Vector4 from the given one.
  59047. * @param vector the vector to normalize
  59048. * @returns the vector
  59049. */
  59050. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59051. /**
  59052. * Updates the given vector "result" from the normalization of the given one.
  59053. * @param vector the vector to normalize
  59054. * @param result the vector to store the result in
  59055. */
  59056. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59057. /**
  59058. * Returns a vector with the minimum values from the left and right vectors
  59059. * @param left left vector to minimize
  59060. * @param right right vector to minimize
  59061. * @returns a new vector with the minimum of the left and right vector values
  59062. */
  59063. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59064. /**
  59065. * Returns a vector with the maximum values from the left and right vectors
  59066. * @param left left vector to maximize
  59067. * @param right right vector to maximize
  59068. * @returns a new vector with the maximum of the left and right vector values
  59069. */
  59070. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59071. /**
  59072. * Returns the distance (float) between the vectors "value1" and "value2".
  59073. * @param value1 value to calulate the distance between
  59074. * @param value2 value to calulate the distance between
  59075. * @return the distance between the two vectors
  59076. */
  59077. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59078. /**
  59079. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59080. * @param value1 value to calulate the distance between
  59081. * @param value2 value to calulate the distance between
  59082. * @return the distance between the two vectors squared
  59083. */
  59084. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59085. /**
  59086. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59087. * @param value1 value to calulate the center between
  59088. * @param value2 value to calulate the center between
  59089. * @return the center between the two vectors
  59090. */
  59091. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59092. /**
  59093. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59094. * This methods computes transformed normalized direction vectors only.
  59095. * @param vector the vector to transform
  59096. * @param transformation the transformation matrix to apply
  59097. * @returns the new vector
  59098. */
  59099. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59100. /**
  59101. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59102. * This methods computes transformed normalized direction vectors only.
  59103. * @param vector the vector to transform
  59104. * @param transformation the transformation matrix to apply
  59105. * @param result the vector to store the result in
  59106. */
  59107. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59108. /**
  59109. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59110. * This methods computes transformed normalized direction vectors only.
  59111. * @param x value to transform
  59112. * @param y value to transform
  59113. * @param z value to transform
  59114. * @param w value to transform
  59115. * @param transformation the transformation matrix to apply
  59116. * @param result the vector to store the results in
  59117. */
  59118. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59119. /**
  59120. * Creates a new Vector4 from a Vector3
  59121. * @param source defines the source data
  59122. * @param w defines the 4th component (default is 0)
  59123. * @returns a new Vector4
  59124. */
  59125. static FromVector3(source: Vector3, w?: number): Vector4;
  59126. }
  59127. /**
  59128. * Interface for the size containing width and height
  59129. */
  59130. export interface ISize {
  59131. /**
  59132. * Width
  59133. */
  59134. width: number;
  59135. /**
  59136. * Heighht
  59137. */
  59138. height: number;
  59139. }
  59140. /**
  59141. * Size containing widht and height
  59142. */
  59143. export class Size implements ISize {
  59144. /**
  59145. * Width
  59146. */
  59147. width: number;
  59148. /**
  59149. * Height
  59150. */
  59151. height: number;
  59152. /**
  59153. * Creates a Size object from the given width and height (floats).
  59154. * @param width width of the new size
  59155. * @param height height of the new size
  59156. */
  59157. constructor(width: number, height: number);
  59158. /**
  59159. * Returns a string with the Size width and height
  59160. * @returns a string with the Size width and height
  59161. */
  59162. toString(): string;
  59163. /**
  59164. * "Size"
  59165. * @returns the string "Size"
  59166. */
  59167. getClassName(): string;
  59168. /**
  59169. * Returns the Size hash code.
  59170. * @returns a hash code for a unique width and height
  59171. */
  59172. getHashCode(): number;
  59173. /**
  59174. * Updates the current size from the given one.
  59175. * @param src the given size
  59176. */
  59177. copyFrom(src: Size): void;
  59178. /**
  59179. * Updates in place the current Size from the given floats.
  59180. * @param width width of the new size
  59181. * @param height height of the new size
  59182. * @returns the updated Size.
  59183. */
  59184. copyFromFloats(width: number, height: number): Size;
  59185. /**
  59186. * Updates in place the current Size from the given floats.
  59187. * @param width width to set
  59188. * @param height height to set
  59189. * @returns the updated Size.
  59190. */
  59191. set(width: number, height: number): Size;
  59192. /**
  59193. * Multiplies the width and height by numbers
  59194. * @param w factor to multiple the width by
  59195. * @param h factor to multiple the height by
  59196. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59197. */
  59198. multiplyByFloats(w: number, h: number): Size;
  59199. /**
  59200. * Clones the size
  59201. * @returns a new Size copied from the given one.
  59202. */
  59203. clone(): Size;
  59204. /**
  59205. * True if the current Size and the given one width and height are strictly equal.
  59206. * @param other the other size to compare against
  59207. * @returns True if the current Size and the given one width and height are strictly equal.
  59208. */
  59209. equals(other: Size): boolean;
  59210. /**
  59211. * The surface of the Size : width * height (float).
  59212. */
  59213. readonly surface: number;
  59214. /**
  59215. * Create a new size of zero
  59216. * @returns a new Size set to (0.0, 0.0)
  59217. */
  59218. static Zero(): Size;
  59219. /**
  59220. * Sums the width and height of two sizes
  59221. * @param otherSize size to add to this size
  59222. * @returns a new Size set as the addition result of the current Size and the given one.
  59223. */
  59224. add(otherSize: Size): Size;
  59225. /**
  59226. * Subtracts the width and height of two
  59227. * @param otherSize size to subtract to this size
  59228. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59229. */
  59230. subtract(otherSize: Size): Size;
  59231. /**
  59232. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59233. * @param start starting size to lerp between
  59234. * @param end end size to lerp between
  59235. * @param amount amount to lerp between the start and end values
  59236. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59237. */
  59238. static Lerp(start: Size, end: Size, amount: number): Size;
  59239. }
  59240. /**
  59241. * Class used to store quaternion data
  59242. * @see https://en.wikipedia.org/wiki/Quaternion
  59243. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59244. */
  59245. export class Quaternion {
  59246. /** defines the first component (0 by default) */
  59247. x: number;
  59248. /** defines the second component (0 by default) */
  59249. y: number;
  59250. /** defines the third component (0 by default) */
  59251. z: number;
  59252. /** defines the fourth component (1.0 by default) */
  59253. w: number;
  59254. /**
  59255. * Creates a new Quaternion from the given floats
  59256. * @param x defines the first component (0 by default)
  59257. * @param y defines the second component (0 by default)
  59258. * @param z defines the third component (0 by default)
  59259. * @param w defines the fourth component (1.0 by default)
  59260. */
  59261. constructor(
  59262. /** defines the first component (0 by default) */
  59263. x?: number,
  59264. /** defines the second component (0 by default) */
  59265. y?: number,
  59266. /** defines the third component (0 by default) */
  59267. z?: number,
  59268. /** defines the fourth component (1.0 by default) */
  59269. w?: number);
  59270. /**
  59271. * Gets a string representation for the current quaternion
  59272. * @returns a string with the Quaternion coordinates
  59273. */
  59274. toString(): string;
  59275. /**
  59276. * Gets the class name of the quaternion
  59277. * @returns the string "Quaternion"
  59278. */
  59279. getClassName(): string;
  59280. /**
  59281. * Gets a hash code for this quaternion
  59282. * @returns the quaternion hash code
  59283. */
  59284. getHashCode(): number;
  59285. /**
  59286. * Copy the quaternion to an array
  59287. * @returns a new array populated with 4 elements from the quaternion coordinates
  59288. */
  59289. asArray(): number[];
  59290. /**
  59291. * Check if two quaternions are equals
  59292. * @param otherQuaternion defines the second operand
  59293. * @return true if the current quaternion and the given one coordinates are strictly equals
  59294. */
  59295. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59296. /**
  59297. * Clone the current quaternion
  59298. * @returns a new quaternion copied from the current one
  59299. */
  59300. clone(): Quaternion;
  59301. /**
  59302. * Copy a quaternion to the current one
  59303. * @param other defines the other quaternion
  59304. * @returns the updated current quaternion
  59305. */
  59306. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59307. /**
  59308. * Updates the current quaternion with the given float coordinates
  59309. * @param x defines the x coordinate
  59310. * @param y defines the y coordinate
  59311. * @param z defines the z coordinate
  59312. * @param w defines the w coordinate
  59313. * @returns the updated current quaternion
  59314. */
  59315. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59316. /**
  59317. * Updates the current quaternion from the given float coordinates
  59318. * @param x defines the x coordinate
  59319. * @param y defines the y coordinate
  59320. * @param z defines the z coordinate
  59321. * @param w defines the w coordinate
  59322. * @returns the updated current quaternion
  59323. */
  59324. set(x: number, y: number, z: number, w: number): Quaternion;
  59325. /**
  59326. * Adds two quaternions
  59327. * @param other defines the second operand
  59328. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59329. */
  59330. add(other: DeepImmutable<Quaternion>): Quaternion;
  59331. /**
  59332. * Add a quaternion to the current one
  59333. * @param other defines the quaternion to add
  59334. * @returns the current quaternion
  59335. */
  59336. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59337. /**
  59338. * Subtract two quaternions
  59339. * @param other defines the second operand
  59340. * @returns a new quaternion as the subtraction result of the given one from the current one
  59341. */
  59342. subtract(other: Quaternion): Quaternion;
  59343. /**
  59344. * Multiplies the current quaternion by a scale factor
  59345. * @param value defines the scale factor
  59346. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59347. */
  59348. scale(value: number): Quaternion;
  59349. /**
  59350. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59351. * @param scale defines the scale factor
  59352. * @param result defines the Quaternion object where to store the result
  59353. * @returns the unmodified current quaternion
  59354. */
  59355. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59356. /**
  59357. * Multiplies in place the current quaternion by a scale factor
  59358. * @param value defines the scale factor
  59359. * @returns the current modified quaternion
  59360. */
  59361. scaleInPlace(value: number): Quaternion;
  59362. /**
  59363. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59364. * @param scale defines the scale factor
  59365. * @param result defines the Quaternion object where to store the result
  59366. * @returns the unmodified current quaternion
  59367. */
  59368. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59369. /**
  59370. * Multiplies two quaternions
  59371. * @param q1 defines the second operand
  59372. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59373. */
  59374. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59375. /**
  59376. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59377. * @param q1 defines the second operand
  59378. * @param result defines the target quaternion
  59379. * @returns the current quaternion
  59380. */
  59381. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59382. /**
  59383. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59384. * @param q1 defines the second operand
  59385. * @returns the currentupdated quaternion
  59386. */
  59387. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59388. /**
  59389. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59390. * @param ref defines the target quaternion
  59391. * @returns the current quaternion
  59392. */
  59393. conjugateToRef(ref: Quaternion): Quaternion;
  59394. /**
  59395. * Conjugates in place (1-q) the current quaternion
  59396. * @returns the current updated quaternion
  59397. */
  59398. conjugateInPlace(): Quaternion;
  59399. /**
  59400. * Conjugates in place (1-q) the current quaternion
  59401. * @returns a new quaternion
  59402. */
  59403. conjugate(): Quaternion;
  59404. /**
  59405. * Gets length of current quaternion
  59406. * @returns the quaternion length (float)
  59407. */
  59408. length(): number;
  59409. /**
  59410. * Normalize in place the current quaternion
  59411. * @returns the current updated quaternion
  59412. */
  59413. normalize(): Quaternion;
  59414. /**
  59415. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59416. * @param order is a reserved parameter and is ignore for now
  59417. * @returns a new Vector3 containing the Euler angles
  59418. */
  59419. toEulerAngles(order?: string): Vector3;
  59420. /**
  59421. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59422. * @param result defines the vector which will be filled with the Euler angles
  59423. * @param order is a reserved parameter and is ignore for now
  59424. * @returns the current unchanged quaternion
  59425. */
  59426. toEulerAnglesToRef(result: Vector3): Quaternion;
  59427. /**
  59428. * Updates the given rotation matrix with the current quaternion values
  59429. * @param result defines the target matrix
  59430. * @returns the current unchanged quaternion
  59431. */
  59432. toRotationMatrix(result: Matrix): Quaternion;
  59433. /**
  59434. * Updates the current quaternion from the given rotation matrix values
  59435. * @param matrix defines the source matrix
  59436. * @returns the current updated quaternion
  59437. */
  59438. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59439. /**
  59440. * Creates a new quaternion from a rotation matrix
  59441. * @param matrix defines the source matrix
  59442. * @returns a new quaternion created from the given rotation matrix values
  59443. */
  59444. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59445. /**
  59446. * Updates the given quaternion with the given rotation matrix values
  59447. * @param matrix defines the source matrix
  59448. * @param result defines the target quaternion
  59449. */
  59450. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59451. /**
  59452. * Returns the dot product (float) between the quaternions "left" and "right"
  59453. * @param left defines the left operand
  59454. * @param right defines the right operand
  59455. * @returns the dot product
  59456. */
  59457. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59458. /**
  59459. * Checks if the two quaternions are close to each other
  59460. * @param quat0 defines the first quaternion to check
  59461. * @param quat1 defines the second quaternion to check
  59462. * @returns true if the two quaternions are close to each other
  59463. */
  59464. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59465. /**
  59466. * Creates an empty quaternion
  59467. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59468. */
  59469. static Zero(): Quaternion;
  59470. /**
  59471. * Inverse a given quaternion
  59472. * @param q defines the source quaternion
  59473. * @returns a new quaternion as the inverted current quaternion
  59474. */
  59475. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59476. /**
  59477. * Inverse a given quaternion
  59478. * @param q defines the source quaternion
  59479. * @param result the quaternion the result will be stored in
  59480. * @returns the result quaternion
  59481. */
  59482. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59483. /**
  59484. * Creates an identity quaternion
  59485. * @returns the identity quaternion
  59486. */
  59487. static Identity(): Quaternion;
  59488. /**
  59489. * Gets a boolean indicating if the given quaternion is identity
  59490. * @param quaternion defines the quaternion to check
  59491. * @returns true if the quaternion is identity
  59492. */
  59493. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59494. /**
  59495. * Creates a quaternion from a rotation around an axis
  59496. * @param axis defines the axis to use
  59497. * @param angle defines the angle to use
  59498. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59499. */
  59500. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59501. /**
  59502. * Creates a rotation around an axis and stores it into the given quaternion
  59503. * @param axis defines the axis to use
  59504. * @param angle defines the angle to use
  59505. * @param result defines the target quaternion
  59506. * @returns the target quaternion
  59507. */
  59508. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59509. /**
  59510. * Creates a new quaternion from data stored into an array
  59511. * @param array defines the data source
  59512. * @param offset defines the offset in the source array where the data starts
  59513. * @returns a new quaternion
  59514. */
  59515. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59516. /**
  59517. * Create a quaternion from Euler rotation angles
  59518. * @param x Pitch
  59519. * @param y Yaw
  59520. * @param z Roll
  59521. * @returns the new Quaternion
  59522. */
  59523. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59524. /**
  59525. * Updates a quaternion from Euler rotation angles
  59526. * @param x Pitch
  59527. * @param y Yaw
  59528. * @param z Roll
  59529. * @param result the quaternion to store the result
  59530. * @returns the updated quaternion
  59531. */
  59532. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59533. /**
  59534. * Create a quaternion from Euler rotation vector
  59535. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59536. * @returns the new Quaternion
  59537. */
  59538. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59539. /**
  59540. * Updates a quaternion from Euler rotation vector
  59541. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59542. * @param result the quaternion to store the result
  59543. * @returns the updated quaternion
  59544. */
  59545. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59546. /**
  59547. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59548. * @param yaw defines the rotation around Y axis
  59549. * @param pitch defines the rotation around X axis
  59550. * @param roll defines the rotation around Z axis
  59551. * @returns the new quaternion
  59552. */
  59553. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59554. /**
  59555. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59556. * @param yaw defines the rotation around Y axis
  59557. * @param pitch defines the rotation around X axis
  59558. * @param roll defines the rotation around Z axis
  59559. * @param result defines the target quaternion
  59560. */
  59561. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59562. /**
  59563. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59564. * @param alpha defines the rotation around first axis
  59565. * @param beta defines the rotation around second axis
  59566. * @param gamma defines the rotation around third axis
  59567. * @returns the new quaternion
  59568. */
  59569. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59570. /**
  59571. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59572. * @param alpha defines the rotation around first axis
  59573. * @param beta defines the rotation around second axis
  59574. * @param gamma defines the rotation around third axis
  59575. * @param result defines the target quaternion
  59576. */
  59577. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59578. /**
  59579. * 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)
  59580. * @param axis1 defines the first axis
  59581. * @param axis2 defines the second axis
  59582. * @param axis3 defines the third axis
  59583. * @returns the new quaternion
  59584. */
  59585. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59586. /**
  59587. * 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
  59588. * @param axis1 defines the first axis
  59589. * @param axis2 defines the second axis
  59590. * @param axis3 defines the third axis
  59591. * @param ref defines the target quaternion
  59592. */
  59593. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59594. /**
  59595. * Interpolates between two quaternions
  59596. * @param left defines first quaternion
  59597. * @param right defines second quaternion
  59598. * @param amount defines the gradient to use
  59599. * @returns the new interpolated quaternion
  59600. */
  59601. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59602. /**
  59603. * Interpolates between two quaternions and stores it into a target quaternion
  59604. * @param left defines first quaternion
  59605. * @param right defines second quaternion
  59606. * @param amount defines the gradient to use
  59607. * @param result defines the target quaternion
  59608. */
  59609. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59610. /**
  59611. * Interpolate between two quaternions using Hermite interpolation
  59612. * @param value1 defines first quaternion
  59613. * @param tangent1 defines the incoming tangent
  59614. * @param value2 defines second quaternion
  59615. * @param tangent2 defines the outgoing tangent
  59616. * @param amount defines the target quaternion
  59617. * @returns the new interpolated quaternion
  59618. */
  59619. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59620. }
  59621. /**
  59622. * Class used to store matrix data (4x4)
  59623. */
  59624. export class Matrix {
  59625. private static _updateFlagSeed;
  59626. private static _identityReadOnly;
  59627. private _isIdentity;
  59628. private _isIdentityDirty;
  59629. private _isIdentity3x2;
  59630. private _isIdentity3x2Dirty;
  59631. /**
  59632. * Gets the update flag of the matrix which is an unique number for the matrix.
  59633. * It will be incremented every time the matrix data change.
  59634. * You can use it to speed the comparison between two versions of the same matrix.
  59635. */
  59636. updateFlag: number;
  59637. private readonly _m;
  59638. /**
  59639. * Gets the internal data of the matrix
  59640. */
  59641. readonly m: DeepImmutable<Float32Array>;
  59642. /** @hidden */
  59643. _markAsUpdated(): void;
  59644. /** @hidden */
  59645. private _updateIdentityStatus;
  59646. /**
  59647. * Creates an empty matrix (filled with zeros)
  59648. */
  59649. constructor();
  59650. /**
  59651. * Check if the current matrix is identity
  59652. * @returns true is the matrix is the identity matrix
  59653. */
  59654. isIdentity(): boolean;
  59655. /**
  59656. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59657. * @returns true is the matrix is the identity matrix
  59658. */
  59659. isIdentityAs3x2(): boolean;
  59660. /**
  59661. * Gets the determinant of the matrix
  59662. * @returns the matrix determinant
  59663. */
  59664. determinant(): number;
  59665. /**
  59666. * Returns the matrix as a Float32Array
  59667. * @returns the matrix underlying array
  59668. */
  59669. toArray(): DeepImmutable<Float32Array>;
  59670. /**
  59671. * Returns the matrix as a Float32Array
  59672. * @returns the matrix underlying array.
  59673. */
  59674. asArray(): DeepImmutable<Float32Array>;
  59675. /**
  59676. * Inverts the current matrix in place
  59677. * @returns the current inverted matrix
  59678. */
  59679. invert(): Matrix;
  59680. /**
  59681. * Sets all the matrix elements to zero
  59682. * @returns the current matrix
  59683. */
  59684. reset(): Matrix;
  59685. /**
  59686. * Adds the current matrix with a second one
  59687. * @param other defines the matrix to add
  59688. * @returns a new matrix as the addition of the current matrix and the given one
  59689. */
  59690. add(other: DeepImmutable<Matrix>): Matrix;
  59691. /**
  59692. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59693. * @param other defines the matrix to add
  59694. * @param result defines the target matrix
  59695. * @returns the current matrix
  59696. */
  59697. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59698. /**
  59699. * Adds in place the given matrix to the current matrix
  59700. * @param other defines the second operand
  59701. * @returns the current updated matrix
  59702. */
  59703. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59704. /**
  59705. * Sets the given matrix to the current inverted Matrix
  59706. * @param other defines the target matrix
  59707. * @returns the unmodified current matrix
  59708. */
  59709. invertToRef(other: Matrix): Matrix;
  59710. /**
  59711. * add a value at the specified position in the current Matrix
  59712. * @param index the index of the value within the matrix. between 0 and 15.
  59713. * @param value the value to be added
  59714. * @returns the current updated matrix
  59715. */
  59716. addAtIndex(index: number, value: number): Matrix;
  59717. /**
  59718. * mutiply the specified position in the current Matrix by a value
  59719. * @param index the index of the value within the matrix. between 0 and 15.
  59720. * @param value the value to be added
  59721. * @returns the current updated matrix
  59722. */
  59723. multiplyAtIndex(index: number, value: number): Matrix;
  59724. /**
  59725. * Inserts the translation vector (using 3 floats) in the current matrix
  59726. * @param x defines the 1st component of the translation
  59727. * @param y defines the 2nd component of the translation
  59728. * @param z defines the 3rd component of the translation
  59729. * @returns the current updated matrix
  59730. */
  59731. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59732. /**
  59733. * Inserts the translation vector in the current matrix
  59734. * @param vector3 defines the translation to insert
  59735. * @returns the current updated matrix
  59736. */
  59737. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59738. /**
  59739. * Gets the translation value of the current matrix
  59740. * @returns a new Vector3 as the extracted translation from the matrix
  59741. */
  59742. getTranslation(): Vector3;
  59743. /**
  59744. * Fill a Vector3 with the extracted translation from the matrix
  59745. * @param result defines the Vector3 where to store the translation
  59746. * @returns the current matrix
  59747. */
  59748. getTranslationToRef(result: Vector3): Matrix;
  59749. /**
  59750. * Remove rotation and scaling part from the matrix
  59751. * @returns the updated matrix
  59752. */
  59753. removeRotationAndScaling(): Matrix;
  59754. /**
  59755. * Multiply two matrices
  59756. * @param other defines the second operand
  59757. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59758. */
  59759. multiply(other: DeepImmutable<Matrix>): Matrix;
  59760. /**
  59761. * Copy the current matrix from the given one
  59762. * @param other defines the source matrix
  59763. * @returns the current updated matrix
  59764. */
  59765. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59766. /**
  59767. * Populates the given array from the starting index with the current matrix values
  59768. * @param array defines the target array
  59769. * @param offset defines the offset in the target array where to start storing values
  59770. * @returns the current matrix
  59771. */
  59772. copyToArray(array: Float32Array, offset?: number): Matrix;
  59773. /**
  59774. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59775. * @param other defines the second operand
  59776. * @param result defines the matrix where to store the multiplication
  59777. * @returns the current matrix
  59778. */
  59779. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59780. /**
  59781. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59782. * @param other defines the second operand
  59783. * @param result defines the array where to store the multiplication
  59784. * @param offset defines the offset in the target array where to start storing values
  59785. * @returns the current matrix
  59786. */
  59787. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59788. /**
  59789. * Check equality between this matrix and a second one
  59790. * @param value defines the second matrix to compare
  59791. * @returns true is the current matrix and the given one values are strictly equal
  59792. */
  59793. equals(value: DeepImmutable<Matrix>): boolean;
  59794. /**
  59795. * Clone the current matrix
  59796. * @returns a new matrix from the current matrix
  59797. */
  59798. clone(): Matrix;
  59799. /**
  59800. * Returns the name of the current matrix class
  59801. * @returns the string "Matrix"
  59802. */
  59803. getClassName(): string;
  59804. /**
  59805. * Gets the hash code of the current matrix
  59806. * @returns the hash code
  59807. */
  59808. getHashCode(): number;
  59809. /**
  59810. * Decomposes the current Matrix into a translation, rotation and scaling components
  59811. * @param scale defines the scale vector3 given as a reference to update
  59812. * @param rotation defines the rotation quaternion given as a reference to update
  59813. * @param translation defines the translation vector3 given as a reference to update
  59814. * @returns true if operation was successful
  59815. */
  59816. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59817. /**
  59818. * Gets specific row of the matrix
  59819. * @param index defines the number of the row to get
  59820. * @returns the index-th row of the current matrix as a new Vector4
  59821. */
  59822. getRow(index: number): Nullable<Vector4>;
  59823. /**
  59824. * Sets the index-th row of the current matrix to the vector4 values
  59825. * @param index defines the number of the row to set
  59826. * @param row defines the target vector4
  59827. * @returns the updated current matrix
  59828. */
  59829. setRow(index: number, row: Vector4): Matrix;
  59830. /**
  59831. * Compute the transpose of the matrix
  59832. * @returns the new transposed matrix
  59833. */
  59834. transpose(): Matrix;
  59835. /**
  59836. * Compute the transpose of the matrix and store it in a given matrix
  59837. * @param result defines the target matrix
  59838. * @returns the current matrix
  59839. */
  59840. transposeToRef(result: Matrix): Matrix;
  59841. /**
  59842. * Sets the index-th row of the current matrix with the given 4 x float values
  59843. * @param index defines the row index
  59844. * @param x defines the x component to set
  59845. * @param y defines the y component to set
  59846. * @param z defines the z component to set
  59847. * @param w defines the w component to set
  59848. * @returns the updated current matrix
  59849. */
  59850. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59851. /**
  59852. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59853. * @param scale defines the scale factor
  59854. * @returns a new matrix
  59855. */
  59856. scale(scale: number): Matrix;
  59857. /**
  59858. * Scale the current matrix values by a factor to a given result matrix
  59859. * @param scale defines the scale factor
  59860. * @param result defines the matrix to store the result
  59861. * @returns the current matrix
  59862. */
  59863. scaleToRef(scale: number, result: Matrix): Matrix;
  59864. /**
  59865. * Scale the current matrix values by a factor and add the result to a given matrix
  59866. * @param scale defines the scale factor
  59867. * @param result defines the Matrix to store the result
  59868. * @returns the current matrix
  59869. */
  59870. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59871. /**
  59872. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59873. * @param ref matrix to store the result
  59874. */
  59875. toNormalMatrix(ref: Matrix): void;
  59876. /**
  59877. * Gets only rotation part of the current matrix
  59878. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59879. */
  59880. getRotationMatrix(): Matrix;
  59881. /**
  59882. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59883. * @param result defines the target matrix to store data to
  59884. * @returns the current matrix
  59885. */
  59886. getRotationMatrixToRef(result: Matrix): Matrix;
  59887. /**
  59888. * Toggles model matrix from being right handed to left handed in place and vice versa
  59889. */
  59890. toggleModelMatrixHandInPlace(): void;
  59891. /**
  59892. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59893. */
  59894. toggleProjectionMatrixHandInPlace(): void;
  59895. /**
  59896. * Creates a matrix from an array
  59897. * @param array defines the source array
  59898. * @param offset defines an offset in the source array
  59899. * @returns a new Matrix set from the starting index of the given array
  59900. */
  59901. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59902. /**
  59903. * Copy the content of an array into a given matrix
  59904. * @param array defines the source array
  59905. * @param offset defines an offset in the source array
  59906. * @param result defines the target matrix
  59907. */
  59908. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59909. /**
  59910. * Stores an array into a matrix after having multiplied each component by a given factor
  59911. * @param array defines the source array
  59912. * @param offset defines the offset in the source array
  59913. * @param scale defines the scaling factor
  59914. * @param result defines the target matrix
  59915. */
  59916. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59917. /**
  59918. * Gets an identity matrix that must not be updated
  59919. */
  59920. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59921. /**
  59922. * Stores a list of values (16) inside a given matrix
  59923. * @param initialM11 defines 1st value of 1st row
  59924. * @param initialM12 defines 2nd value of 1st row
  59925. * @param initialM13 defines 3rd value of 1st row
  59926. * @param initialM14 defines 4th value of 1st row
  59927. * @param initialM21 defines 1st value of 2nd row
  59928. * @param initialM22 defines 2nd value of 2nd row
  59929. * @param initialM23 defines 3rd value of 2nd row
  59930. * @param initialM24 defines 4th value of 2nd row
  59931. * @param initialM31 defines 1st value of 3rd row
  59932. * @param initialM32 defines 2nd value of 3rd row
  59933. * @param initialM33 defines 3rd value of 3rd row
  59934. * @param initialM34 defines 4th value of 3rd row
  59935. * @param initialM41 defines 1st value of 4th row
  59936. * @param initialM42 defines 2nd value of 4th row
  59937. * @param initialM43 defines 3rd value of 4th row
  59938. * @param initialM44 defines 4th value of 4th row
  59939. * @param result defines the target matrix
  59940. */
  59941. 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;
  59942. /**
  59943. * Creates new matrix from a list of values (16)
  59944. * @param initialM11 defines 1st value of 1st row
  59945. * @param initialM12 defines 2nd value of 1st row
  59946. * @param initialM13 defines 3rd value of 1st row
  59947. * @param initialM14 defines 4th value of 1st row
  59948. * @param initialM21 defines 1st value of 2nd row
  59949. * @param initialM22 defines 2nd value of 2nd row
  59950. * @param initialM23 defines 3rd value of 2nd row
  59951. * @param initialM24 defines 4th value of 2nd row
  59952. * @param initialM31 defines 1st value of 3rd row
  59953. * @param initialM32 defines 2nd value of 3rd row
  59954. * @param initialM33 defines 3rd value of 3rd row
  59955. * @param initialM34 defines 4th value of 3rd row
  59956. * @param initialM41 defines 1st value of 4th row
  59957. * @param initialM42 defines 2nd value of 4th row
  59958. * @param initialM43 defines 3rd value of 4th row
  59959. * @param initialM44 defines 4th value of 4th row
  59960. * @returns the new matrix
  59961. */
  59962. 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;
  59963. /**
  59964. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59965. * @param scale defines the scale vector3
  59966. * @param rotation defines the rotation quaternion
  59967. * @param translation defines the translation vector3
  59968. * @returns a new matrix
  59969. */
  59970. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59971. /**
  59972. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59973. * @param scale defines the scale vector3
  59974. * @param rotation defines the rotation quaternion
  59975. * @param translation defines the translation vector3
  59976. * @param result defines the target matrix
  59977. */
  59978. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59979. /**
  59980. * Creates a new identity matrix
  59981. * @returns a new identity matrix
  59982. */
  59983. static Identity(): Matrix;
  59984. /**
  59985. * Creates a new identity matrix and stores the result in a given matrix
  59986. * @param result defines the target matrix
  59987. */
  59988. static IdentityToRef(result: Matrix): void;
  59989. /**
  59990. * Creates a new zero matrix
  59991. * @returns a new zero matrix
  59992. */
  59993. static Zero(): Matrix;
  59994. /**
  59995. * Creates a new rotation matrix for "angle" radians around the X axis
  59996. * @param angle defines the angle (in radians) to use
  59997. * @return the new matrix
  59998. */
  59999. static RotationX(angle: number): Matrix;
  60000. /**
  60001. * Creates a new matrix as the invert of a given matrix
  60002. * @param source defines the source matrix
  60003. * @returns the new matrix
  60004. */
  60005. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60006. /**
  60007. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60008. * @param angle defines the angle (in radians) to use
  60009. * @param result defines the target matrix
  60010. */
  60011. static RotationXToRef(angle: number, result: Matrix): void;
  60012. /**
  60013. * Creates a new rotation matrix for "angle" radians around the Y axis
  60014. * @param angle defines the angle (in radians) to use
  60015. * @return the new matrix
  60016. */
  60017. static RotationY(angle: number): Matrix;
  60018. /**
  60019. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60020. * @param angle defines the angle (in radians) to use
  60021. * @param result defines the target matrix
  60022. */
  60023. static RotationYToRef(angle: number, result: Matrix): void;
  60024. /**
  60025. * Creates a new rotation matrix for "angle" radians around the Z axis
  60026. * @param angle defines the angle (in radians) to use
  60027. * @return the new matrix
  60028. */
  60029. static RotationZ(angle: number): Matrix;
  60030. /**
  60031. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60032. * @param angle defines the angle (in radians) to use
  60033. * @param result defines the target matrix
  60034. */
  60035. static RotationZToRef(angle: number, result: Matrix): void;
  60036. /**
  60037. * Creates a new rotation matrix for "angle" radians around the given axis
  60038. * @param axis defines the axis to use
  60039. * @param angle defines the angle (in radians) to use
  60040. * @return the new matrix
  60041. */
  60042. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60043. /**
  60044. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60045. * @param axis defines the axis to use
  60046. * @param angle defines the angle (in radians) to use
  60047. * @param result defines the target matrix
  60048. */
  60049. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60050. /**
  60051. * Creates a rotation matrix
  60052. * @param yaw defines the yaw angle in radians (Y axis)
  60053. * @param pitch defines the pitch angle in radians (X axis)
  60054. * @param roll defines the roll angle in radians (X axis)
  60055. * @returns the new rotation matrix
  60056. */
  60057. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60058. /**
  60059. * Creates a rotation matrix and stores it in a given matrix
  60060. * @param yaw defines the yaw angle in radians (Y axis)
  60061. * @param pitch defines the pitch angle in radians (X axis)
  60062. * @param roll defines the roll angle in radians (X axis)
  60063. * @param result defines the target matrix
  60064. */
  60065. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60066. /**
  60067. * Creates a scaling matrix
  60068. * @param x defines the scale factor on X axis
  60069. * @param y defines the scale factor on Y axis
  60070. * @param z defines the scale factor on Z axis
  60071. * @returns the new matrix
  60072. */
  60073. static Scaling(x: number, y: number, z: number): Matrix;
  60074. /**
  60075. * Creates a scaling matrix and stores it in a given matrix
  60076. * @param x defines the scale factor on X axis
  60077. * @param y defines the scale factor on Y axis
  60078. * @param z defines the scale factor on Z axis
  60079. * @param result defines the target matrix
  60080. */
  60081. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60082. /**
  60083. * Creates a translation matrix
  60084. * @param x defines the translation on X axis
  60085. * @param y defines the translation on Y axis
  60086. * @param z defines the translationon Z axis
  60087. * @returns the new matrix
  60088. */
  60089. static Translation(x: number, y: number, z: number): Matrix;
  60090. /**
  60091. * Creates a translation matrix and stores it in a given matrix
  60092. * @param x defines the translation on X axis
  60093. * @param y defines the translation on Y axis
  60094. * @param z defines the translationon Z axis
  60095. * @param result defines the target matrix
  60096. */
  60097. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60098. /**
  60099. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60100. * @param startValue defines the start value
  60101. * @param endValue defines the end value
  60102. * @param gradient defines the gradient factor
  60103. * @returns the new matrix
  60104. */
  60105. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60106. /**
  60107. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60108. * @param startValue defines the start value
  60109. * @param endValue defines the end value
  60110. * @param gradient defines the gradient factor
  60111. * @param result defines the Matrix object where to store data
  60112. */
  60113. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60114. /**
  60115. * Builds a new matrix whose values are computed by:
  60116. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60117. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60118. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60119. * @param startValue defines the first matrix
  60120. * @param endValue defines the second matrix
  60121. * @param gradient defines the gradient between the two matrices
  60122. * @returns the new matrix
  60123. */
  60124. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60125. /**
  60126. * Update a matrix to values which are computed by:
  60127. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60128. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60129. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60130. * @param startValue defines the first matrix
  60131. * @param endValue defines the second matrix
  60132. * @param gradient defines the gradient between the two matrices
  60133. * @param result defines the target matrix
  60134. */
  60135. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60136. /**
  60137. * 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"
  60138. * This function works in left handed mode
  60139. * @param eye defines the final position of the entity
  60140. * @param target defines where the entity should look at
  60141. * @param up defines the up vector for the entity
  60142. * @returns the new matrix
  60143. */
  60144. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60145. /**
  60146. * 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".
  60147. * This function works in left handed mode
  60148. * @param eye defines the final position of the entity
  60149. * @param target defines where the entity should look at
  60150. * @param up defines the up vector for the entity
  60151. * @param result defines the target matrix
  60152. */
  60153. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60154. /**
  60155. * 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"
  60156. * This function works in right handed mode
  60157. * @param eye defines the final position of the entity
  60158. * @param target defines where the entity should look at
  60159. * @param up defines the up vector for the entity
  60160. * @returns the new matrix
  60161. */
  60162. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60163. /**
  60164. * 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".
  60165. * This function works in right handed mode
  60166. * @param eye defines the final position of the entity
  60167. * @param target defines where the entity should look at
  60168. * @param up defines the up vector for the entity
  60169. * @param result defines the target matrix
  60170. */
  60171. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60172. /**
  60173. * Create a left-handed orthographic projection matrix
  60174. * @param width defines the viewport width
  60175. * @param height defines the viewport height
  60176. * @param znear defines the near clip plane
  60177. * @param zfar defines the far clip plane
  60178. * @returns a new matrix as a left-handed orthographic projection matrix
  60179. */
  60180. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60181. /**
  60182. * Store a left-handed orthographic projection to a given matrix
  60183. * @param width defines the viewport width
  60184. * @param height defines the viewport height
  60185. * @param znear defines the near clip plane
  60186. * @param zfar defines the far clip plane
  60187. * @param result defines the target matrix
  60188. */
  60189. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60190. /**
  60191. * Create a left-handed orthographic projection matrix
  60192. * @param left defines the viewport left coordinate
  60193. * @param right defines the viewport right coordinate
  60194. * @param bottom defines the viewport bottom coordinate
  60195. * @param top defines the viewport top coordinate
  60196. * @param znear defines the near clip plane
  60197. * @param zfar defines the far clip plane
  60198. * @returns a new matrix as a left-handed orthographic projection matrix
  60199. */
  60200. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60201. /**
  60202. * Stores a left-handed orthographic projection into a given matrix
  60203. * @param left defines the viewport left coordinate
  60204. * @param right defines the viewport right coordinate
  60205. * @param bottom defines the viewport bottom coordinate
  60206. * @param top defines the viewport top coordinate
  60207. * @param znear defines the near clip plane
  60208. * @param zfar defines the far clip plane
  60209. * @param result defines the target matrix
  60210. */
  60211. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60212. /**
  60213. * Creates a right-handed orthographic projection matrix
  60214. * @param left defines the viewport left coordinate
  60215. * @param right defines the viewport right coordinate
  60216. * @param bottom defines the viewport bottom coordinate
  60217. * @param top defines the viewport top coordinate
  60218. * @param znear defines the near clip plane
  60219. * @param zfar defines the far clip plane
  60220. * @returns a new matrix as a right-handed orthographic projection matrix
  60221. */
  60222. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60223. /**
  60224. * Stores a right-handed orthographic projection into a given matrix
  60225. * @param left defines the viewport left coordinate
  60226. * @param right defines the viewport right coordinate
  60227. * @param bottom defines the viewport bottom coordinate
  60228. * @param top defines the viewport top coordinate
  60229. * @param znear defines the near clip plane
  60230. * @param zfar defines the far clip plane
  60231. * @param result defines the target matrix
  60232. */
  60233. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60234. /**
  60235. * Creates a left-handed perspective projection matrix
  60236. * @param width defines the viewport width
  60237. * @param height defines the viewport height
  60238. * @param znear defines the near clip plane
  60239. * @param zfar defines the far clip plane
  60240. * @returns a new matrix as a left-handed perspective projection matrix
  60241. */
  60242. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60243. /**
  60244. * Creates a left-handed perspective projection matrix
  60245. * @param fov defines the horizontal field of view
  60246. * @param aspect defines the aspect ratio
  60247. * @param znear defines the near clip plane
  60248. * @param zfar defines the far clip plane
  60249. * @returns a new matrix as a left-handed perspective projection matrix
  60250. */
  60251. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60252. /**
  60253. * Stores a left-handed perspective projection into a given matrix
  60254. * @param fov defines the horizontal field of view
  60255. * @param aspect defines the aspect ratio
  60256. * @param znear defines the near clip plane
  60257. * @param zfar defines the far clip plane
  60258. * @param result defines the target matrix
  60259. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60260. */
  60261. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60262. /**
  60263. * Creates a right-handed perspective projection matrix
  60264. * @param fov defines the horizontal field of view
  60265. * @param aspect defines the aspect ratio
  60266. * @param znear defines the near clip plane
  60267. * @param zfar defines the far clip plane
  60268. * @returns a new matrix as a right-handed perspective projection matrix
  60269. */
  60270. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60271. /**
  60272. * Stores a right-handed perspective projection into a given matrix
  60273. * @param fov defines the horizontal field of view
  60274. * @param aspect defines the aspect ratio
  60275. * @param znear defines the near clip plane
  60276. * @param zfar defines the far clip plane
  60277. * @param result defines the target matrix
  60278. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60279. */
  60280. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60281. /**
  60282. * Stores a perspective projection for WebVR info a given matrix
  60283. * @param fov defines the field of view
  60284. * @param znear defines the near clip plane
  60285. * @param zfar defines the far clip plane
  60286. * @param result defines the target matrix
  60287. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60288. */
  60289. static PerspectiveFovWebVRToRef(fov: {
  60290. upDegrees: number;
  60291. downDegrees: number;
  60292. leftDegrees: number;
  60293. rightDegrees: number;
  60294. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60295. /**
  60296. * Computes a complete transformation matrix
  60297. * @param viewport defines the viewport to use
  60298. * @param world defines the world matrix
  60299. * @param view defines the view matrix
  60300. * @param projection defines the projection matrix
  60301. * @param zmin defines the near clip plane
  60302. * @param zmax defines the far clip plane
  60303. * @returns the transformation matrix
  60304. */
  60305. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60306. /**
  60307. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60308. * @param matrix defines the matrix to use
  60309. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60310. */
  60311. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60312. /**
  60313. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60314. * @param matrix defines the matrix to use
  60315. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60316. */
  60317. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60318. /**
  60319. * Compute the transpose of a given matrix
  60320. * @param matrix defines the matrix to transpose
  60321. * @returns the new matrix
  60322. */
  60323. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60324. /**
  60325. * Compute the transpose of a matrix and store it in a target matrix
  60326. * @param matrix defines the matrix to transpose
  60327. * @param result defines the target matrix
  60328. */
  60329. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60330. /**
  60331. * Computes a reflection matrix from a plane
  60332. * @param plane defines the reflection plane
  60333. * @returns a new matrix
  60334. */
  60335. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60336. /**
  60337. * Computes a reflection matrix from a plane
  60338. * @param plane defines the reflection plane
  60339. * @param result defines the target matrix
  60340. */
  60341. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60342. /**
  60343. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60344. * @param xaxis defines the value of the 1st axis
  60345. * @param yaxis defines the value of the 2nd axis
  60346. * @param zaxis defines the value of the 3rd axis
  60347. * @param result defines the target matrix
  60348. */
  60349. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60350. /**
  60351. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60352. * @param quat defines the quaternion to use
  60353. * @param result defines the target matrix
  60354. */
  60355. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60356. }
  60357. /**
  60358. * Represens a plane by the equation ax + by + cz + d = 0
  60359. */
  60360. export class Plane {
  60361. /**
  60362. * Normal of the plane (a,b,c)
  60363. */
  60364. normal: Vector3;
  60365. /**
  60366. * d component of the plane
  60367. */
  60368. d: number;
  60369. /**
  60370. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60371. * @param a a component of the plane
  60372. * @param b b component of the plane
  60373. * @param c c component of the plane
  60374. * @param d d component of the plane
  60375. */
  60376. constructor(a: number, b: number, c: number, d: number);
  60377. /**
  60378. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60379. */
  60380. asArray(): number[];
  60381. /**
  60382. * @returns a new plane copied from the current Plane.
  60383. */
  60384. clone(): Plane;
  60385. /**
  60386. * @returns the string "Plane".
  60387. */
  60388. getClassName(): string;
  60389. /**
  60390. * @returns the Plane hash code.
  60391. */
  60392. getHashCode(): number;
  60393. /**
  60394. * Normalize the current Plane in place.
  60395. * @returns the updated Plane.
  60396. */
  60397. normalize(): Plane;
  60398. /**
  60399. * Applies a transformation the plane and returns the result
  60400. * @param transformation the transformation matrix to be applied to the plane
  60401. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60402. */
  60403. transform(transformation: DeepImmutable<Matrix>): Plane;
  60404. /**
  60405. * Calcualtte the dot product between the point and the plane normal
  60406. * @param point point to calculate the dot product with
  60407. * @returns the dot product (float) of the point coordinates and the plane normal.
  60408. */
  60409. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60410. /**
  60411. * Updates the current Plane from the plane defined by the three given points.
  60412. * @param point1 one of the points used to contruct the plane
  60413. * @param point2 one of the points used to contruct the plane
  60414. * @param point3 one of the points used to contruct the plane
  60415. * @returns the updated Plane.
  60416. */
  60417. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60418. /**
  60419. * Checks if the plane is facing a given direction
  60420. * @param direction the direction to check if the plane is facing
  60421. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60422. * @returns True is the vector "direction" is the same side than the plane normal.
  60423. */
  60424. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60425. /**
  60426. * Calculates the distance to a point
  60427. * @param point point to calculate distance to
  60428. * @returns the signed distance (float) from the given point to the Plane.
  60429. */
  60430. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60431. /**
  60432. * Creates a plane from an array
  60433. * @param array the array to create a plane from
  60434. * @returns a new Plane from the given array.
  60435. */
  60436. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60437. /**
  60438. * Creates a plane from three points
  60439. * @param point1 point used to create the plane
  60440. * @param point2 point used to create the plane
  60441. * @param point3 point used to create the plane
  60442. * @returns a new Plane defined by the three given points.
  60443. */
  60444. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60445. /**
  60446. * Creates a plane from an origin point and a normal
  60447. * @param origin origin of the plane to be constructed
  60448. * @param normal normal of the plane to be constructed
  60449. * @returns a new Plane the normal vector to this plane at the given origin point.
  60450. * Note : the vector "normal" is updated because normalized.
  60451. */
  60452. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60453. /**
  60454. * Calculates the distance from a plane and a point
  60455. * @param origin origin of the plane to be constructed
  60456. * @param normal normal of the plane to be constructed
  60457. * @param point point to calculate distance to
  60458. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60459. */
  60460. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60461. }
  60462. /**
  60463. * Class used to represent a viewport on screen
  60464. */
  60465. export class Viewport {
  60466. /** viewport left coordinate */
  60467. x: number;
  60468. /** viewport top coordinate */
  60469. y: number;
  60470. /**viewport width */
  60471. width: number;
  60472. /** viewport height */
  60473. height: number;
  60474. /**
  60475. * Creates a Viewport object located at (x, y) and sized (width, height)
  60476. * @param x defines viewport left coordinate
  60477. * @param y defines viewport top coordinate
  60478. * @param width defines the viewport width
  60479. * @param height defines the viewport height
  60480. */
  60481. constructor(
  60482. /** viewport left coordinate */
  60483. x: number,
  60484. /** viewport top coordinate */
  60485. y: number,
  60486. /**viewport width */
  60487. width: number,
  60488. /** viewport height */
  60489. height: number);
  60490. /**
  60491. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60492. * @param renderWidth defines the rendering width
  60493. * @param renderHeight defines the rendering height
  60494. * @returns a new Viewport
  60495. */
  60496. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60497. /**
  60498. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60499. * @param renderWidth defines the rendering width
  60500. * @param renderHeight defines the rendering height
  60501. * @param ref defines the target viewport
  60502. * @returns the current viewport
  60503. */
  60504. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60505. /**
  60506. * Returns a new Viewport copied from the current one
  60507. * @returns a new Viewport
  60508. */
  60509. clone(): Viewport;
  60510. }
  60511. /**
  60512. * Reprasents a camera frustum
  60513. */
  60514. export class Frustum {
  60515. /**
  60516. * Gets the planes representing the frustum
  60517. * @param transform matrix to be applied to the returned planes
  60518. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60519. */
  60520. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60521. /**
  60522. * Gets the near frustum plane transformed by the transform matrix
  60523. * @param transform transformation matrix to be applied to the resulting frustum plane
  60524. * @param frustumPlane the resuling frustum plane
  60525. */
  60526. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60527. /**
  60528. * Gets the far frustum plane transformed by the transform matrix
  60529. * @param transform transformation matrix to be applied to the resulting frustum plane
  60530. * @param frustumPlane the resuling frustum plane
  60531. */
  60532. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60533. /**
  60534. * Gets the left frustum plane transformed by the transform matrix
  60535. * @param transform transformation matrix to be applied to the resulting frustum plane
  60536. * @param frustumPlane the resuling frustum plane
  60537. */
  60538. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60539. /**
  60540. * Gets the right frustum plane transformed by the transform matrix
  60541. * @param transform transformation matrix to be applied to the resulting frustum plane
  60542. * @param frustumPlane the resuling frustum plane
  60543. */
  60544. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60545. /**
  60546. * Gets the top frustum plane transformed by the transform matrix
  60547. * @param transform transformation matrix to be applied to the resulting frustum plane
  60548. * @param frustumPlane the resuling frustum plane
  60549. */
  60550. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60551. /**
  60552. * Gets the bottom frustum plane transformed by the transform matrix
  60553. * @param transform transformation matrix to be applied to the resulting frustum plane
  60554. * @param frustumPlane the resuling frustum plane
  60555. */
  60556. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60557. /**
  60558. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60559. * @param transform transformation matrix to be applied to the resulting frustum planes
  60560. * @param frustumPlanes the resuling frustum planes
  60561. */
  60562. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60563. }
  60564. /** Defines supported spaces */
  60565. export enum Space {
  60566. /** Local (object) space */
  60567. LOCAL = 0,
  60568. /** World space */
  60569. WORLD = 1,
  60570. /** Bone space */
  60571. BONE = 2
  60572. }
  60573. /** Defines the 3 main axes */
  60574. export class Axis {
  60575. /** X axis */
  60576. static X: Vector3;
  60577. /** Y axis */
  60578. static Y: Vector3;
  60579. /** Z axis */
  60580. static Z: Vector3;
  60581. }
  60582. /** Class used to represent a Bezier curve */
  60583. export class BezierCurve {
  60584. /**
  60585. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60586. * @param t defines the time
  60587. * @param x1 defines the left coordinate on X axis
  60588. * @param y1 defines the left coordinate on Y axis
  60589. * @param x2 defines the right coordinate on X axis
  60590. * @param y2 defines the right coordinate on Y axis
  60591. * @returns the interpolated value
  60592. */
  60593. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60594. }
  60595. /**
  60596. * Defines potential orientation for back face culling
  60597. */
  60598. export enum Orientation {
  60599. /**
  60600. * Clockwise
  60601. */
  60602. CW = 0,
  60603. /** Counter clockwise */
  60604. CCW = 1
  60605. }
  60606. /**
  60607. * Defines angle representation
  60608. */
  60609. export class Angle {
  60610. private _radians;
  60611. /**
  60612. * Creates an Angle object of "radians" radians (float).
  60613. * @param radians the angle in radians
  60614. */
  60615. constructor(radians: number);
  60616. /**
  60617. * Get value in degrees
  60618. * @returns the Angle value in degrees (float)
  60619. */
  60620. degrees(): number;
  60621. /**
  60622. * Get value in radians
  60623. * @returns the Angle value in radians (float)
  60624. */
  60625. radians(): number;
  60626. /**
  60627. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60628. * @param a defines first vector
  60629. * @param b defines second vector
  60630. * @returns a new Angle
  60631. */
  60632. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60633. /**
  60634. * Gets a new Angle object from the given float in radians
  60635. * @param radians defines the angle value in radians
  60636. * @returns a new Angle
  60637. */
  60638. static FromRadians(radians: number): Angle;
  60639. /**
  60640. * Gets a new Angle object from the given float in degrees
  60641. * @param degrees defines the angle value in degrees
  60642. * @returns a new Angle
  60643. */
  60644. static FromDegrees(degrees: number): Angle;
  60645. }
  60646. /**
  60647. * This represents an arc in a 2d space.
  60648. */
  60649. export class Arc2 {
  60650. /** Defines the start point of the arc */
  60651. startPoint: Vector2;
  60652. /** Defines the mid point of the arc */
  60653. midPoint: Vector2;
  60654. /** Defines the end point of the arc */
  60655. endPoint: Vector2;
  60656. /**
  60657. * Defines the center point of the arc.
  60658. */
  60659. centerPoint: Vector2;
  60660. /**
  60661. * Defines the radius of the arc.
  60662. */
  60663. radius: number;
  60664. /**
  60665. * Defines the angle of the arc (from mid point to end point).
  60666. */
  60667. angle: Angle;
  60668. /**
  60669. * Defines the start angle of the arc (from start point to middle point).
  60670. */
  60671. startAngle: Angle;
  60672. /**
  60673. * Defines the orientation of the arc (clock wise/counter clock wise).
  60674. */
  60675. orientation: Orientation;
  60676. /**
  60677. * Creates an Arc object from the three given points : start, middle and end.
  60678. * @param startPoint Defines the start point of the arc
  60679. * @param midPoint Defines the midlle point of the arc
  60680. * @param endPoint Defines the end point of the arc
  60681. */
  60682. constructor(
  60683. /** Defines the start point of the arc */
  60684. startPoint: Vector2,
  60685. /** Defines the mid point of the arc */
  60686. midPoint: Vector2,
  60687. /** Defines the end point of the arc */
  60688. endPoint: Vector2);
  60689. }
  60690. /**
  60691. * Represents a 2D path made up of multiple 2D points
  60692. */
  60693. export class Path2 {
  60694. private _points;
  60695. private _length;
  60696. /**
  60697. * If the path start and end point are the same
  60698. */
  60699. closed: boolean;
  60700. /**
  60701. * Creates a Path2 object from the starting 2D coordinates x and y.
  60702. * @param x the starting points x value
  60703. * @param y the starting points y value
  60704. */
  60705. constructor(x: number, y: number);
  60706. /**
  60707. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60708. * @param x the added points x value
  60709. * @param y the added points y value
  60710. * @returns the updated Path2.
  60711. */
  60712. addLineTo(x: number, y: number): Path2;
  60713. /**
  60714. * 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.
  60715. * @param midX middle point x value
  60716. * @param midY middle point y value
  60717. * @param endX end point x value
  60718. * @param endY end point y value
  60719. * @param numberOfSegments (default: 36)
  60720. * @returns the updated Path2.
  60721. */
  60722. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60723. /**
  60724. * Closes the Path2.
  60725. * @returns the Path2.
  60726. */
  60727. close(): Path2;
  60728. /**
  60729. * Gets the sum of the distance between each sequential point in the path
  60730. * @returns the Path2 total length (float).
  60731. */
  60732. length(): number;
  60733. /**
  60734. * Gets the points which construct the path
  60735. * @returns the Path2 internal array of points.
  60736. */
  60737. getPoints(): Vector2[];
  60738. /**
  60739. * Retreives the point at the distance aways from the starting point
  60740. * @param normalizedLengthPosition the length along the path to retreive the point from
  60741. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60742. */
  60743. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60744. /**
  60745. * Creates a new path starting from an x and y position
  60746. * @param x starting x value
  60747. * @param y starting y value
  60748. * @returns a new Path2 starting at the coordinates (x, y).
  60749. */
  60750. static StartingAt(x: number, y: number): Path2;
  60751. }
  60752. /**
  60753. * Represents a 3D path made up of multiple 3D points
  60754. */
  60755. export class Path3D {
  60756. /**
  60757. * an array of Vector3, the curve axis of the Path3D
  60758. */
  60759. path: Vector3[];
  60760. private _curve;
  60761. private _distances;
  60762. private _tangents;
  60763. private _normals;
  60764. private _binormals;
  60765. private _raw;
  60766. /**
  60767. * new Path3D(path, normal, raw)
  60768. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60769. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60770. * @param path an array of Vector3, the curve axis of the Path3D
  60771. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60772. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60773. */
  60774. constructor(
  60775. /**
  60776. * an array of Vector3, the curve axis of the Path3D
  60777. */
  60778. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60779. /**
  60780. * Returns the Path3D array of successive Vector3 designing its curve.
  60781. * @returns the Path3D array of successive Vector3 designing its curve.
  60782. */
  60783. getCurve(): Vector3[];
  60784. /**
  60785. * Returns an array populated with tangent vectors on each Path3D curve point.
  60786. * @returns an array populated with tangent vectors on each Path3D curve point.
  60787. */
  60788. getTangents(): Vector3[];
  60789. /**
  60790. * Returns an array populated with normal vectors on each Path3D curve point.
  60791. * @returns an array populated with normal vectors on each Path3D curve point.
  60792. */
  60793. getNormals(): Vector3[];
  60794. /**
  60795. * Returns an array populated with binormal vectors on each Path3D curve point.
  60796. * @returns an array populated with binormal vectors on each Path3D curve point.
  60797. */
  60798. getBinormals(): Vector3[];
  60799. /**
  60800. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60801. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60802. */
  60803. getDistances(): number[];
  60804. /**
  60805. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60806. * @param path path which all values are copied into the curves points
  60807. * @param firstNormal which should be projected onto the curve
  60808. * @returns the same object updated.
  60809. */
  60810. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60811. private _compute;
  60812. private _getFirstNonNullVector;
  60813. private _getLastNonNullVector;
  60814. private _normalVector;
  60815. }
  60816. /**
  60817. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60818. * A Curve3 is designed from a series of successive Vector3.
  60819. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60820. */
  60821. export class Curve3 {
  60822. private _points;
  60823. private _length;
  60824. /**
  60825. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60826. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60827. * @param v1 (Vector3) the control point
  60828. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60829. * @param nbPoints (integer) the wanted number of points in the curve
  60830. * @returns the created Curve3
  60831. */
  60832. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60833. /**
  60834. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60835. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60836. * @param v1 (Vector3) the first control point
  60837. * @param v2 (Vector3) the second control point
  60838. * @param v3 (Vector3) the end point of the Cubic Bezier
  60839. * @param nbPoints (integer) the wanted number of points in the curve
  60840. * @returns the created Curve3
  60841. */
  60842. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60843. /**
  60844. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60845. * @param p1 (Vector3) the origin point of the Hermite Spline
  60846. * @param t1 (Vector3) the tangent vector at the origin point
  60847. * @param p2 (Vector3) the end point of the Hermite Spline
  60848. * @param t2 (Vector3) the tangent vector at the end point
  60849. * @param nbPoints (integer) the wanted number of points in the curve
  60850. * @returns the created Curve3
  60851. */
  60852. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60853. /**
  60854. * Returns a Curve3 object along a CatmullRom Spline curve :
  60855. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60856. * @param nbPoints (integer) the wanted number of points between each curve control points
  60857. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60858. * @returns the created Curve3
  60859. */
  60860. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60861. /**
  60862. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60863. * A Curve3 is designed from a series of successive Vector3.
  60864. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60865. * @param points points which make up the curve
  60866. */
  60867. constructor(points: Vector3[]);
  60868. /**
  60869. * @returns the Curve3 stored array of successive Vector3
  60870. */
  60871. getPoints(): Vector3[];
  60872. /**
  60873. * @returns the computed length (float) of the curve.
  60874. */
  60875. length(): number;
  60876. /**
  60877. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60878. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60879. * curveA and curveB keep unchanged.
  60880. * @param curve the curve to continue from this curve
  60881. * @returns the newly constructed curve
  60882. */
  60883. continue(curve: DeepImmutable<Curve3>): Curve3;
  60884. private _computeLength;
  60885. }
  60886. /**
  60887. * Contains position and normal vectors for a vertex
  60888. */
  60889. export class PositionNormalVertex {
  60890. /** the position of the vertex (defaut: 0,0,0) */
  60891. position: Vector3;
  60892. /** the normal of the vertex (defaut: 0,1,0) */
  60893. normal: Vector3;
  60894. /**
  60895. * Creates a PositionNormalVertex
  60896. * @param position the position of the vertex (defaut: 0,0,0)
  60897. * @param normal the normal of the vertex (defaut: 0,1,0)
  60898. */
  60899. constructor(
  60900. /** the position of the vertex (defaut: 0,0,0) */
  60901. position?: Vector3,
  60902. /** the normal of the vertex (defaut: 0,1,0) */
  60903. normal?: Vector3);
  60904. /**
  60905. * Clones the PositionNormalVertex
  60906. * @returns the cloned PositionNormalVertex
  60907. */
  60908. clone(): PositionNormalVertex;
  60909. }
  60910. /**
  60911. * Contains position, normal and uv vectors for a vertex
  60912. */
  60913. export class PositionNormalTextureVertex {
  60914. /** the position of the vertex (defaut: 0,0,0) */
  60915. position: Vector3;
  60916. /** the normal of the vertex (defaut: 0,1,0) */
  60917. normal: Vector3;
  60918. /** the uv of the vertex (default: 0,0) */
  60919. uv: Vector2;
  60920. /**
  60921. * Creates a PositionNormalTextureVertex
  60922. * @param position the position of the vertex (defaut: 0,0,0)
  60923. * @param normal the normal of the vertex (defaut: 0,1,0)
  60924. * @param uv the uv of the vertex (default: 0,0)
  60925. */
  60926. constructor(
  60927. /** the position of the vertex (defaut: 0,0,0) */
  60928. position?: Vector3,
  60929. /** the normal of the vertex (defaut: 0,1,0) */
  60930. normal?: Vector3,
  60931. /** the uv of the vertex (default: 0,0) */
  60932. uv?: Vector2);
  60933. /**
  60934. * Clones the PositionNormalTextureVertex
  60935. * @returns the cloned PositionNormalTextureVertex
  60936. */
  60937. clone(): PositionNormalTextureVertex;
  60938. }
  60939. /**
  60940. * @hidden
  60941. */
  60942. export class Tmp {
  60943. static Color3: Color3[];
  60944. static Color4: Color4[];
  60945. static Vector2: Vector2[];
  60946. static Vector3: Vector3[];
  60947. static Vector4: Vector4[];
  60948. static Quaternion: Quaternion[];
  60949. static Matrix: Matrix[];
  60950. }
  60951. }
  60952. declare module BABYLON {
  60953. /**
  60954. * Class used to enable access to offline support
  60955. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60956. */
  60957. export interface IOfflineProvider {
  60958. /**
  60959. * Gets a boolean indicating if scene must be saved in the database
  60960. */
  60961. enableSceneOffline: boolean;
  60962. /**
  60963. * Gets a boolean indicating if textures must be saved in the database
  60964. */
  60965. enableTexturesOffline: boolean;
  60966. /**
  60967. * Open the offline support and make it available
  60968. * @param successCallback defines the callback to call on success
  60969. * @param errorCallback defines the callback to call on error
  60970. */
  60971. open(successCallback: () => void, errorCallback: () => void): void;
  60972. /**
  60973. * Loads an image from the offline support
  60974. * @param url defines the url to load from
  60975. * @param image defines the target DOM image
  60976. */
  60977. loadImage(url: string, image: HTMLImageElement): void;
  60978. /**
  60979. * Loads a file from offline support
  60980. * @param url defines the URL to load from
  60981. * @param sceneLoaded defines a callback to call on success
  60982. * @param progressCallBack defines a callback to call when progress changed
  60983. * @param errorCallback defines a callback to call on error
  60984. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60985. */
  60986. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60987. }
  60988. }
  60989. declare module BABYLON {
  60990. /**
  60991. * A class serves as a medium between the observable and its observers
  60992. */
  60993. export class EventState {
  60994. /**
  60995. * Create a new EventState
  60996. * @param mask defines the mask associated with this state
  60997. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60998. * @param target defines the original target of the state
  60999. * @param currentTarget defines the current target of the state
  61000. */
  61001. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61002. /**
  61003. * Initialize the current event state
  61004. * @param mask defines the mask associated with this state
  61005. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61006. * @param target defines the original target of the state
  61007. * @param currentTarget defines the current target of the state
  61008. * @returns the current event state
  61009. */
  61010. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61011. /**
  61012. * An Observer can set this property to true to prevent subsequent observers of being notified
  61013. */
  61014. skipNextObservers: boolean;
  61015. /**
  61016. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61017. */
  61018. mask: number;
  61019. /**
  61020. * The object that originally notified the event
  61021. */
  61022. target?: any;
  61023. /**
  61024. * The current object in the bubbling phase
  61025. */
  61026. currentTarget?: any;
  61027. /**
  61028. * This will be populated with the return value of the last function that was executed.
  61029. * If it is the first function in the callback chain it will be the event data.
  61030. */
  61031. lastReturnValue?: any;
  61032. }
  61033. /**
  61034. * Represent an Observer registered to a given Observable object.
  61035. */
  61036. export class Observer<T> {
  61037. /**
  61038. * Defines the callback to call when the observer is notified
  61039. */
  61040. callback: (eventData: T, eventState: EventState) => void;
  61041. /**
  61042. * Defines the mask of the observer (used to filter notifications)
  61043. */
  61044. mask: number;
  61045. /**
  61046. * Defines the current scope used to restore the JS context
  61047. */
  61048. scope: any;
  61049. /** @hidden */
  61050. _willBeUnregistered: boolean;
  61051. /**
  61052. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61053. */
  61054. unregisterOnNextCall: boolean;
  61055. /**
  61056. * Creates a new observer
  61057. * @param callback defines the callback to call when the observer is notified
  61058. * @param mask defines the mask of the observer (used to filter notifications)
  61059. * @param scope defines the current scope used to restore the JS context
  61060. */
  61061. constructor(
  61062. /**
  61063. * Defines the callback to call when the observer is notified
  61064. */
  61065. callback: (eventData: T, eventState: EventState) => void,
  61066. /**
  61067. * Defines the mask of the observer (used to filter notifications)
  61068. */
  61069. mask: number,
  61070. /**
  61071. * Defines the current scope used to restore the JS context
  61072. */
  61073. scope?: any);
  61074. }
  61075. /**
  61076. * Represent a list of observers registered to multiple Observables object.
  61077. */
  61078. export class MultiObserver<T> {
  61079. private _observers;
  61080. private _observables;
  61081. /**
  61082. * Release associated resources
  61083. */
  61084. dispose(): void;
  61085. /**
  61086. * Raise a callback when one of the observable will notify
  61087. * @param observables defines a list of observables to watch
  61088. * @param callback defines the callback to call on notification
  61089. * @param mask defines the mask used to filter notifications
  61090. * @param scope defines the current scope used to restore the JS context
  61091. * @returns the new MultiObserver
  61092. */
  61093. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61094. }
  61095. /**
  61096. * The Observable class is a simple implementation of the Observable pattern.
  61097. *
  61098. * 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.
  61099. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61100. * 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).
  61101. * 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.
  61102. */
  61103. export class Observable<T> {
  61104. private _observers;
  61105. private _eventState;
  61106. private _onObserverAdded;
  61107. /**
  61108. * Creates a new observable
  61109. * @param onObserverAdded defines a callback to call when a new observer is added
  61110. */
  61111. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61112. /**
  61113. * Create a new Observer with the specified callback
  61114. * @param callback the callback that will be executed for that Observer
  61115. * @param mask the mask used to filter observers
  61116. * @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.
  61117. * @param scope optional scope for the callback to be called from
  61118. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61119. * @returns the new observer created for the callback
  61120. */
  61121. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61122. /**
  61123. * Create a new Observer with the specified callback and unregisters after the next notification
  61124. * @param callback the callback that will be executed for that Observer
  61125. * @returns the new observer created for the callback
  61126. */
  61127. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61128. /**
  61129. * Remove an Observer from the Observable object
  61130. * @param observer the instance of the Observer to remove
  61131. * @returns false if it doesn't belong to this Observable
  61132. */
  61133. remove(observer: Nullable<Observer<T>>): boolean;
  61134. /**
  61135. * Remove a callback from the Observable object
  61136. * @param callback the callback to remove
  61137. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61138. * @returns false if it doesn't belong to this Observable
  61139. */
  61140. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61141. private _deferUnregister;
  61142. private _remove;
  61143. /**
  61144. * Notify all Observers by calling their respective callback with the given data
  61145. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61146. * @param eventData defines the data to send to all observers
  61147. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61148. * @param target defines the original target of the state
  61149. * @param currentTarget defines the current target of the state
  61150. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61151. */
  61152. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61153. /**
  61154. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61155. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61156. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61157. * and it is crucial that all callbacks will be executed.
  61158. * The order of the callbacks is kept, callbacks are not executed parallel.
  61159. *
  61160. * @param eventData The data to be sent to each callback
  61161. * @param mask is used to filter observers defaults to -1
  61162. * @param target defines the callback target (see EventState)
  61163. * @param currentTarget defines he current object in the bubbling phase
  61164. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61165. */
  61166. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61167. /**
  61168. * Notify a specific observer
  61169. * @param observer defines the observer to notify
  61170. * @param eventData defines the data to be sent to each callback
  61171. * @param mask is used to filter observers defaults to -1
  61172. */
  61173. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61174. /**
  61175. * Gets a boolean indicating if the observable has at least one observer
  61176. * @returns true is the Observable has at least one Observer registered
  61177. */
  61178. hasObservers(): boolean;
  61179. /**
  61180. * Clear the list of observers
  61181. */
  61182. clear(): void;
  61183. /**
  61184. * Clone the current observable
  61185. * @returns a new observable
  61186. */
  61187. clone(): Observable<T>;
  61188. /**
  61189. * Does this observable handles observer registered with a given mask
  61190. * @param mask defines the mask to be tested
  61191. * @return whether or not one observer registered with the given mask is handeled
  61192. **/
  61193. hasSpecificMask(mask?: number): boolean;
  61194. }
  61195. }
  61196. declare module BABYLON {
  61197. /**
  61198. * Class used to help managing file picking and drag'n'drop
  61199. * File Storage
  61200. */
  61201. export class FilesInputStore {
  61202. /**
  61203. * List of files ready to be loaded
  61204. */
  61205. static FilesToLoad: {
  61206. [key: string]: File;
  61207. };
  61208. }
  61209. }
  61210. declare module BABYLON {
  61211. /** Defines the cross module used constants to avoid circular dependncies */
  61212. export class Constants {
  61213. /** Defines that alpha blending is disabled */
  61214. static readonly ALPHA_DISABLE: number;
  61215. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61216. static readonly ALPHA_ADD: number;
  61217. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61218. static readonly ALPHA_COMBINE: number;
  61219. /** Defines that alpha blending to DEST - SRC * DEST */
  61220. static readonly ALPHA_SUBTRACT: number;
  61221. /** Defines that alpha blending to SRC * DEST */
  61222. static readonly ALPHA_MULTIPLY: number;
  61223. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61224. static readonly ALPHA_MAXIMIZED: number;
  61225. /** Defines that alpha blending to SRC + DEST */
  61226. static readonly ALPHA_ONEONE: number;
  61227. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61228. static readonly ALPHA_PREMULTIPLIED: number;
  61229. /**
  61230. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61231. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61232. */
  61233. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61234. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61235. static readonly ALPHA_INTERPOLATE: number;
  61236. /**
  61237. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61238. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61239. */
  61240. static readonly ALPHA_SCREENMODE: number;
  61241. /** Defines that the ressource is not delayed*/
  61242. static readonly DELAYLOADSTATE_NONE: number;
  61243. /** Defines that the ressource was successfully delay loaded */
  61244. static readonly DELAYLOADSTATE_LOADED: number;
  61245. /** Defines that the ressource is currently delay loading */
  61246. static readonly DELAYLOADSTATE_LOADING: number;
  61247. /** Defines that the ressource is delayed and has not started loading */
  61248. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61249. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61250. static readonly NEVER: number;
  61251. /** 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 */
  61252. static readonly ALWAYS: number;
  61253. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61254. static readonly LESS: number;
  61255. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61256. static readonly EQUAL: number;
  61257. /** 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 */
  61258. static readonly LEQUAL: number;
  61259. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61260. static readonly GREATER: number;
  61261. /** 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 */
  61262. static readonly GEQUAL: number;
  61263. /** 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 */
  61264. static readonly NOTEQUAL: number;
  61265. /** Passed to stencilOperation to specify that stencil value must be kept */
  61266. static readonly KEEP: number;
  61267. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61268. static readonly REPLACE: number;
  61269. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61270. static readonly INCR: number;
  61271. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61272. static readonly DECR: number;
  61273. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61274. static readonly INVERT: number;
  61275. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61276. static readonly INCR_WRAP: number;
  61277. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61278. static readonly DECR_WRAP: number;
  61279. /** Texture is not repeating outside of 0..1 UVs */
  61280. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61281. /** Texture is repeating outside of 0..1 UVs */
  61282. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61283. /** Texture is repeating and mirrored */
  61284. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61285. /** ALPHA */
  61286. static readonly TEXTUREFORMAT_ALPHA: number;
  61287. /** LUMINANCE */
  61288. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61289. /** LUMINANCE_ALPHA */
  61290. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61291. /** RGB */
  61292. static readonly TEXTUREFORMAT_RGB: number;
  61293. /** RGBA */
  61294. static readonly TEXTUREFORMAT_RGBA: number;
  61295. /** RED */
  61296. static readonly TEXTUREFORMAT_RED: number;
  61297. /** RED (2nd reference) */
  61298. static readonly TEXTUREFORMAT_R: number;
  61299. /** RG */
  61300. static readonly TEXTUREFORMAT_RG: number;
  61301. /** RED_INTEGER */
  61302. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61303. /** RED_INTEGER (2nd reference) */
  61304. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61305. /** RG_INTEGER */
  61306. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61307. /** RGB_INTEGER */
  61308. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61309. /** RGBA_INTEGER */
  61310. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61311. /** UNSIGNED_BYTE */
  61312. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61313. /** UNSIGNED_BYTE (2nd reference) */
  61314. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61315. /** FLOAT */
  61316. static readonly TEXTURETYPE_FLOAT: number;
  61317. /** HALF_FLOAT */
  61318. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61319. /** BYTE */
  61320. static readonly TEXTURETYPE_BYTE: number;
  61321. /** SHORT */
  61322. static readonly TEXTURETYPE_SHORT: number;
  61323. /** UNSIGNED_SHORT */
  61324. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61325. /** INT */
  61326. static readonly TEXTURETYPE_INT: number;
  61327. /** UNSIGNED_INT */
  61328. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61329. /** UNSIGNED_SHORT_4_4_4_4 */
  61330. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61331. /** UNSIGNED_SHORT_5_5_5_1 */
  61332. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61333. /** UNSIGNED_SHORT_5_6_5 */
  61334. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61335. /** UNSIGNED_INT_2_10_10_10_REV */
  61336. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61337. /** UNSIGNED_INT_24_8 */
  61338. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61339. /** UNSIGNED_INT_10F_11F_11F_REV */
  61340. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61341. /** UNSIGNED_INT_5_9_9_9_REV */
  61342. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61343. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61344. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61345. /** nearest is mag = nearest and min = nearest and mip = linear */
  61346. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61347. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61348. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61349. /** Trilinear is mag = linear and min = linear and mip = linear */
  61350. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61351. /** nearest is mag = nearest and min = nearest and mip = linear */
  61352. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61353. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61354. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61355. /** Trilinear is mag = linear and min = linear and mip = linear */
  61356. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61357. /** mag = nearest and min = nearest and mip = nearest */
  61358. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61359. /** mag = nearest and min = linear and mip = nearest */
  61360. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61361. /** mag = nearest and min = linear and mip = linear */
  61362. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61363. /** mag = nearest and min = linear and mip = none */
  61364. static readonly TEXTURE_NEAREST_LINEAR: number;
  61365. /** mag = nearest and min = nearest and mip = none */
  61366. static readonly TEXTURE_NEAREST_NEAREST: number;
  61367. /** mag = linear and min = nearest and mip = nearest */
  61368. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61369. /** mag = linear and min = nearest and mip = linear */
  61370. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61371. /** mag = linear and min = linear and mip = none */
  61372. static readonly TEXTURE_LINEAR_LINEAR: number;
  61373. /** mag = linear and min = nearest and mip = none */
  61374. static readonly TEXTURE_LINEAR_NEAREST: number;
  61375. /** Explicit coordinates mode */
  61376. static readonly TEXTURE_EXPLICIT_MODE: number;
  61377. /** Spherical coordinates mode */
  61378. static readonly TEXTURE_SPHERICAL_MODE: number;
  61379. /** Planar coordinates mode */
  61380. static readonly TEXTURE_PLANAR_MODE: number;
  61381. /** Cubic coordinates mode */
  61382. static readonly TEXTURE_CUBIC_MODE: number;
  61383. /** Projection coordinates mode */
  61384. static readonly TEXTURE_PROJECTION_MODE: number;
  61385. /** Skybox coordinates mode */
  61386. static readonly TEXTURE_SKYBOX_MODE: number;
  61387. /** Inverse Cubic coordinates mode */
  61388. static readonly TEXTURE_INVCUBIC_MODE: number;
  61389. /** Equirectangular coordinates mode */
  61390. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61391. /** Equirectangular Fixed coordinates mode */
  61392. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61393. /** Equirectangular Fixed Mirrored coordinates mode */
  61394. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61395. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61396. static readonly SCALEMODE_FLOOR: number;
  61397. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61398. static readonly SCALEMODE_NEAREST: number;
  61399. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61400. static readonly SCALEMODE_CEILING: number;
  61401. /**
  61402. * The dirty texture flag value
  61403. */
  61404. static readonly MATERIAL_TextureDirtyFlag: number;
  61405. /**
  61406. * The dirty light flag value
  61407. */
  61408. static readonly MATERIAL_LightDirtyFlag: number;
  61409. /**
  61410. * The dirty fresnel flag value
  61411. */
  61412. static readonly MATERIAL_FresnelDirtyFlag: number;
  61413. /**
  61414. * The dirty attribute flag value
  61415. */
  61416. static readonly MATERIAL_AttributesDirtyFlag: number;
  61417. /**
  61418. * The dirty misc flag value
  61419. */
  61420. static readonly MATERIAL_MiscDirtyFlag: number;
  61421. /**
  61422. * The all dirty flag value
  61423. */
  61424. static readonly MATERIAL_AllDirtyFlag: number;
  61425. /**
  61426. * Returns the triangle fill mode
  61427. */
  61428. static readonly MATERIAL_TriangleFillMode: number;
  61429. /**
  61430. * Returns the wireframe mode
  61431. */
  61432. static readonly MATERIAL_WireFrameFillMode: number;
  61433. /**
  61434. * Returns the point fill mode
  61435. */
  61436. static readonly MATERIAL_PointFillMode: number;
  61437. /**
  61438. * Returns the point list draw mode
  61439. */
  61440. static readonly MATERIAL_PointListDrawMode: number;
  61441. /**
  61442. * Returns the line list draw mode
  61443. */
  61444. static readonly MATERIAL_LineListDrawMode: number;
  61445. /**
  61446. * Returns the line loop draw mode
  61447. */
  61448. static readonly MATERIAL_LineLoopDrawMode: number;
  61449. /**
  61450. * Returns the line strip draw mode
  61451. */
  61452. static readonly MATERIAL_LineStripDrawMode: number;
  61453. /**
  61454. * Returns the triangle strip draw mode
  61455. */
  61456. static readonly MATERIAL_TriangleStripDrawMode: number;
  61457. /**
  61458. * Returns the triangle fan draw mode
  61459. */
  61460. static readonly MATERIAL_TriangleFanDrawMode: number;
  61461. /**
  61462. * Stores the clock-wise side orientation
  61463. */
  61464. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61465. /**
  61466. * Stores the counter clock-wise side orientation
  61467. */
  61468. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61469. /**
  61470. * Nothing
  61471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61472. */
  61473. static readonly ACTION_NothingTrigger: number;
  61474. /**
  61475. * On pick
  61476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61477. */
  61478. static readonly ACTION_OnPickTrigger: number;
  61479. /**
  61480. * On left pick
  61481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61482. */
  61483. static readonly ACTION_OnLeftPickTrigger: number;
  61484. /**
  61485. * On right pick
  61486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61487. */
  61488. static readonly ACTION_OnRightPickTrigger: number;
  61489. /**
  61490. * On center pick
  61491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61492. */
  61493. static readonly ACTION_OnCenterPickTrigger: number;
  61494. /**
  61495. * On pick down
  61496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61497. */
  61498. static readonly ACTION_OnPickDownTrigger: number;
  61499. /**
  61500. * On double pick
  61501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61502. */
  61503. static readonly ACTION_OnDoublePickTrigger: number;
  61504. /**
  61505. * On pick up
  61506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61507. */
  61508. static readonly ACTION_OnPickUpTrigger: number;
  61509. /**
  61510. * On pick out.
  61511. * This trigger will only be raised if you also declared a OnPickDown
  61512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61513. */
  61514. static readonly ACTION_OnPickOutTrigger: number;
  61515. /**
  61516. * On long press
  61517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61518. */
  61519. static readonly ACTION_OnLongPressTrigger: number;
  61520. /**
  61521. * On pointer over
  61522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61523. */
  61524. static readonly ACTION_OnPointerOverTrigger: number;
  61525. /**
  61526. * On pointer out
  61527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61528. */
  61529. static readonly ACTION_OnPointerOutTrigger: number;
  61530. /**
  61531. * On every frame
  61532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61533. */
  61534. static readonly ACTION_OnEveryFrameTrigger: number;
  61535. /**
  61536. * On intersection enter
  61537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61538. */
  61539. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61540. /**
  61541. * On intersection exit
  61542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61543. */
  61544. static readonly ACTION_OnIntersectionExitTrigger: number;
  61545. /**
  61546. * On key down
  61547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61548. */
  61549. static readonly ACTION_OnKeyDownTrigger: number;
  61550. /**
  61551. * On key up
  61552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61553. */
  61554. static readonly ACTION_OnKeyUpTrigger: number;
  61555. /**
  61556. * Billboard mode will only apply to Y axis
  61557. */
  61558. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61559. /**
  61560. * Billboard mode will apply to all axes
  61561. */
  61562. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61563. /**
  61564. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61565. */
  61566. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61567. /**
  61568. * Gets or sets base Assets URL
  61569. */
  61570. static readonly PARTICLES_BaseAssetsUrl: string;
  61571. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61572. * Test order :
  61573. * Is the bounding sphere outside the frustum ?
  61574. * If not, are the bounding box vertices outside the frustum ?
  61575. * It not, then the cullable object is in the frustum.
  61576. */
  61577. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61578. /** Culling strategy : Bounding Sphere Only.
  61579. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61580. * It's also less accurate than the standard because some not visible objects can still be selected.
  61581. * Test : is the bounding sphere outside the frustum ?
  61582. * If not, then the cullable object is in the frustum.
  61583. */
  61584. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61585. /** Culling strategy : Optimistic Inclusion.
  61586. * This in an inclusion test first, then the standard exclusion test.
  61587. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61588. * 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.
  61589. * Anyway, it's as accurate as the standard strategy.
  61590. * Test :
  61591. * Is the cullable object bounding sphere center in the frustum ?
  61592. * If not, apply the default culling strategy.
  61593. */
  61594. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61595. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61596. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61597. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61598. * 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.
  61599. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61600. * Test :
  61601. * Is the cullable object bounding sphere center in the frustum ?
  61602. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61603. */
  61604. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61605. /**
  61606. * No logging while loading
  61607. */
  61608. static readonly SCENELOADER_NO_LOGGING: number;
  61609. /**
  61610. * Minimal logging while loading
  61611. */
  61612. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61613. /**
  61614. * Summary logging while loading
  61615. */
  61616. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61617. /**
  61618. * Detailled logging while loading
  61619. */
  61620. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61626. * Babylon.js
  61627. */
  61628. export class DomManagement {
  61629. /**
  61630. * Checks if the window object exists
  61631. * @returns true if the window object exists
  61632. */
  61633. static IsWindowObjectExist(): boolean;
  61634. /**
  61635. * Extracts text content from a DOM element hierarchy
  61636. * @param element defines the root element
  61637. * @returns a string
  61638. */
  61639. static GetDOMTextContent(element: HTMLElement): string;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /**
  61644. * Logger used througouht the application to allow configuration of
  61645. * the log level required for the messages.
  61646. */
  61647. export class Logger {
  61648. /**
  61649. * No log
  61650. */
  61651. static readonly NoneLogLevel: number;
  61652. /**
  61653. * Only message logs
  61654. */
  61655. static readonly MessageLogLevel: number;
  61656. /**
  61657. * Only warning logs
  61658. */
  61659. static readonly WarningLogLevel: number;
  61660. /**
  61661. * Only error logs
  61662. */
  61663. static readonly ErrorLogLevel: number;
  61664. /**
  61665. * All logs
  61666. */
  61667. static readonly AllLogLevel: number;
  61668. private static _LogCache;
  61669. /**
  61670. * Gets a value indicating the number of loading errors
  61671. * @ignorenaming
  61672. */
  61673. static errorsCount: number;
  61674. /**
  61675. * Callback called when a new log is added
  61676. */
  61677. static OnNewCacheEntry: (entry: string) => void;
  61678. private static _AddLogEntry;
  61679. private static _FormatMessage;
  61680. private static _LogDisabled;
  61681. private static _LogEnabled;
  61682. private static _WarnDisabled;
  61683. private static _WarnEnabled;
  61684. private static _ErrorDisabled;
  61685. private static _ErrorEnabled;
  61686. /**
  61687. * Log a message to the console
  61688. */
  61689. static Log: (message: string) => void;
  61690. /**
  61691. * Write a warning message to the console
  61692. */
  61693. static Warn: (message: string) => void;
  61694. /**
  61695. * Write an error message to the console
  61696. */
  61697. static Error: (message: string) => void;
  61698. /**
  61699. * Gets current log cache (list of logs)
  61700. */
  61701. static readonly LogCache: string;
  61702. /**
  61703. * Clears the log cache
  61704. */
  61705. static ClearLogCache(): void;
  61706. /**
  61707. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61708. */
  61709. static LogLevels: number;
  61710. }
  61711. }
  61712. declare module BABYLON {
  61713. /** @hidden */
  61714. export class _TypeStore {
  61715. /** @hidden */
  61716. static RegisteredTypes: {
  61717. [key: string]: Object;
  61718. };
  61719. /** @hidden */
  61720. static GetClass(fqdn: string): any;
  61721. }
  61722. }
  61723. declare module BABYLON {
  61724. /**
  61725. * Class containing a set of static utilities functions for deep copy.
  61726. */
  61727. export class DeepCopier {
  61728. /**
  61729. * Tries to copy an object by duplicating every property
  61730. * @param source defines the source object
  61731. * @param destination defines the target object
  61732. * @param doNotCopyList defines a list of properties to avoid
  61733. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61734. */
  61735. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61736. }
  61737. }
  61738. declare module BABYLON {
  61739. /**
  61740. * Class containing a set of static utilities functions for precision date
  61741. */
  61742. export class PrecisionDate {
  61743. /**
  61744. * Gets either window.performance.now() if supported or Date.now() else
  61745. */
  61746. static readonly Now: number;
  61747. }
  61748. }
  61749. declare module BABYLON {
  61750. /** @hidden */
  61751. export class _DevTools {
  61752. static WarnImport(name: string): string;
  61753. }
  61754. }
  61755. declare module BABYLON {
  61756. /**
  61757. * Class used to evalaute queries containing `and` and `or` operators
  61758. */
  61759. export class AndOrNotEvaluator {
  61760. /**
  61761. * Evaluate a query
  61762. * @param query defines the query to evaluate
  61763. * @param evaluateCallback defines the callback used to filter result
  61764. * @returns true if the query matches
  61765. */
  61766. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61767. private static _HandleParenthesisContent;
  61768. private static _SimplifyNegation;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * Class used to store custom tags
  61774. */
  61775. export class Tags {
  61776. /**
  61777. * Adds support for tags on the given object
  61778. * @param obj defines the object to use
  61779. */
  61780. static EnableFor(obj: any): void;
  61781. /**
  61782. * Removes tags support
  61783. * @param obj defines the object to use
  61784. */
  61785. static DisableFor(obj: any): void;
  61786. /**
  61787. * Gets a boolean indicating if the given object has tags
  61788. * @param obj defines the object to use
  61789. * @returns a boolean
  61790. */
  61791. static HasTags(obj: any): boolean;
  61792. /**
  61793. * Gets the tags available on a given object
  61794. * @param obj defines the object to use
  61795. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61796. * @returns the tags
  61797. */
  61798. static GetTags(obj: any, asString?: boolean): any;
  61799. /**
  61800. * Adds tags to an object
  61801. * @param obj defines the object to use
  61802. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61803. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61804. */
  61805. static AddTagsTo(obj: any, tagsString: string): void;
  61806. /**
  61807. * @hidden
  61808. */
  61809. static _AddTagTo(obj: any, tag: string): void;
  61810. /**
  61811. * Removes specific tags from a specific object
  61812. * @param obj defines the object to use
  61813. * @param tagsString defines the tags to remove
  61814. */
  61815. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61816. /**
  61817. * @hidden
  61818. */
  61819. static _RemoveTagFrom(obj: any, tag: string): void;
  61820. /**
  61821. * Defines if tags hosted on an object match a given query
  61822. * @param obj defines the object to use
  61823. * @param tagsQuery defines the tag query
  61824. * @returns a boolean
  61825. */
  61826. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61827. }
  61828. }
  61829. declare module BABYLON {
  61830. /**
  61831. * Manages the defines for the Material
  61832. */
  61833. export class MaterialDefines {
  61834. private _keys;
  61835. private _isDirty;
  61836. /** @hidden */
  61837. _renderId: number;
  61838. /** @hidden */
  61839. _areLightsDirty: boolean;
  61840. /** @hidden */
  61841. _areAttributesDirty: boolean;
  61842. /** @hidden */
  61843. _areTexturesDirty: boolean;
  61844. /** @hidden */
  61845. _areFresnelDirty: boolean;
  61846. /** @hidden */
  61847. _areMiscDirty: boolean;
  61848. /** @hidden */
  61849. _areImageProcessingDirty: boolean;
  61850. /** @hidden */
  61851. _normals: boolean;
  61852. /** @hidden */
  61853. _uvs: boolean;
  61854. /** @hidden */
  61855. _needNormals: boolean;
  61856. /** @hidden */
  61857. _needUVs: boolean;
  61858. /**
  61859. * Specifies if the material needs to be re-calculated
  61860. */
  61861. readonly isDirty: boolean;
  61862. /**
  61863. * Marks the material to indicate that it has been re-calculated
  61864. */
  61865. markAsProcessed(): void;
  61866. /**
  61867. * Marks the material to indicate that it needs to be re-calculated
  61868. */
  61869. markAsUnprocessed(): void;
  61870. /**
  61871. * Marks the material to indicate all of its defines need to be re-calculated
  61872. */
  61873. markAllAsDirty(): void;
  61874. /**
  61875. * Marks the material to indicate that image processing needs to be re-calculated
  61876. */
  61877. markAsImageProcessingDirty(): void;
  61878. /**
  61879. * Marks the material to indicate the lights need to be re-calculated
  61880. */
  61881. markAsLightDirty(): void;
  61882. /**
  61883. * Marks the attribute state as changed
  61884. */
  61885. markAsAttributesDirty(): void;
  61886. /**
  61887. * Marks the texture state as changed
  61888. */
  61889. markAsTexturesDirty(): void;
  61890. /**
  61891. * Marks the fresnel state as changed
  61892. */
  61893. markAsFresnelDirty(): void;
  61894. /**
  61895. * Marks the misc state as changed
  61896. */
  61897. markAsMiscDirty(): void;
  61898. /**
  61899. * Rebuilds the material defines
  61900. */
  61901. rebuild(): void;
  61902. /**
  61903. * Specifies if two material defines are equal
  61904. * @param other - A material define instance to compare to
  61905. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61906. */
  61907. isEqual(other: MaterialDefines): boolean;
  61908. /**
  61909. * Clones this instance's defines to another instance
  61910. * @param other - material defines to clone values to
  61911. */
  61912. cloneTo(other: MaterialDefines): void;
  61913. /**
  61914. * Resets the material define values
  61915. */
  61916. reset(): void;
  61917. /**
  61918. * Converts the material define values to a string
  61919. * @returns - String of material define information
  61920. */
  61921. toString(): string;
  61922. }
  61923. }
  61924. declare module BABYLON {
  61925. /**
  61926. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61927. */
  61928. export class PerformanceMonitor {
  61929. private _enabled;
  61930. private _rollingFrameTime;
  61931. private _lastFrameTimeMs;
  61932. /**
  61933. * constructor
  61934. * @param frameSampleSize The number of samples required to saturate the sliding window
  61935. */
  61936. constructor(frameSampleSize?: number);
  61937. /**
  61938. * Samples current frame
  61939. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61940. */
  61941. sampleFrame(timeMs?: number): void;
  61942. /**
  61943. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61944. */
  61945. readonly averageFrameTime: number;
  61946. /**
  61947. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61948. */
  61949. readonly averageFrameTimeVariance: number;
  61950. /**
  61951. * Returns the frame time of the most recent frame
  61952. */
  61953. readonly instantaneousFrameTime: number;
  61954. /**
  61955. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61956. */
  61957. readonly averageFPS: number;
  61958. /**
  61959. * Returns the average framerate in frames per second using the most recent frame time
  61960. */
  61961. readonly instantaneousFPS: number;
  61962. /**
  61963. * Returns true if enough samples have been taken to completely fill the sliding window
  61964. */
  61965. readonly isSaturated: boolean;
  61966. /**
  61967. * Enables contributions to the sliding window sample set
  61968. */
  61969. enable(): void;
  61970. /**
  61971. * Disables contributions to the sliding window sample set
  61972. * Samples will not be interpolated over the disabled period
  61973. */
  61974. disable(): void;
  61975. /**
  61976. * Returns true if sampling is enabled
  61977. */
  61978. readonly isEnabled: boolean;
  61979. /**
  61980. * Resets performance monitor
  61981. */
  61982. reset(): void;
  61983. }
  61984. /**
  61985. * RollingAverage
  61986. *
  61987. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61988. */
  61989. export class RollingAverage {
  61990. /**
  61991. * Current average
  61992. */
  61993. average: number;
  61994. /**
  61995. * Current variance
  61996. */
  61997. variance: number;
  61998. protected _samples: Array<number>;
  61999. protected _sampleCount: number;
  62000. protected _pos: number;
  62001. protected _m2: number;
  62002. /**
  62003. * constructor
  62004. * @param length The number of samples required to saturate the sliding window
  62005. */
  62006. constructor(length: number);
  62007. /**
  62008. * Adds a sample to the sample set
  62009. * @param v The sample value
  62010. */
  62011. add(v: number): void;
  62012. /**
  62013. * Returns previously added values or null if outside of history or outside the sliding window domain
  62014. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62015. * @return Value previously recorded with add() or null if outside of range
  62016. */
  62017. history(i: number): number;
  62018. /**
  62019. * Returns true if enough samples have been taken to completely fill the sliding window
  62020. * @return true if sample-set saturated
  62021. */
  62022. isSaturated(): boolean;
  62023. /**
  62024. * Resets the rolling average (equivalent to 0 samples taken so far)
  62025. */
  62026. reset(): void;
  62027. /**
  62028. * Wraps a value around the sample range boundaries
  62029. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62030. * @return Wrapped position in sample range
  62031. */
  62032. protected _wrapPosition(i: number): number;
  62033. }
  62034. }
  62035. declare module BABYLON {
  62036. /**
  62037. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62038. * The underlying implementation relies on an associative array to ensure the best performances.
  62039. * The value can be anything including 'null' but except 'undefined'
  62040. */
  62041. export class StringDictionary<T> {
  62042. /**
  62043. * This will clear this dictionary and copy the content from the 'source' one.
  62044. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62045. * @param source the dictionary to take the content from and copy to this dictionary
  62046. */
  62047. copyFrom(source: StringDictionary<T>): void;
  62048. /**
  62049. * Get a value based from its key
  62050. * @param key the given key to get the matching value from
  62051. * @return the value if found, otherwise undefined is returned
  62052. */
  62053. get(key: string): T | undefined;
  62054. /**
  62055. * Get a value from its key or add it if it doesn't exist.
  62056. * This method will ensure you that a given key/data will be present in the dictionary.
  62057. * @param key the given key to get the matching value from
  62058. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62059. * The factory will only be invoked if there's no data for the given key.
  62060. * @return the value corresponding to the key.
  62061. */
  62062. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62063. /**
  62064. * Get a value from its key if present in the dictionary otherwise add it
  62065. * @param key the key to get the value from
  62066. * @param val if there's no such key/value pair in the dictionary add it with this value
  62067. * @return the value corresponding to the key
  62068. */
  62069. getOrAdd(key: string, val: T): T;
  62070. /**
  62071. * Check if there's a given key in the dictionary
  62072. * @param key the key to check for
  62073. * @return true if the key is present, false otherwise
  62074. */
  62075. contains(key: string): boolean;
  62076. /**
  62077. * Add a new key and its corresponding value
  62078. * @param key the key to add
  62079. * @param value the value corresponding to the key
  62080. * @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
  62081. */
  62082. add(key: string, value: T): boolean;
  62083. /**
  62084. * Update a specific value associated to a key
  62085. * @param key defines the key to use
  62086. * @param value defines the value to store
  62087. * @returns true if the value was updated (or false if the key was not found)
  62088. */
  62089. set(key: string, value: T): boolean;
  62090. /**
  62091. * Get the element of the given key and remove it from the dictionary
  62092. * @param key defines the key to search
  62093. * @returns the value associated with the key or null if not found
  62094. */
  62095. getAndRemove(key: string): Nullable<T>;
  62096. /**
  62097. * Remove a key/value from the dictionary.
  62098. * @param key the key to remove
  62099. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62100. */
  62101. remove(key: string): boolean;
  62102. /**
  62103. * Clear the whole content of the dictionary
  62104. */
  62105. clear(): void;
  62106. /**
  62107. * Gets the current count
  62108. */
  62109. readonly count: number;
  62110. /**
  62111. * Execute a callback on each key/val of the dictionary.
  62112. * Note that you can remove any element in this dictionary in the callback implementation
  62113. * @param callback the callback to execute on a given key/value pair
  62114. */
  62115. forEach(callback: (key: string, val: T) => void): void;
  62116. /**
  62117. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62118. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62119. * Note that you can remove any element in this dictionary in the callback implementation
  62120. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62121. * @returns the first item
  62122. */
  62123. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62124. private _count;
  62125. private _data;
  62126. }
  62127. }
  62128. declare module BABYLON {
  62129. /**
  62130. * Helper class that provides a small promise polyfill
  62131. */
  62132. export class PromisePolyfill {
  62133. /**
  62134. * Static function used to check if the polyfill is required
  62135. * If this is the case then the function will inject the polyfill to window.Promise
  62136. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62137. */
  62138. static Apply(force?: boolean): void;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Class used to store data that will be store in GPU memory
  62144. */
  62145. export class Buffer {
  62146. private _engine;
  62147. private _buffer;
  62148. /** @hidden */
  62149. _data: Nullable<DataArray>;
  62150. private _updatable;
  62151. private _instanced;
  62152. /**
  62153. * Gets the byte stride.
  62154. */
  62155. readonly byteStride: number;
  62156. /**
  62157. * Constructor
  62158. * @param engine the engine
  62159. * @param data the data to use for this buffer
  62160. * @param updatable whether the data is updatable
  62161. * @param stride the stride (optional)
  62162. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62163. * @param instanced whether the buffer is instanced (optional)
  62164. * @param useBytes set to true if the stride in in bytes (optional)
  62165. */
  62166. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62167. /**
  62168. * Create a new VertexBuffer based on the current buffer
  62169. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62170. * @param offset defines offset in the buffer (0 by default)
  62171. * @param size defines the size in floats of attributes (position is 3 for instance)
  62172. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62173. * @param instanced defines if the vertex buffer contains indexed data
  62174. * @param useBytes defines if the offset and stride are in bytes
  62175. * @returns the new vertex buffer
  62176. */
  62177. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62178. /**
  62179. * Gets a boolean indicating if the Buffer is updatable?
  62180. * @returns true if the buffer is updatable
  62181. */
  62182. isUpdatable(): boolean;
  62183. /**
  62184. * Gets current buffer's data
  62185. * @returns a DataArray or null
  62186. */
  62187. getData(): Nullable<DataArray>;
  62188. /**
  62189. * Gets underlying native buffer
  62190. * @returns underlying native buffer
  62191. */
  62192. getBuffer(): Nullable<WebGLBuffer>;
  62193. /**
  62194. * Gets the stride in float32 units (i.e. byte stride / 4).
  62195. * May not be an integer if the byte stride is not divisible by 4.
  62196. * DEPRECATED. Use byteStride instead.
  62197. * @returns the stride in float32 units
  62198. */
  62199. getStrideSize(): number;
  62200. /**
  62201. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62202. * @param data defines the data to store
  62203. */
  62204. create(data?: Nullable<DataArray>): void;
  62205. /** @hidden */
  62206. _rebuild(): void;
  62207. /**
  62208. * Update current buffer data
  62209. * @param data defines the data to store
  62210. */
  62211. update(data: DataArray): void;
  62212. /**
  62213. * Updates the data directly.
  62214. * @param data the new data
  62215. * @param offset the new offset
  62216. * @param vertexCount the vertex count (optional)
  62217. * @param useBytes set to true if the offset is in bytes
  62218. */
  62219. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62220. /**
  62221. * Release all resources
  62222. */
  62223. dispose(): void;
  62224. }
  62225. /**
  62226. * Specialized buffer used to store vertex data
  62227. */
  62228. export class VertexBuffer {
  62229. /** @hidden */
  62230. _buffer: Buffer;
  62231. private _kind;
  62232. private _size;
  62233. private _ownsBuffer;
  62234. private _instanced;
  62235. private _instanceDivisor;
  62236. /**
  62237. * The byte type.
  62238. */
  62239. static readonly BYTE: number;
  62240. /**
  62241. * The unsigned byte type.
  62242. */
  62243. static readonly UNSIGNED_BYTE: number;
  62244. /**
  62245. * The short type.
  62246. */
  62247. static readonly SHORT: number;
  62248. /**
  62249. * The unsigned short type.
  62250. */
  62251. static readonly UNSIGNED_SHORT: number;
  62252. /**
  62253. * The integer type.
  62254. */
  62255. static readonly INT: number;
  62256. /**
  62257. * The unsigned integer type.
  62258. */
  62259. static readonly UNSIGNED_INT: number;
  62260. /**
  62261. * The float type.
  62262. */
  62263. static readonly FLOAT: number;
  62264. /**
  62265. * Gets or sets the instance divisor when in instanced mode
  62266. */
  62267. instanceDivisor: number;
  62268. /**
  62269. * Gets the byte stride.
  62270. */
  62271. readonly byteStride: number;
  62272. /**
  62273. * Gets the byte offset.
  62274. */
  62275. readonly byteOffset: number;
  62276. /**
  62277. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62278. */
  62279. readonly normalized: boolean;
  62280. /**
  62281. * Gets the data type of each component in the array.
  62282. */
  62283. readonly type: number;
  62284. /**
  62285. * Constructor
  62286. * @param engine the engine
  62287. * @param data the data to use for this vertex buffer
  62288. * @param kind the vertex buffer kind
  62289. * @param updatable whether the data is updatable
  62290. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62291. * @param stride the stride (optional)
  62292. * @param instanced whether the buffer is instanced (optional)
  62293. * @param offset the offset of the data (optional)
  62294. * @param size the number of components (optional)
  62295. * @param type the type of the component (optional)
  62296. * @param normalized whether the data contains normalized data (optional)
  62297. * @param useBytes set to true if stride and offset are in bytes (optional)
  62298. */
  62299. 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);
  62300. /** @hidden */
  62301. _rebuild(): void;
  62302. /**
  62303. * Returns the kind of the VertexBuffer (string)
  62304. * @returns a string
  62305. */
  62306. getKind(): string;
  62307. /**
  62308. * Gets a boolean indicating if the VertexBuffer is updatable?
  62309. * @returns true if the buffer is updatable
  62310. */
  62311. isUpdatable(): boolean;
  62312. /**
  62313. * Gets current buffer's data
  62314. * @returns a DataArray or null
  62315. */
  62316. getData(): Nullable<DataArray>;
  62317. /**
  62318. * Gets underlying native buffer
  62319. * @returns underlying native buffer
  62320. */
  62321. getBuffer(): Nullable<WebGLBuffer>;
  62322. /**
  62323. * Gets the stride in float32 units (i.e. byte stride / 4).
  62324. * May not be an integer if the byte stride is not divisible by 4.
  62325. * DEPRECATED. Use byteStride instead.
  62326. * @returns the stride in float32 units
  62327. */
  62328. getStrideSize(): number;
  62329. /**
  62330. * Returns the offset as a multiple of the type byte length.
  62331. * DEPRECATED. Use byteOffset instead.
  62332. * @returns the offset in bytes
  62333. */
  62334. getOffset(): number;
  62335. /**
  62336. * Returns the number of components per vertex attribute (integer)
  62337. * @returns the size in float
  62338. */
  62339. getSize(): number;
  62340. /**
  62341. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62342. * @returns true if this buffer is instanced
  62343. */
  62344. getIsInstanced(): boolean;
  62345. /**
  62346. * Returns the instancing divisor, zero for non-instanced (integer).
  62347. * @returns a number
  62348. */
  62349. getInstanceDivisor(): number;
  62350. /**
  62351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62352. * @param data defines the data to store
  62353. */
  62354. create(data?: DataArray): void;
  62355. /**
  62356. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62357. * This function will create a new buffer if the current one is not updatable
  62358. * @param data defines the data to store
  62359. */
  62360. update(data: DataArray): void;
  62361. /**
  62362. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62363. * Returns the directly updated WebGLBuffer.
  62364. * @param data the new data
  62365. * @param offset the new offset
  62366. * @param useBytes set to true if the offset is in bytes
  62367. */
  62368. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62369. /**
  62370. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62371. */
  62372. dispose(): void;
  62373. /**
  62374. * Enumerates each value of this vertex buffer as numbers.
  62375. * @param count the number of values to enumerate
  62376. * @param callback the callback function called for each value
  62377. */
  62378. forEach(count: number, callback: (value: number, index: number) => void): void;
  62379. /**
  62380. * Positions
  62381. */
  62382. static readonly PositionKind: string;
  62383. /**
  62384. * Normals
  62385. */
  62386. static readonly NormalKind: string;
  62387. /**
  62388. * Tangents
  62389. */
  62390. static readonly TangentKind: string;
  62391. /**
  62392. * Texture coordinates
  62393. */
  62394. static readonly UVKind: string;
  62395. /**
  62396. * Texture coordinates 2
  62397. */
  62398. static readonly UV2Kind: string;
  62399. /**
  62400. * Texture coordinates 3
  62401. */
  62402. static readonly UV3Kind: string;
  62403. /**
  62404. * Texture coordinates 4
  62405. */
  62406. static readonly UV4Kind: string;
  62407. /**
  62408. * Texture coordinates 5
  62409. */
  62410. static readonly UV5Kind: string;
  62411. /**
  62412. * Texture coordinates 6
  62413. */
  62414. static readonly UV6Kind: string;
  62415. /**
  62416. * Colors
  62417. */
  62418. static readonly ColorKind: string;
  62419. /**
  62420. * Matrix indices (for bones)
  62421. */
  62422. static readonly MatricesIndicesKind: string;
  62423. /**
  62424. * Matrix weights (for bones)
  62425. */
  62426. static readonly MatricesWeightsKind: string;
  62427. /**
  62428. * Additional matrix indices (for bones)
  62429. */
  62430. static readonly MatricesIndicesExtraKind: string;
  62431. /**
  62432. * Additional matrix weights (for bones)
  62433. */
  62434. static readonly MatricesWeightsExtraKind: string;
  62435. /**
  62436. * Deduces the stride given a kind.
  62437. * @param kind The kind string to deduce
  62438. * @returns The deduced stride
  62439. */
  62440. static DeduceStride(kind: string): number;
  62441. /**
  62442. * Gets the byte length of the given type.
  62443. * @param type the type
  62444. * @returns the number of bytes
  62445. */
  62446. static GetTypeByteLength(type: number): number;
  62447. /**
  62448. * Enumerates each value of the given parameters as numbers.
  62449. * @param data the data to enumerate
  62450. * @param byteOffset the byte offset of the data
  62451. * @param byteStride the byte stride of the data
  62452. * @param componentCount the number of components per element
  62453. * @param componentType the type of the component
  62454. * @param count the total number of components
  62455. * @param normalized whether the data is normalized
  62456. * @param callback the callback function called for each value
  62457. */
  62458. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62459. private static _GetFloatValue;
  62460. }
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * Class representing spherical polynomial coefficients to the 3rd degree
  62465. */
  62466. export class SphericalPolynomial {
  62467. /**
  62468. * The x coefficients of the spherical polynomial
  62469. */
  62470. x: Vector3;
  62471. /**
  62472. * The y coefficients of the spherical polynomial
  62473. */
  62474. y: Vector3;
  62475. /**
  62476. * The z coefficients of the spherical polynomial
  62477. */
  62478. z: Vector3;
  62479. /**
  62480. * The xx coefficients of the spherical polynomial
  62481. */
  62482. xx: Vector3;
  62483. /**
  62484. * The yy coefficients of the spherical polynomial
  62485. */
  62486. yy: Vector3;
  62487. /**
  62488. * The zz coefficients of the spherical polynomial
  62489. */
  62490. zz: Vector3;
  62491. /**
  62492. * The xy coefficients of the spherical polynomial
  62493. */
  62494. xy: Vector3;
  62495. /**
  62496. * The yz coefficients of the spherical polynomial
  62497. */
  62498. yz: Vector3;
  62499. /**
  62500. * The zx coefficients of the spherical polynomial
  62501. */
  62502. zx: Vector3;
  62503. /**
  62504. * Adds an ambient color to the spherical polynomial
  62505. * @param color the color to add
  62506. */
  62507. addAmbient(color: Color3): void;
  62508. /**
  62509. * Scales the spherical polynomial by the given amount
  62510. * @param scale the amount to scale
  62511. */
  62512. scale(scale: number): void;
  62513. /**
  62514. * Gets the spherical polynomial from harmonics
  62515. * @param harmonics the spherical harmonics
  62516. * @returns the spherical polynomial
  62517. */
  62518. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62519. /**
  62520. * Constructs a spherical polynomial from an array.
  62521. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62522. * @returns the spherical polynomial
  62523. */
  62524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62525. }
  62526. /**
  62527. * Class representing spherical harmonics coefficients to the 3rd degree
  62528. */
  62529. export class SphericalHarmonics {
  62530. /**
  62531. * The l0,0 coefficients of the spherical harmonics
  62532. */
  62533. l00: Vector3;
  62534. /**
  62535. * The l1,-1 coefficients of the spherical harmonics
  62536. */
  62537. l1_1: Vector3;
  62538. /**
  62539. * The l1,0 coefficients of the spherical harmonics
  62540. */
  62541. l10: Vector3;
  62542. /**
  62543. * The l1,1 coefficients of the spherical harmonics
  62544. */
  62545. l11: Vector3;
  62546. /**
  62547. * The l2,-2 coefficients of the spherical harmonics
  62548. */
  62549. l2_2: Vector3;
  62550. /**
  62551. * The l2,-1 coefficients of the spherical harmonics
  62552. */
  62553. l2_1: Vector3;
  62554. /**
  62555. * The l2,0 coefficients of the spherical harmonics
  62556. */
  62557. l20: Vector3;
  62558. /**
  62559. * The l2,1 coefficients of the spherical harmonics
  62560. */
  62561. l21: Vector3;
  62562. /**
  62563. * The l2,2 coefficients of the spherical harmonics
  62564. */
  62565. lL22: Vector3;
  62566. /**
  62567. * Adds a light to the spherical harmonics
  62568. * @param direction the direction of the light
  62569. * @param color the color of the light
  62570. * @param deltaSolidAngle the delta solid angle of the light
  62571. */
  62572. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62573. /**
  62574. * Scales the spherical harmonics by the given amount
  62575. * @param scale the amount to scale
  62576. */
  62577. scale(scale: number): void;
  62578. /**
  62579. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62580. *
  62581. * ```
  62582. * E_lm = A_l * L_lm
  62583. * ```
  62584. *
  62585. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62586. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62587. * the scaling factors are given in equation 9.
  62588. */
  62589. convertIncidentRadianceToIrradiance(): void;
  62590. /**
  62591. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62592. *
  62593. * ```
  62594. * L = (1/pi) * E * rho
  62595. * ```
  62596. *
  62597. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62598. */
  62599. convertIrradianceToLambertianRadiance(): void;
  62600. /**
  62601. * Gets the spherical harmonics from polynomial
  62602. * @param polynomial the spherical polynomial
  62603. * @returns the spherical harmonics
  62604. */
  62605. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62606. /**
  62607. * Constructs a spherical harmonics from an array.
  62608. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62609. * @returns the spherical harmonics
  62610. */
  62611. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62617. */
  62618. export interface CubeMapInfo {
  62619. /**
  62620. * The pixel array for the front face.
  62621. * This is stored in format, left to right, up to down format.
  62622. */
  62623. front: Nullable<ArrayBufferView>;
  62624. /**
  62625. * The pixel array for the back face.
  62626. * This is stored in format, left to right, up to down format.
  62627. */
  62628. back: Nullable<ArrayBufferView>;
  62629. /**
  62630. * The pixel array for the left face.
  62631. * This is stored in format, left to right, up to down format.
  62632. */
  62633. left: Nullable<ArrayBufferView>;
  62634. /**
  62635. * The pixel array for the right face.
  62636. * This is stored in format, left to right, up to down format.
  62637. */
  62638. right: Nullable<ArrayBufferView>;
  62639. /**
  62640. * The pixel array for the up face.
  62641. * This is stored in format, left to right, up to down format.
  62642. */
  62643. up: Nullable<ArrayBufferView>;
  62644. /**
  62645. * The pixel array for the down face.
  62646. * This is stored in format, left to right, up to down format.
  62647. */
  62648. down: Nullable<ArrayBufferView>;
  62649. /**
  62650. * The size of the cubemap stored.
  62651. *
  62652. * Each faces will be size * size pixels.
  62653. */
  62654. size: number;
  62655. /**
  62656. * The format of the texture.
  62657. *
  62658. * RGBA, RGB.
  62659. */
  62660. format: number;
  62661. /**
  62662. * The type of the texture data.
  62663. *
  62664. * UNSIGNED_INT, FLOAT.
  62665. */
  62666. type: number;
  62667. /**
  62668. * Specifies whether the texture is in gamma space.
  62669. */
  62670. gammaSpace: boolean;
  62671. }
  62672. /**
  62673. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62674. */
  62675. export class PanoramaToCubeMapTools {
  62676. private static FACE_FRONT;
  62677. private static FACE_BACK;
  62678. private static FACE_RIGHT;
  62679. private static FACE_LEFT;
  62680. private static FACE_DOWN;
  62681. private static FACE_UP;
  62682. /**
  62683. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62684. *
  62685. * @param float32Array The source data.
  62686. * @param inputWidth The width of the input panorama.
  62687. * @param inputHeight The height of the input panorama.
  62688. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62689. * @return The cubemap data
  62690. */
  62691. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62692. private static CreateCubemapTexture;
  62693. private static CalcProjectionSpherical;
  62694. }
  62695. }
  62696. declare module BABYLON {
  62697. /**
  62698. * Helper class dealing with the extraction of spherical polynomial dataArray
  62699. * from a cube map.
  62700. */
  62701. export class CubeMapToSphericalPolynomialTools {
  62702. private static FileFaces;
  62703. /**
  62704. * Converts a texture to the according Spherical Polynomial data.
  62705. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62706. *
  62707. * @param texture The texture to extract the information from.
  62708. * @return The Spherical Polynomial data.
  62709. */
  62710. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62711. /**
  62712. * Converts a cubemap to the according Spherical Polynomial data.
  62713. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62714. *
  62715. * @param cubeInfo The Cube map to extract the information from.
  62716. * @return The Spherical Polynomial data.
  62717. */
  62718. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62724. * during the life time of the application.
  62725. */
  62726. export class EngineStore {
  62727. /** Gets the list of created engines */
  62728. static Instances: Engine[];
  62729. /**
  62730. * Gets the latest created engine
  62731. */
  62732. static readonly LastCreatedEngine: Nullable<Engine>;
  62733. /**
  62734. * Gets the latest created scene
  62735. */
  62736. static readonly LastCreatedScene: Nullable<Scene>;
  62737. }
  62738. }
  62739. declare module BABYLON {
  62740. /**
  62741. * Define options used to create a render target texture
  62742. */
  62743. export class RenderTargetCreationOptions {
  62744. /**
  62745. * Specifies is mipmaps must be generated
  62746. */
  62747. generateMipMaps?: boolean;
  62748. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62749. generateDepthBuffer?: boolean;
  62750. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62751. generateStencilBuffer?: boolean;
  62752. /** Defines texture type (int by default) */
  62753. type?: number;
  62754. /** Defines sampling mode (trilinear by default) */
  62755. samplingMode?: number;
  62756. /** Defines format (RGBA by default) */
  62757. format?: number;
  62758. }
  62759. }
  62760. declare module BABYLON {
  62761. /**
  62762. * @hidden
  62763. **/
  62764. export class _AlphaState {
  62765. private _isAlphaBlendDirty;
  62766. private _isBlendFunctionParametersDirty;
  62767. private _isBlendEquationParametersDirty;
  62768. private _isBlendConstantsDirty;
  62769. private _alphaBlend;
  62770. private _blendFunctionParameters;
  62771. private _blendEquationParameters;
  62772. private _blendConstants;
  62773. /**
  62774. * Initializes the state.
  62775. */
  62776. constructor();
  62777. readonly isDirty: boolean;
  62778. alphaBlend: boolean;
  62779. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62780. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62781. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62782. reset(): void;
  62783. apply(gl: WebGLRenderingContext): void;
  62784. }
  62785. }
  62786. declare module BABYLON {
  62787. /**
  62788. * @hidden
  62789. **/
  62790. export class _DepthCullingState {
  62791. private _isDepthTestDirty;
  62792. private _isDepthMaskDirty;
  62793. private _isDepthFuncDirty;
  62794. private _isCullFaceDirty;
  62795. private _isCullDirty;
  62796. private _isZOffsetDirty;
  62797. private _isFrontFaceDirty;
  62798. private _depthTest;
  62799. private _depthMask;
  62800. private _depthFunc;
  62801. private _cull;
  62802. private _cullFace;
  62803. private _zOffset;
  62804. private _frontFace;
  62805. /**
  62806. * Initializes the state.
  62807. */
  62808. constructor();
  62809. readonly isDirty: boolean;
  62810. zOffset: number;
  62811. cullFace: Nullable<number>;
  62812. cull: Nullable<boolean>;
  62813. depthFunc: Nullable<number>;
  62814. depthMask: boolean;
  62815. depthTest: boolean;
  62816. frontFace: Nullable<number>;
  62817. reset(): void;
  62818. apply(gl: WebGLRenderingContext): void;
  62819. }
  62820. }
  62821. declare module BABYLON {
  62822. /**
  62823. * @hidden
  62824. **/
  62825. export class _StencilState {
  62826. /** 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 */
  62827. static readonly ALWAYS: number;
  62828. /** Passed to stencilOperation to specify that stencil value must be kept */
  62829. static readonly KEEP: number;
  62830. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62831. static readonly REPLACE: number;
  62832. private _isStencilTestDirty;
  62833. private _isStencilMaskDirty;
  62834. private _isStencilFuncDirty;
  62835. private _isStencilOpDirty;
  62836. private _stencilTest;
  62837. private _stencilMask;
  62838. private _stencilFunc;
  62839. private _stencilFuncRef;
  62840. private _stencilFuncMask;
  62841. private _stencilOpStencilFail;
  62842. private _stencilOpDepthFail;
  62843. private _stencilOpStencilDepthPass;
  62844. readonly isDirty: boolean;
  62845. stencilFunc: number;
  62846. stencilFuncRef: number;
  62847. stencilFuncMask: number;
  62848. stencilOpStencilFail: number;
  62849. stencilOpDepthFail: number;
  62850. stencilOpStencilDepthPass: number;
  62851. stencilMask: number;
  62852. stencilTest: boolean;
  62853. constructor();
  62854. reset(): void;
  62855. apply(gl: WebGLRenderingContext): void;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * @hidden
  62861. **/
  62862. export class _TimeToken {
  62863. _startTimeQuery: Nullable<WebGLQuery>;
  62864. _endTimeQuery: Nullable<WebGLQuery>;
  62865. _timeElapsedQuery: Nullable<WebGLQuery>;
  62866. _timeElapsedQueryEnded: boolean;
  62867. }
  62868. }
  62869. declare module BABYLON {
  62870. /**
  62871. * Internal interface used to track InternalTexture already bound to the GL context
  62872. */
  62873. export interface IInternalTextureTracker {
  62874. /**
  62875. * Gets or set the previous tracker in the list
  62876. */
  62877. previous: Nullable<IInternalTextureTracker>;
  62878. /**
  62879. * Gets or set the next tracker in the list
  62880. */
  62881. next: Nullable<IInternalTextureTracker>;
  62882. }
  62883. /**
  62884. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62885. */
  62886. export class DummyInternalTextureTracker {
  62887. /**
  62888. * Gets or set the previous tracker in the list
  62889. */
  62890. previous: Nullable<IInternalTextureTracker>;
  62891. /**
  62892. * Gets or set the next tracker in the list
  62893. */
  62894. next: Nullable<IInternalTextureTracker>;
  62895. }
  62896. }
  62897. declare module BABYLON {
  62898. /**
  62899. * Class used to store data associated with WebGL texture data for the engine
  62900. * This class should not be used directly
  62901. */
  62902. export class InternalTexture implements IInternalTextureTracker {
  62903. /** hidden */
  62904. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62905. /**
  62906. * The source of the texture data is unknown
  62907. */
  62908. static DATASOURCE_UNKNOWN: number;
  62909. /**
  62910. * Texture data comes from an URL
  62911. */
  62912. static DATASOURCE_URL: number;
  62913. /**
  62914. * Texture data is only used for temporary storage
  62915. */
  62916. static DATASOURCE_TEMP: number;
  62917. /**
  62918. * Texture data comes from raw data (ArrayBuffer)
  62919. */
  62920. static DATASOURCE_RAW: number;
  62921. /**
  62922. * Texture content is dynamic (video or dynamic texture)
  62923. */
  62924. static DATASOURCE_DYNAMIC: number;
  62925. /**
  62926. * Texture content is generated by rendering to it
  62927. */
  62928. static DATASOURCE_RENDERTARGET: number;
  62929. /**
  62930. * Texture content is part of a multi render target process
  62931. */
  62932. static DATASOURCE_MULTIRENDERTARGET: number;
  62933. /**
  62934. * Texture data comes from a cube data file
  62935. */
  62936. static DATASOURCE_CUBE: number;
  62937. /**
  62938. * Texture data comes from a raw cube data
  62939. */
  62940. static DATASOURCE_CUBERAW: number;
  62941. /**
  62942. * Texture data come from a prefiltered cube data file
  62943. */
  62944. static DATASOURCE_CUBEPREFILTERED: number;
  62945. /**
  62946. * Texture content is raw 3D data
  62947. */
  62948. static DATASOURCE_RAW3D: number;
  62949. /**
  62950. * Texture content is a depth texture
  62951. */
  62952. static DATASOURCE_DEPTHTEXTURE: number;
  62953. /**
  62954. * Texture data comes from a raw cube data encoded with RGBD
  62955. */
  62956. static DATASOURCE_CUBERAW_RGBD: number;
  62957. /**
  62958. * Defines if the texture is ready
  62959. */
  62960. isReady: boolean;
  62961. /**
  62962. * Defines if the texture is a cube texture
  62963. */
  62964. isCube: boolean;
  62965. /**
  62966. * Defines if the texture contains 3D data
  62967. */
  62968. is3D: boolean;
  62969. /**
  62970. * Gets the URL used to load this texture
  62971. */
  62972. url: string;
  62973. /**
  62974. * Gets the sampling mode of the texture
  62975. */
  62976. samplingMode: number;
  62977. /**
  62978. * Gets a boolean indicating if the texture needs mipmaps generation
  62979. */
  62980. generateMipMaps: boolean;
  62981. /**
  62982. * Gets the number of samples used by the texture (WebGL2+ only)
  62983. */
  62984. samples: number;
  62985. /**
  62986. * Gets the type of the texture (int, float...)
  62987. */
  62988. type: number;
  62989. /**
  62990. * Gets the format of the texture (RGB, RGBA...)
  62991. */
  62992. format: number;
  62993. /**
  62994. * Observable called when the texture is loaded
  62995. */
  62996. onLoadedObservable: Observable<InternalTexture>;
  62997. /**
  62998. * Gets the width of the texture
  62999. */
  63000. width: number;
  63001. /**
  63002. * Gets the height of the texture
  63003. */
  63004. height: number;
  63005. /**
  63006. * Gets the depth of the texture
  63007. */
  63008. depth: number;
  63009. /**
  63010. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63011. */
  63012. baseWidth: number;
  63013. /**
  63014. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63015. */
  63016. baseHeight: number;
  63017. /**
  63018. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63019. */
  63020. baseDepth: number;
  63021. /**
  63022. * Gets a boolean indicating if the texture is inverted on Y axis
  63023. */
  63024. invertY: boolean;
  63025. /**
  63026. * Gets or set the previous tracker in the list
  63027. */
  63028. previous: Nullable<IInternalTextureTracker>;
  63029. /**
  63030. * Gets or set the next tracker in the list
  63031. */
  63032. next: Nullable<IInternalTextureTracker>;
  63033. /** @hidden */
  63034. _invertVScale: boolean;
  63035. /** @hidden */
  63036. _initialSlot: number;
  63037. /** @hidden */
  63038. _designatedSlot: number;
  63039. /** @hidden */
  63040. _dataSource: number;
  63041. /** @hidden */
  63042. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63043. /** @hidden */
  63044. _bufferView: Nullable<ArrayBufferView>;
  63045. /** @hidden */
  63046. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63047. /** @hidden */
  63048. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63049. /** @hidden */
  63050. _size: number;
  63051. /** @hidden */
  63052. _extension: string;
  63053. /** @hidden */
  63054. _files: Nullable<string[]>;
  63055. /** @hidden */
  63056. _workingCanvas: HTMLCanvasElement;
  63057. /** @hidden */
  63058. _workingContext: CanvasRenderingContext2D;
  63059. /** @hidden */
  63060. _framebuffer: Nullable<WebGLFramebuffer>;
  63061. /** @hidden */
  63062. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63063. /** @hidden */
  63064. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63065. /** @hidden */
  63066. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63067. /** @hidden */
  63068. _attachments: Nullable<number[]>;
  63069. /** @hidden */
  63070. _cachedCoordinatesMode: Nullable<number>;
  63071. /** @hidden */
  63072. _cachedWrapU: Nullable<number>;
  63073. /** @hidden */
  63074. _cachedWrapV: Nullable<number>;
  63075. /** @hidden */
  63076. _cachedWrapR: Nullable<number>;
  63077. /** @hidden */
  63078. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63079. /** @hidden */
  63080. _isDisabled: boolean;
  63081. /** @hidden */
  63082. _compression: Nullable<string>;
  63083. /** @hidden */
  63084. _generateStencilBuffer: boolean;
  63085. /** @hidden */
  63086. _generateDepthBuffer: boolean;
  63087. /** @hidden */
  63088. _comparisonFunction: number;
  63089. /** @hidden */
  63090. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63091. /** @hidden */
  63092. _lodGenerationScale: number;
  63093. /** @hidden */
  63094. _lodGenerationOffset: number;
  63095. /** @hidden */
  63096. _lodTextureHigh: BaseTexture;
  63097. /** @hidden */
  63098. _lodTextureMid: BaseTexture;
  63099. /** @hidden */
  63100. _lodTextureLow: BaseTexture;
  63101. /** @hidden */
  63102. _isRGBD: boolean;
  63103. /** @hidden */
  63104. _webGLTexture: Nullable<WebGLTexture>;
  63105. /** @hidden */
  63106. _references: number;
  63107. private _engine;
  63108. /**
  63109. * Gets the Engine the texture belongs to.
  63110. * @returns The babylon engine
  63111. */
  63112. getEngine(): Engine;
  63113. /**
  63114. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63115. */
  63116. readonly dataSource: number;
  63117. /**
  63118. * Creates a new InternalTexture
  63119. * @param engine defines the engine to use
  63120. * @param dataSource defines the type of data that will be used
  63121. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63122. */
  63123. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63124. /**
  63125. * Increments the number of references (ie. the number of Texture that point to it)
  63126. */
  63127. incrementReferences(): void;
  63128. /**
  63129. * Change the size of the texture (not the size of the content)
  63130. * @param width defines the new width
  63131. * @param height defines the new height
  63132. * @param depth defines the new depth (1 by default)
  63133. */
  63134. updateSize(width: int, height: int, depth?: int): void;
  63135. /** @hidden */
  63136. _rebuild(): void;
  63137. /** @hidden */
  63138. _swapAndDie(target: InternalTexture): void;
  63139. /**
  63140. * Dispose the current allocated resources
  63141. */
  63142. dispose(): void;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /**
  63147. * This represents the main contract an easing function should follow.
  63148. * Easing functions are used throughout the animation system.
  63149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63150. */
  63151. export interface IEasingFunction {
  63152. /**
  63153. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63154. * of the easing function.
  63155. * The link below provides some of the most common examples of easing functions.
  63156. * @see https://easings.net/
  63157. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63158. * @returns the corresponding value on the curve defined by the easing function
  63159. */
  63160. ease(gradient: number): number;
  63161. }
  63162. /**
  63163. * Base class used for every default easing function.
  63164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63165. */
  63166. export class EasingFunction implements IEasingFunction {
  63167. /**
  63168. * Interpolation follows the mathematical formula associated with the easing function.
  63169. */
  63170. static readonly EASINGMODE_EASEIN: number;
  63171. /**
  63172. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63173. */
  63174. static readonly EASINGMODE_EASEOUT: number;
  63175. /**
  63176. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63177. */
  63178. static readonly EASINGMODE_EASEINOUT: number;
  63179. private _easingMode;
  63180. /**
  63181. * Sets the easing mode of the current function.
  63182. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63183. */
  63184. setEasingMode(easingMode: number): void;
  63185. /**
  63186. * Gets the current easing mode.
  63187. * @returns the easing mode
  63188. */
  63189. getEasingMode(): number;
  63190. /**
  63191. * @hidden
  63192. */
  63193. easeInCore(gradient: number): number;
  63194. /**
  63195. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63196. * of the easing function.
  63197. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63198. * @returns the corresponding value on the curve defined by the easing function
  63199. */
  63200. ease(gradient: number): number;
  63201. }
  63202. /**
  63203. * Easing function with a circle shape (see link below).
  63204. * @see https://easings.net/#easeInCirc
  63205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63206. */
  63207. export class CircleEase extends EasingFunction implements IEasingFunction {
  63208. /** @hidden */
  63209. easeInCore(gradient: number): number;
  63210. }
  63211. /**
  63212. * Easing function with a ease back shape (see link below).
  63213. * @see https://easings.net/#easeInBack
  63214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63215. */
  63216. export class BackEase extends EasingFunction implements IEasingFunction {
  63217. /** Defines the amplitude of the function */
  63218. amplitude: number;
  63219. /**
  63220. * Instantiates a back ease easing
  63221. * @see https://easings.net/#easeInBack
  63222. * @param amplitude Defines the amplitude of the function
  63223. */
  63224. constructor(
  63225. /** Defines the amplitude of the function */
  63226. amplitude?: number);
  63227. /** @hidden */
  63228. easeInCore(gradient: number): number;
  63229. }
  63230. /**
  63231. * Easing function with a bouncing shape (see link below).
  63232. * @see https://easings.net/#easeInBounce
  63233. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63234. */
  63235. export class BounceEase extends EasingFunction implements IEasingFunction {
  63236. /** Defines the number of bounces */
  63237. bounces: number;
  63238. /** Defines the amplitude of the bounce */
  63239. bounciness: number;
  63240. /**
  63241. * Instantiates a bounce easing
  63242. * @see https://easings.net/#easeInBounce
  63243. * @param bounces Defines the number of bounces
  63244. * @param bounciness Defines the amplitude of the bounce
  63245. */
  63246. constructor(
  63247. /** Defines the number of bounces */
  63248. bounces?: number,
  63249. /** Defines the amplitude of the bounce */
  63250. bounciness?: number);
  63251. /** @hidden */
  63252. easeInCore(gradient: number): number;
  63253. }
  63254. /**
  63255. * Easing function with a power of 3 shape (see link below).
  63256. * @see https://easings.net/#easeInCubic
  63257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63258. */
  63259. export class CubicEase extends EasingFunction implements IEasingFunction {
  63260. /** @hidden */
  63261. easeInCore(gradient: number): number;
  63262. }
  63263. /**
  63264. * Easing function with an elastic shape (see link below).
  63265. * @see https://easings.net/#easeInElastic
  63266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63267. */
  63268. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63269. /** Defines the number of oscillations*/
  63270. oscillations: number;
  63271. /** Defines the amplitude of the oscillations*/
  63272. springiness: number;
  63273. /**
  63274. * Instantiates an elastic easing function
  63275. * @see https://easings.net/#easeInElastic
  63276. * @param oscillations Defines the number of oscillations
  63277. * @param springiness Defines the amplitude of the oscillations
  63278. */
  63279. constructor(
  63280. /** Defines the number of oscillations*/
  63281. oscillations?: number,
  63282. /** Defines the amplitude of the oscillations*/
  63283. springiness?: number);
  63284. /** @hidden */
  63285. easeInCore(gradient: number): number;
  63286. }
  63287. /**
  63288. * Easing function with an exponential shape (see link below).
  63289. * @see https://easings.net/#easeInExpo
  63290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63291. */
  63292. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63293. /** Defines the exponent of the function */
  63294. exponent: number;
  63295. /**
  63296. * Instantiates an exponential easing function
  63297. * @see https://easings.net/#easeInExpo
  63298. * @param exponent Defines the exponent of the function
  63299. */
  63300. constructor(
  63301. /** Defines the exponent of the function */
  63302. exponent?: number);
  63303. /** @hidden */
  63304. easeInCore(gradient: number): number;
  63305. }
  63306. /**
  63307. * Easing function with a power shape (see link below).
  63308. * @see https://easings.net/#easeInQuad
  63309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63310. */
  63311. export class PowerEase extends EasingFunction implements IEasingFunction {
  63312. /** Defines the power of the function */
  63313. power: number;
  63314. /**
  63315. * Instantiates an power base easing function
  63316. * @see https://easings.net/#easeInQuad
  63317. * @param power Defines the power of the function
  63318. */
  63319. constructor(
  63320. /** Defines the power of the function */
  63321. power?: number);
  63322. /** @hidden */
  63323. easeInCore(gradient: number): number;
  63324. }
  63325. /**
  63326. * Easing function with a power of 2 shape (see link below).
  63327. * @see https://easings.net/#easeInQuad
  63328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63329. */
  63330. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63331. /** @hidden */
  63332. easeInCore(gradient: number): number;
  63333. }
  63334. /**
  63335. * Easing function with a power of 4 shape (see link below).
  63336. * @see https://easings.net/#easeInQuart
  63337. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63338. */
  63339. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63340. /** @hidden */
  63341. easeInCore(gradient: number): number;
  63342. }
  63343. /**
  63344. * Easing function with a power of 5 shape (see link below).
  63345. * @see https://easings.net/#easeInQuint
  63346. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63347. */
  63348. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63349. /** @hidden */
  63350. easeInCore(gradient: number): number;
  63351. }
  63352. /**
  63353. * Easing function with a sin shape (see link below).
  63354. * @see https://easings.net/#easeInSine
  63355. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63356. */
  63357. export class SineEase extends EasingFunction implements IEasingFunction {
  63358. /** @hidden */
  63359. easeInCore(gradient: number): number;
  63360. }
  63361. /**
  63362. * Easing function with a bezier shape (see link below).
  63363. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63365. */
  63366. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63367. /** Defines the x component of the start tangent in the bezier curve */
  63368. x1: number;
  63369. /** Defines the y component of the start tangent in the bezier curve */
  63370. y1: number;
  63371. /** Defines the x component of the end tangent in the bezier curve */
  63372. x2: number;
  63373. /** Defines the y component of the end tangent in the bezier curve */
  63374. y2: number;
  63375. /**
  63376. * Instantiates a bezier function
  63377. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63378. * @param x1 Defines the x component of the start tangent in the bezier curve
  63379. * @param y1 Defines the y component of the start tangent in the bezier curve
  63380. * @param x2 Defines the x component of the end tangent in the bezier curve
  63381. * @param y2 Defines the y component of the end tangent in the bezier curve
  63382. */
  63383. constructor(
  63384. /** Defines the x component of the start tangent in the bezier curve */
  63385. x1?: number,
  63386. /** Defines the y component of the start tangent in the bezier curve */
  63387. y1?: number,
  63388. /** Defines the x component of the end tangent in the bezier curve */
  63389. x2?: number,
  63390. /** Defines the y component of the end tangent in the bezier curve */
  63391. y2?: number);
  63392. /** @hidden */
  63393. easeInCore(gradient: number): number;
  63394. }
  63395. }
  63396. declare module BABYLON {
  63397. /**
  63398. * Defines an interface which represents an animation key frame
  63399. */
  63400. export interface IAnimationKey {
  63401. /**
  63402. * Frame of the key frame
  63403. */
  63404. frame: number;
  63405. /**
  63406. * Value at the specifies key frame
  63407. */
  63408. value: any;
  63409. /**
  63410. * The input tangent for the cubic hermite spline
  63411. */
  63412. inTangent?: any;
  63413. /**
  63414. * The output tangent for the cubic hermite spline
  63415. */
  63416. outTangent?: any;
  63417. /**
  63418. * The animation interpolation type
  63419. */
  63420. interpolation?: AnimationKeyInterpolation;
  63421. }
  63422. /**
  63423. * Enum for the animation key frame interpolation type
  63424. */
  63425. export enum AnimationKeyInterpolation {
  63426. /**
  63427. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63428. */
  63429. STEP = 1
  63430. }
  63431. }
  63432. declare module BABYLON {
  63433. /**
  63434. * Represents the range of an animation
  63435. */
  63436. export class AnimationRange {
  63437. /**The name of the animation range**/
  63438. name: string;
  63439. /**The starting frame of the animation */
  63440. from: number;
  63441. /**The ending frame of the animation*/
  63442. to: number;
  63443. /**
  63444. * Initializes the range of an animation
  63445. * @param name The name of the animation range
  63446. * @param from The starting frame of the animation
  63447. * @param to The ending frame of the animation
  63448. */
  63449. constructor(
  63450. /**The name of the animation range**/
  63451. name: string,
  63452. /**The starting frame of the animation */
  63453. from: number,
  63454. /**The ending frame of the animation*/
  63455. to: number);
  63456. /**
  63457. * Makes a copy of the animation range
  63458. * @returns A copy of the animation range
  63459. */
  63460. clone(): AnimationRange;
  63461. }
  63462. }
  63463. declare module BABYLON {
  63464. /**
  63465. * Composed of a frame, and an action function
  63466. */
  63467. export class AnimationEvent {
  63468. /** The frame for which the event is triggered **/
  63469. frame: number;
  63470. /** The event to perform when triggered **/
  63471. action: (currentFrame: number) => void;
  63472. /** Specifies if the event should be triggered only once**/
  63473. onlyOnce?: boolean | undefined;
  63474. /**
  63475. * Specifies if the animation event is done
  63476. */
  63477. isDone: boolean;
  63478. /**
  63479. * Initializes the animation event
  63480. * @param frame The frame for which the event is triggered
  63481. * @param action The event to perform when triggered
  63482. * @param onlyOnce Specifies if the event should be triggered only once
  63483. */
  63484. constructor(
  63485. /** The frame for which the event is triggered **/
  63486. frame: number,
  63487. /** The event to perform when triggered **/
  63488. action: (currentFrame: number) => void,
  63489. /** Specifies if the event should be triggered only once**/
  63490. onlyOnce?: boolean | undefined);
  63491. /** @hidden */
  63492. _clone(): AnimationEvent;
  63493. }
  63494. }
  63495. declare module BABYLON {
  63496. /**
  63497. * Interface used to define a behavior
  63498. */
  63499. export interface Behavior<T> {
  63500. /** gets or sets behavior's name */
  63501. name: string;
  63502. /**
  63503. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63504. */
  63505. init(): void;
  63506. /**
  63507. * Called when the behavior is attached to a target
  63508. * @param target defines the target where the behavior is attached to
  63509. */
  63510. attach(target: T): void;
  63511. /**
  63512. * Called when the behavior is detached from its target
  63513. */
  63514. detach(): void;
  63515. }
  63516. /**
  63517. * Interface implemented by classes supporting behaviors
  63518. */
  63519. export interface IBehaviorAware<T> {
  63520. /**
  63521. * Attach a behavior
  63522. * @param behavior defines the behavior to attach
  63523. * @returns the current host
  63524. */
  63525. addBehavior(behavior: Behavior<T>): T;
  63526. /**
  63527. * Remove a behavior from the current object
  63528. * @param behavior defines the behavior to detach
  63529. * @returns the current host
  63530. */
  63531. removeBehavior(behavior: Behavior<T>): T;
  63532. /**
  63533. * Gets a behavior using its name to search
  63534. * @param name defines the name to search
  63535. * @returns the behavior or null if not found
  63536. */
  63537. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63538. }
  63539. }
  63540. declare module BABYLON {
  63541. /**
  63542. * @hidden
  63543. */
  63544. export class IntersectionInfo {
  63545. bu: Nullable<number>;
  63546. bv: Nullable<number>;
  63547. distance: number;
  63548. faceId: number;
  63549. subMeshId: number;
  63550. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63551. }
  63552. }
  63553. declare module BABYLON {
  63554. /**
  63555. * Class used to store bounding sphere information
  63556. */
  63557. export class BoundingSphere {
  63558. /**
  63559. * Gets the center of the bounding sphere in local space
  63560. */
  63561. readonly center: Vector3;
  63562. /**
  63563. * Radius of the bounding sphere in local space
  63564. */
  63565. radius: number;
  63566. /**
  63567. * Gets the center of the bounding sphere in world space
  63568. */
  63569. readonly centerWorld: Vector3;
  63570. /**
  63571. * Radius of the bounding sphere in world space
  63572. */
  63573. radiusWorld: number;
  63574. /**
  63575. * Gets the minimum vector in local space
  63576. */
  63577. readonly minimum: Vector3;
  63578. /**
  63579. * Gets the maximum vector in local space
  63580. */
  63581. readonly maximum: Vector3;
  63582. private _worldMatrix;
  63583. private static readonly TmpVector3;
  63584. /**
  63585. * Creates a new bounding sphere
  63586. * @param min defines the minimum vector (in local space)
  63587. * @param max defines the maximum vector (in local space)
  63588. * @param worldMatrix defines the new world matrix
  63589. */
  63590. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63591. /**
  63592. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63593. * @param min defines the new minimum vector (in local space)
  63594. * @param max defines the new maximum vector (in local space)
  63595. * @param worldMatrix defines the new world matrix
  63596. */
  63597. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63598. /**
  63599. * Scale the current bounding sphere by applying a scale factor
  63600. * @param factor defines the scale factor to apply
  63601. * @returns the current bounding box
  63602. */
  63603. scale(factor: number): BoundingSphere;
  63604. /**
  63605. * Gets the world matrix of the bounding box
  63606. * @returns a matrix
  63607. */
  63608. getWorldMatrix(): DeepImmutable<Matrix>;
  63609. /** @hidden */
  63610. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63611. /**
  63612. * Tests if the bounding sphere is intersecting the frustum planes
  63613. * @param frustumPlanes defines the frustum planes to test
  63614. * @returns true if there is an intersection
  63615. */
  63616. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63617. /**
  63618. * Tests if the bounding sphere center is in between the frustum planes.
  63619. * Used for optimistic fast inclusion.
  63620. * @param frustumPlanes defines the frustum planes to test
  63621. * @returns true if the sphere center is in between the frustum planes
  63622. */
  63623. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63624. /**
  63625. * Tests if a point is inside the bounding sphere
  63626. * @param point defines the point to test
  63627. * @returns true if the point is inside the bounding sphere
  63628. */
  63629. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63630. /**
  63631. * Checks if two sphere intersct
  63632. * @param sphere0 sphere 0
  63633. * @param sphere1 sphere 1
  63634. * @returns true if the speres intersect
  63635. */
  63636. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63637. }
  63638. }
  63639. declare module BABYLON {
  63640. /**
  63641. * Class used to store bounding box information
  63642. */
  63643. export class BoundingBox implements ICullable {
  63644. /**
  63645. * Gets the 8 vectors representing the bounding box in local space
  63646. */
  63647. readonly vectors: Vector3[];
  63648. /**
  63649. * Gets the center of the bounding box in local space
  63650. */
  63651. readonly center: Vector3;
  63652. /**
  63653. * Gets the center of the bounding box in world space
  63654. */
  63655. readonly centerWorld: Vector3;
  63656. /**
  63657. * Gets the extend size in local space
  63658. */
  63659. readonly extendSize: Vector3;
  63660. /**
  63661. * Gets the extend size in world space
  63662. */
  63663. readonly extendSizeWorld: Vector3;
  63664. /**
  63665. * Gets the OBB (object bounding box) directions
  63666. */
  63667. readonly directions: Vector3[];
  63668. /**
  63669. * Gets the 8 vectors representing the bounding box in world space
  63670. */
  63671. readonly vectorsWorld: Vector3[];
  63672. /**
  63673. * Gets the minimum vector in world space
  63674. */
  63675. readonly minimumWorld: Vector3;
  63676. /**
  63677. * Gets the maximum vector in world space
  63678. */
  63679. readonly maximumWorld: Vector3;
  63680. /**
  63681. * Gets the minimum vector in local space
  63682. */
  63683. readonly minimum: Vector3;
  63684. /**
  63685. * Gets the maximum vector in local space
  63686. */
  63687. readonly maximum: Vector3;
  63688. private _worldMatrix;
  63689. private static readonly TmpVector3;
  63690. /**
  63691. * @hidden
  63692. */
  63693. _tag: number;
  63694. /**
  63695. * Creates a new bounding box
  63696. * @param min defines the minimum vector (in local space)
  63697. * @param max defines the maximum vector (in local space)
  63698. * @param worldMatrix defines the new world matrix
  63699. */
  63700. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63701. /**
  63702. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63703. * @param min defines the new minimum vector (in local space)
  63704. * @param max defines the new maximum vector (in local space)
  63705. * @param worldMatrix defines the new world matrix
  63706. */
  63707. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63708. /**
  63709. * Scale the current bounding box by applying a scale factor
  63710. * @param factor defines the scale factor to apply
  63711. * @returns the current bounding box
  63712. */
  63713. scale(factor: number): BoundingBox;
  63714. /**
  63715. * Gets the world matrix of the bounding box
  63716. * @returns a matrix
  63717. */
  63718. getWorldMatrix(): DeepImmutable<Matrix>;
  63719. /** @hidden */
  63720. _update(world: DeepImmutable<Matrix>): void;
  63721. /**
  63722. * Tests if the bounding box is intersecting the frustum planes
  63723. * @param frustumPlanes defines the frustum planes to test
  63724. * @returns true if there is an intersection
  63725. */
  63726. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63727. /**
  63728. * Tests if the bounding box is entirely inside the frustum planes
  63729. * @param frustumPlanes defines the frustum planes to test
  63730. * @returns true if there is an inclusion
  63731. */
  63732. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63733. /**
  63734. * Tests if a point is inside the bounding box
  63735. * @param point defines the point to test
  63736. * @returns true if the point is inside the bounding box
  63737. */
  63738. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63739. /**
  63740. * Tests if the bounding box intersects with a bounding sphere
  63741. * @param sphere defines the sphere to test
  63742. * @returns true if there is an intersection
  63743. */
  63744. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63745. /**
  63746. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63747. * @param min defines the min vector to use
  63748. * @param max defines the max vector to use
  63749. * @returns true if there is an intersection
  63750. */
  63751. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63752. /**
  63753. * Tests if two bounding boxes are intersections
  63754. * @param box0 defines the first box to test
  63755. * @param box1 defines the second box to test
  63756. * @returns true if there is an intersection
  63757. */
  63758. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63759. /**
  63760. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63761. * @param minPoint defines the minimum vector of the bounding box
  63762. * @param maxPoint defines the maximum vector of the bounding box
  63763. * @param sphereCenter defines the sphere center
  63764. * @param sphereRadius defines the sphere radius
  63765. * @returns true if there is an intersection
  63766. */
  63767. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63768. /**
  63769. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63770. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63771. * @param frustumPlanes defines the frustum planes to test
  63772. * @return true if there is an inclusion
  63773. */
  63774. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63775. /**
  63776. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63777. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63778. * @param frustumPlanes defines the frustum planes to test
  63779. * @return true if there is an intersection
  63780. */
  63781. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63782. }
  63783. }
  63784. declare module BABYLON {
  63785. /** @hidden */
  63786. export class Collider {
  63787. /** Define if a collision was found */
  63788. collisionFound: boolean;
  63789. /**
  63790. * Define last intersection point in local space
  63791. */
  63792. intersectionPoint: Vector3;
  63793. /**
  63794. * Define last collided mesh
  63795. */
  63796. collidedMesh: Nullable<AbstractMesh>;
  63797. private _collisionPoint;
  63798. private _planeIntersectionPoint;
  63799. private _tempVector;
  63800. private _tempVector2;
  63801. private _tempVector3;
  63802. private _tempVector4;
  63803. private _edge;
  63804. private _baseToVertex;
  63805. private _destinationPoint;
  63806. private _slidePlaneNormal;
  63807. private _displacementVector;
  63808. /** @hidden */
  63809. _radius: Vector3;
  63810. /** @hidden */
  63811. _retry: number;
  63812. private _velocity;
  63813. private _basePoint;
  63814. private _epsilon;
  63815. /** @hidden */
  63816. _velocityWorldLength: number;
  63817. /** @hidden */
  63818. _basePointWorld: Vector3;
  63819. private _velocityWorld;
  63820. private _normalizedVelocity;
  63821. /** @hidden */
  63822. _initialVelocity: Vector3;
  63823. /** @hidden */
  63824. _initialPosition: Vector3;
  63825. private _nearestDistance;
  63826. private _collisionMask;
  63827. collisionMask: number;
  63828. /**
  63829. * Gets the plane normal used to compute the sliding response (in local space)
  63830. */
  63831. readonly slidePlaneNormal: Vector3;
  63832. /** @hidden */
  63833. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63834. /** @hidden */
  63835. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63836. /** @hidden */
  63837. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63838. /** @hidden */
  63839. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63840. /** @hidden */
  63841. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63842. /** @hidden */
  63843. _getResponse(pos: Vector3, vel: Vector3): void;
  63844. }
  63845. }
  63846. declare module BABYLON {
  63847. /**
  63848. * Interface for cullable objects
  63849. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63850. */
  63851. export interface ICullable {
  63852. /**
  63853. * Checks if the object or part of the object is in the frustum
  63854. * @param frustumPlanes Camera near/planes
  63855. * @returns true if the object is in frustum otherwise false
  63856. */
  63857. isInFrustum(frustumPlanes: Plane[]): boolean;
  63858. /**
  63859. * Checks if a cullable object (mesh...) is in the camera frustum
  63860. * Unlike isInFrustum this cheks the full bounding box
  63861. * @param frustumPlanes Camera near/planes
  63862. * @returns true if the object is in frustum otherwise false
  63863. */
  63864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63865. }
  63866. /**
  63867. * Info for a bounding data of a mesh
  63868. */
  63869. export class BoundingInfo implements ICullable {
  63870. /**
  63871. * Bounding box for the mesh
  63872. */
  63873. readonly boundingBox: BoundingBox;
  63874. /**
  63875. * Bounding sphere for the mesh
  63876. */
  63877. readonly boundingSphere: BoundingSphere;
  63878. private _isLocked;
  63879. private static readonly TmpVector3;
  63880. /**
  63881. * Constructs bounding info
  63882. * @param minimum min vector of the bounding box/sphere
  63883. * @param maximum max vector of the bounding box/sphere
  63884. * @param worldMatrix defines the new world matrix
  63885. */
  63886. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63887. /**
  63888. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63889. * @param min defines the new minimum vector (in local space)
  63890. * @param max defines the new maximum vector (in local space)
  63891. * @param worldMatrix defines the new world matrix
  63892. */
  63893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63894. /**
  63895. * min vector of the bounding box/sphere
  63896. */
  63897. readonly minimum: Vector3;
  63898. /**
  63899. * max vector of the bounding box/sphere
  63900. */
  63901. readonly maximum: Vector3;
  63902. /**
  63903. * If the info is locked and won't be updated to avoid perf overhead
  63904. */
  63905. isLocked: boolean;
  63906. /**
  63907. * Updates the bounding sphere and box
  63908. * @param world world matrix to be used to update
  63909. */
  63910. update(world: DeepImmutable<Matrix>): void;
  63911. /**
  63912. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63913. * @param center New center of the bounding info
  63914. * @param extend New extend of the bounding info
  63915. * @returns the current bounding info
  63916. */
  63917. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63918. /**
  63919. * Scale the current bounding info by applying a scale factor
  63920. * @param factor defines the scale factor to apply
  63921. * @returns the current bounding info
  63922. */
  63923. scale(factor: number): BoundingInfo;
  63924. /**
  63925. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63926. * @param frustumPlanes defines the frustum to test
  63927. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63928. * @returns true if the bounding info is in the frustum planes
  63929. */
  63930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63931. /**
  63932. * Gets the world distance between the min and max points of the bounding box
  63933. */
  63934. readonly diagonalLength: number;
  63935. /**
  63936. * Checks if a cullable object (mesh...) is in the camera frustum
  63937. * Unlike isInFrustum this cheks the full bounding box
  63938. * @param frustumPlanes Camera near/planes
  63939. * @returns true if the object is in frustum otherwise false
  63940. */
  63941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63942. /** @hidden */
  63943. _checkCollision(collider: Collider): boolean;
  63944. /**
  63945. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63946. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63947. * @param point the point to check intersection with
  63948. * @returns if the point intersects
  63949. */
  63950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63951. /**
  63952. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63953. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63954. * @param boundingInfo the bounding info to check intersection with
  63955. * @param precise if the intersection should be done using OBB
  63956. * @returns if the bounding info intersects
  63957. */
  63958. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Defines an array and its length.
  63964. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63965. */
  63966. export interface ISmartArrayLike<T> {
  63967. /**
  63968. * The data of the array.
  63969. */
  63970. data: Array<T>;
  63971. /**
  63972. * The active length of the array.
  63973. */
  63974. length: number;
  63975. }
  63976. /**
  63977. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63978. */
  63979. export class SmartArray<T> implements ISmartArrayLike<T> {
  63980. /**
  63981. * The full set of data from the array.
  63982. */
  63983. data: Array<T>;
  63984. /**
  63985. * The active length of the array.
  63986. */
  63987. length: number;
  63988. protected _id: number;
  63989. /**
  63990. * Instantiates a Smart Array.
  63991. * @param capacity defines the default capacity of the array.
  63992. */
  63993. constructor(capacity: number);
  63994. /**
  63995. * Pushes a value at the end of the active data.
  63996. * @param value defines the object to push in the array.
  63997. */
  63998. push(value: T): void;
  63999. /**
  64000. * Iterates over the active data and apply the lambda to them.
  64001. * @param func defines the action to apply on each value.
  64002. */
  64003. forEach(func: (content: T) => void): void;
  64004. /**
  64005. * Sorts the full sets of data.
  64006. * @param compareFn defines the comparison function to apply.
  64007. */
  64008. sort(compareFn: (a: T, b: T) => number): void;
  64009. /**
  64010. * Resets the active data to an empty array.
  64011. */
  64012. reset(): void;
  64013. /**
  64014. * Releases all the data from the array as well as the array.
  64015. */
  64016. dispose(): void;
  64017. /**
  64018. * Concats the active data with a given array.
  64019. * @param array defines the data to concatenate with.
  64020. */
  64021. concat(array: any): void;
  64022. /**
  64023. * Returns the position of a value in the active data.
  64024. * @param value defines the value to find the index for
  64025. * @returns the index if found in the active data otherwise -1
  64026. */
  64027. indexOf(value: T): number;
  64028. /**
  64029. * Returns whether an element is part of the active data.
  64030. * @param value defines the value to look for
  64031. * @returns true if found in the active data otherwise false
  64032. */
  64033. contains(value: T): boolean;
  64034. private static _GlobalId;
  64035. }
  64036. /**
  64037. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64038. * The data in this array can only be present once
  64039. */
  64040. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64041. private _duplicateId;
  64042. /**
  64043. * Pushes a value at the end of the active data.
  64044. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64045. * @param value defines the object to push in the array.
  64046. */
  64047. push(value: T): void;
  64048. /**
  64049. * Pushes a value at the end of the active data.
  64050. * If the data is already present, it won t be added again
  64051. * @param value defines the object to push in the array.
  64052. * @returns true if added false if it was already present
  64053. */
  64054. pushNoDuplicate(value: T): boolean;
  64055. /**
  64056. * Resets the active data to an empty array.
  64057. */
  64058. reset(): void;
  64059. /**
  64060. * Concats the active data with a given array.
  64061. * This ensures no dupplicate will be present in the result.
  64062. * @param array defines the data to concatenate with.
  64063. */
  64064. concatWithNoDuplicate(array: any): void;
  64065. }
  64066. }
  64067. declare module BABYLON {
  64068. /**
  64069. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64070. * separate meshes. This can be use to improve performances.
  64071. * @see http://doc.babylonjs.com/how_to/multi_materials
  64072. */
  64073. export class MultiMaterial extends Material {
  64074. private _subMaterials;
  64075. /**
  64076. * Gets or Sets the list of Materials used within the multi material.
  64077. * They need to be ordered according to the submeshes order in the associated mesh
  64078. */
  64079. subMaterials: Nullable<Material>[];
  64080. /**
  64081. * Function used to align with Node.getChildren()
  64082. * @returns the list of Materials used within the multi material
  64083. */
  64084. getChildren(): Nullable<Material>[];
  64085. /**
  64086. * Instantiates a new Multi Material
  64087. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64088. * separate meshes. This can be use to improve performances.
  64089. * @see http://doc.babylonjs.com/how_to/multi_materials
  64090. * @param name Define the name in the scene
  64091. * @param scene Define the scene the material belongs to
  64092. */
  64093. constructor(name: string, scene: Scene);
  64094. private _hookArray;
  64095. /**
  64096. * Get one of the submaterial by its index in the submaterials array
  64097. * @param index The index to look the sub material at
  64098. * @returns The Material if the index has been defined
  64099. */
  64100. getSubMaterial(index: number): Nullable<Material>;
  64101. /**
  64102. * Get the list of active textures for the whole sub materials list.
  64103. * @returns All the textures that will be used during the rendering
  64104. */
  64105. getActiveTextures(): BaseTexture[];
  64106. /**
  64107. * Gets the current class name of the material e.g. "MultiMaterial"
  64108. * Mainly use in serialization.
  64109. * @returns the class name
  64110. */
  64111. getClassName(): string;
  64112. /**
  64113. * Checks if the material is ready to render the requested sub mesh
  64114. * @param mesh Define the mesh the submesh belongs to
  64115. * @param subMesh Define the sub mesh to look readyness for
  64116. * @param useInstances Define whether or not the material is used with instances
  64117. * @returns true if ready, otherwise false
  64118. */
  64119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64120. /**
  64121. * Clones the current material and its related sub materials
  64122. * @param name Define the name of the newly cloned material
  64123. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64124. * @returns the cloned material
  64125. */
  64126. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64127. /**
  64128. * Serializes the materials into a JSON representation.
  64129. * @returns the JSON representation
  64130. */
  64131. serialize(): any;
  64132. /**
  64133. * Dispose the material and release its associated resources
  64134. * @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)
  64135. * @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)
  64136. * @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)
  64137. */
  64138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64139. /**
  64140. * Creates a MultiMaterial from parsed MultiMaterial data.
  64141. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64142. * @param scene defines the hosting scene
  64143. * @returns a new MultiMaterial
  64144. */
  64145. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * Class used to represent data loading progression
  64151. */
  64152. export class SceneLoaderFlags {
  64153. private static _ForceFullSceneLoadingForIncremental;
  64154. private static _ShowLoadingScreen;
  64155. private static _CleanBoneMatrixWeights;
  64156. private static _loggingLevel;
  64157. /**
  64158. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64159. */
  64160. static ForceFullSceneLoadingForIncremental: boolean;
  64161. /**
  64162. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64163. */
  64164. static ShowLoadingScreen: boolean;
  64165. /**
  64166. * Defines the current logging level (while loading the scene)
  64167. * @ignorenaming
  64168. */
  64169. static loggingLevel: number;
  64170. /**
  64171. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64172. */
  64173. static CleanBoneMatrixWeights: boolean;
  64174. }
  64175. }
  64176. declare module BABYLON {
  64177. /**
  64178. * 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.
  64179. * @see https://doc.babylonjs.com/how_to/transformnode
  64180. */
  64181. export class TransformNode extends Node {
  64182. /**
  64183. * Object will not rotate to face the camera
  64184. */
  64185. static BILLBOARDMODE_NONE: number;
  64186. /**
  64187. * Object will rotate to face the camera but only on the x axis
  64188. */
  64189. static BILLBOARDMODE_X: number;
  64190. /**
  64191. * Object will rotate to face the camera but only on the y axis
  64192. */
  64193. static BILLBOARDMODE_Y: number;
  64194. /**
  64195. * Object will rotate to face the camera but only on the z axis
  64196. */
  64197. static BILLBOARDMODE_Z: number;
  64198. /**
  64199. * Object will rotate to face the camera
  64200. */
  64201. static BILLBOARDMODE_ALL: number;
  64202. private _forward;
  64203. private _forwardInverted;
  64204. private _up;
  64205. private _right;
  64206. private _rightInverted;
  64207. private _position;
  64208. private _rotation;
  64209. private _rotationQuaternion;
  64210. protected _scaling: Vector3;
  64211. protected _isDirty: boolean;
  64212. private _transformToBoneReferal;
  64213. /**
  64214. * Set the billboard mode. Default is 0.
  64215. *
  64216. * | Value | Type | Description |
  64217. * | --- | --- | --- |
  64218. * | 0 | BILLBOARDMODE_NONE | |
  64219. * | 1 | BILLBOARDMODE_X | |
  64220. * | 2 | BILLBOARDMODE_Y | |
  64221. * | 4 | BILLBOARDMODE_Z | |
  64222. * | 7 | BILLBOARDMODE_ALL | |
  64223. *
  64224. */
  64225. billboardMode: number;
  64226. /**
  64227. * 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
  64228. */
  64229. scalingDeterminant: number;
  64230. /**
  64231. * Sets the distance of the object to max, often used by skybox
  64232. */
  64233. infiniteDistance: boolean;
  64234. /**
  64235. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64236. * By default the system will update normals to compensate
  64237. */
  64238. ignoreNonUniformScaling: boolean;
  64239. /** @hidden */
  64240. _poseMatrix: Matrix;
  64241. /** @hidden */
  64242. _localMatrix: Matrix;
  64243. private _absolutePosition;
  64244. private _pivotMatrix;
  64245. private _pivotMatrixInverse;
  64246. protected _postMultiplyPivotMatrix: boolean;
  64247. protected _isWorldMatrixFrozen: boolean;
  64248. /** @hidden */
  64249. _indexInSceneTransformNodesArray: number;
  64250. /**
  64251. * An event triggered after the world matrix is updated
  64252. */
  64253. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64254. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64255. /**
  64256. * Gets a string identifying the name of the class
  64257. * @returns "TransformNode" string
  64258. */
  64259. getClassName(): string;
  64260. /**
  64261. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64262. */
  64263. position: Vector3;
  64264. /**
  64265. * 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)).
  64266. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64267. */
  64268. rotation: Vector3;
  64269. /**
  64270. * 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)).
  64271. */
  64272. scaling: Vector3;
  64273. /**
  64274. * 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).
  64275. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64276. */
  64277. rotationQuaternion: Nullable<Quaternion>;
  64278. /**
  64279. * The forward direction of that transform in world space.
  64280. */
  64281. readonly forward: Vector3;
  64282. /**
  64283. * The up direction of that transform in world space.
  64284. */
  64285. readonly up: Vector3;
  64286. /**
  64287. * The right direction of that transform in world space.
  64288. */
  64289. readonly right: Vector3;
  64290. /**
  64291. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64292. * @param matrix the matrix to copy the pose from
  64293. * @returns this TransformNode.
  64294. */
  64295. updatePoseMatrix(matrix: Matrix): TransformNode;
  64296. /**
  64297. * Returns the mesh Pose matrix.
  64298. * @returns the pose matrix
  64299. */
  64300. getPoseMatrix(): Matrix;
  64301. /** @hidden */
  64302. _isSynchronized(): boolean;
  64303. /** @hidden */
  64304. _initCache(): void;
  64305. /**
  64306. * Flag the transform node as dirty (Forcing it to update everything)
  64307. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64308. * @returns this transform node
  64309. */
  64310. markAsDirty(property: string): TransformNode;
  64311. /**
  64312. * Returns the current mesh absolute position.
  64313. * Returns a Vector3.
  64314. */
  64315. readonly absolutePosition: Vector3;
  64316. /**
  64317. * Sets a new matrix to apply before all other transformation
  64318. * @param matrix defines the transform matrix
  64319. * @returns the current TransformNode
  64320. */
  64321. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64322. /**
  64323. * Sets a new pivot matrix to the current node
  64324. * @param matrix defines the new pivot matrix to use
  64325. * @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
  64326. * @returns the current TransformNode
  64327. */
  64328. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64329. /**
  64330. * Returns the mesh pivot matrix.
  64331. * Default : Identity.
  64332. * @returns the matrix
  64333. */
  64334. getPivotMatrix(): Matrix;
  64335. /**
  64336. * Prevents the World matrix to be computed any longer.
  64337. * @returns the TransformNode.
  64338. */
  64339. freezeWorldMatrix(): TransformNode;
  64340. /**
  64341. * Allows back the World matrix computation.
  64342. * @returns the TransformNode.
  64343. */
  64344. unfreezeWorldMatrix(): this;
  64345. /**
  64346. * True if the World matrix has been frozen.
  64347. */
  64348. readonly isWorldMatrixFrozen: boolean;
  64349. /**
  64350. * Retuns the mesh absolute position in the World.
  64351. * @returns a Vector3.
  64352. */
  64353. getAbsolutePosition(): Vector3;
  64354. /**
  64355. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64356. * @param absolutePosition the absolute position to set
  64357. * @returns the TransformNode.
  64358. */
  64359. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64360. /**
  64361. * Sets the mesh position in its local space.
  64362. * @param vector3 the position to set in localspace
  64363. * @returns the TransformNode.
  64364. */
  64365. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64366. /**
  64367. * Returns the mesh position in the local space from the current World matrix values.
  64368. * @returns a new Vector3.
  64369. */
  64370. getPositionExpressedInLocalSpace(): Vector3;
  64371. /**
  64372. * Translates the mesh along the passed Vector3 in its local space.
  64373. * @param vector3 the distance to translate in localspace
  64374. * @returns the TransformNode.
  64375. */
  64376. locallyTranslate(vector3: Vector3): TransformNode;
  64377. private static _lookAtVectorCache;
  64378. /**
  64379. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64380. * @param targetPoint the position (must be in same space as current mesh) to look at
  64381. * @param yawCor optional yaw (y-axis) correction in radians
  64382. * @param pitchCor optional pitch (x-axis) correction in radians
  64383. * @param rollCor optional roll (z-axis) correction in radians
  64384. * @param space the choosen space of the target
  64385. * @returns the TransformNode.
  64386. */
  64387. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64388. /**
  64389. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64390. * This Vector3 is expressed in the World space.
  64391. * @param localAxis axis to rotate
  64392. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64393. */
  64394. getDirection(localAxis: Vector3): Vector3;
  64395. /**
  64396. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64397. * localAxis is expressed in the mesh local space.
  64398. * result is computed in the Wordl space from the mesh World matrix.
  64399. * @param localAxis axis to rotate
  64400. * @param result the resulting transformnode
  64401. * @returns this TransformNode.
  64402. */
  64403. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  64404. /**
  64405. * Sets this transform node rotation to the given local axis.
  64406. * @param localAxis the axis in local space
  64407. * @param yawCor optional yaw (y-axis) correction in radians
  64408. * @param pitchCor optional pitch (x-axis) correction in radians
  64409. * @param rollCor optional roll (z-axis) correction in radians
  64410. * @returns this TransformNode
  64411. */
  64412. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  64413. /**
  64414. * Sets a new pivot point to the current node
  64415. * @param point defines the new pivot point to use
  64416. * @param space defines if the point is in world or local space (local by default)
  64417. * @returns the current TransformNode
  64418. */
  64419. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  64420. /**
  64421. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  64422. * @returns the pivot point
  64423. */
  64424. getPivotPoint(): Vector3;
  64425. /**
  64426. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  64427. * @param result the vector3 to store the result
  64428. * @returns this TransformNode.
  64429. */
  64430. getPivotPointToRef(result: Vector3): TransformNode;
  64431. /**
  64432. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  64433. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  64434. */
  64435. getAbsolutePivotPoint(): Vector3;
  64436. /**
  64437. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  64438. * @param result vector3 to store the result
  64439. * @returns this TransformNode.
  64440. */
  64441. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  64442. /**
  64443. * Defines the passed node as the parent of the current node.
  64444. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  64445. * @param node the node ot set as the parent
  64446. * @returns this TransformNode.
  64447. */
  64448. setParent(node: Nullable<Node>): TransformNode;
  64449. private _nonUniformScaling;
  64450. /**
  64451. * True if the scaling property of this object is non uniform eg. (1,2,1)
  64452. */
  64453. readonly nonUniformScaling: boolean;
  64454. /** @hidden */
  64455. _updateNonUniformScalingState(value: boolean): boolean;
  64456. /**
  64457. * Attach the current TransformNode to another TransformNode associated with a bone
  64458. * @param bone Bone affecting the TransformNode
  64459. * @param affectedTransformNode TransformNode associated with the bone
  64460. * @returns this object
  64461. */
  64462. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  64463. /**
  64464. * Detach the transform node if its associated with a bone
  64465. * @returns this object
  64466. */
  64467. detachFromBone(): TransformNode;
  64468. private static _rotationAxisCache;
  64469. /**
  64470. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  64471. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64472. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64473. * The passed axis is also normalized.
  64474. * @param axis the axis to rotate around
  64475. * @param amount the amount to rotate in radians
  64476. * @param space Space to rotate in (Default: local)
  64477. * @returns the TransformNode.
  64478. */
  64479. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  64480. /**
  64481. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  64482. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64483. * The passed axis is also normalized. .
  64484. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  64485. * @param point the point to rotate around
  64486. * @param axis the axis to rotate around
  64487. * @param amount the amount to rotate in radians
  64488. * @returns the TransformNode
  64489. */
  64490. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  64491. /**
  64492. * Translates the mesh along the axis vector for the passed distance in the given space.
  64493. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64494. * @param axis the axis to translate in
  64495. * @param distance the distance to translate
  64496. * @param space Space to rotate in (Default: local)
  64497. * @returns the TransformNode.
  64498. */
  64499. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  64500. /**
  64501. * Adds a rotation step to the mesh current rotation.
  64502. * x, y, z are Euler angles expressed in radians.
  64503. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  64504. * This means this rotation is made in the mesh local space only.
  64505. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  64506. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  64507. * ```javascript
  64508. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  64509. * ```
  64510. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  64511. * 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.
  64512. * @param x Rotation to add
  64513. * @param y Rotation to add
  64514. * @param z Rotation to add
  64515. * @returns the TransformNode.
  64516. */
  64517. addRotation(x: number, y: number, z: number): TransformNode;
  64518. /**
  64519. * Computes the world matrix of the node
  64520. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  64521. * @returns the world matrix
  64522. */
  64523. computeWorldMatrix(force?: boolean): Matrix;
  64524. protected _afterComputeWorldMatrix(): void;
  64525. /**
  64526. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  64527. * @param func callback function to add
  64528. *
  64529. * @returns the TransformNode.
  64530. */
  64531. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64532. /**
  64533. * Removes a registered callback function.
  64534. * @param func callback function to remove
  64535. * @returns the TransformNode.
  64536. */
  64537. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64538. /**
  64539. * Gets the position of the current mesh in camera space
  64540. * @param camera defines the camera to use
  64541. * @returns a position
  64542. */
  64543. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  64544. /**
  64545. * Returns the distance from the mesh to the active camera
  64546. * @param camera defines the camera to use
  64547. * @returns the distance
  64548. */
  64549. getDistanceToCamera(camera?: Nullable<Camera>): number;
  64550. /**
  64551. * Clone the current transform node
  64552. * @param name Name of the new clone
  64553. * @param newParent New parent for the clone
  64554. * @param doNotCloneChildren Do not clone children hierarchy
  64555. * @returns the new transform node
  64556. */
  64557. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  64558. /**
  64559. * Serializes the objects information.
  64560. * @param currentSerializationObject defines the object to serialize in
  64561. * @returns the serialized object
  64562. */
  64563. serialize(currentSerializationObject?: any): any;
  64564. /**
  64565. * Returns a new TransformNode object parsed from the source provided.
  64566. * @param parsedTransformNode is the source.
  64567. * @param scene the scne the object belongs to
  64568. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  64569. * @returns a new TransformNode object parsed from the source provided.
  64570. */
  64571. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  64572. /**
  64573. * Get all child-transformNodes of this node
  64574. * @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
  64575. * @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
  64576. * @returns an array of TransformNode
  64577. */
  64578. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  64579. /**
  64580. * Releases resources associated with this transform node.
  64581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64583. */
  64584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64585. }
  64586. }
  64587. declare module BABYLON {
  64588. /**
  64589. * Class used to override all child animations of a given target
  64590. */
  64591. export class AnimationPropertiesOverride {
  64592. /**
  64593. * Gets or sets a value indicating if animation blending must be used
  64594. */
  64595. enableBlending: boolean;
  64596. /**
  64597. * Gets or sets the blending speed to use when enableBlending is true
  64598. */
  64599. blendingSpeed: number;
  64600. /**
  64601. * Gets or sets the default loop mode to use
  64602. */
  64603. loopMode: number;
  64604. }
  64605. }
  64606. declare module BABYLON {
  64607. /**
  64608. * Class used to store bone information
  64609. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  64610. */
  64611. export class Bone extends Node {
  64612. /**
  64613. * defines the bone name
  64614. */
  64615. name: string;
  64616. private static _tmpVecs;
  64617. private static _tmpQuat;
  64618. private static _tmpMats;
  64619. /**
  64620. * Gets the list of child bones
  64621. */
  64622. children: Bone[];
  64623. /** Gets the animations associated with this bone */
  64624. animations: Animation[];
  64625. /**
  64626. * Gets or sets bone length
  64627. */
  64628. length: number;
  64629. /**
  64630. * @hidden Internal only
  64631. * Set this value to map this bone to a different index in the transform matrices
  64632. * Set this value to -1 to exclude the bone from the transform matrices
  64633. */
  64634. _index: Nullable<number>;
  64635. private _skeleton;
  64636. private _localMatrix;
  64637. private _restPose;
  64638. private _baseMatrix;
  64639. private _absoluteTransform;
  64640. private _invertedAbsoluteTransform;
  64641. private _parent;
  64642. private _scalingDeterminant;
  64643. private _worldTransform;
  64644. private _localScaling;
  64645. private _localRotation;
  64646. private _localPosition;
  64647. private _needToDecompose;
  64648. private _needToCompose;
  64649. /** @hidden */
  64650. _linkedTransformNode: Nullable<TransformNode>;
  64651. /** @hidden */
  64652. /** @hidden */
  64653. _matrix: Matrix;
  64654. /**
  64655. * Create a new bone
  64656. * @param name defines the bone name
  64657. * @param skeleton defines the parent skeleton
  64658. * @param parentBone defines the parent (can be null if the bone is the root)
  64659. * @param localMatrix defines the local matrix
  64660. * @param restPose defines the rest pose matrix
  64661. * @param baseMatrix defines the base matrix
  64662. * @param index defines index of the bone in the hiearchy
  64663. */
  64664. constructor(
  64665. /**
  64666. * defines the bone name
  64667. */
  64668. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  64669. /**
  64670. * Gets the parent skeleton
  64671. * @returns a skeleton
  64672. */
  64673. getSkeleton(): Skeleton;
  64674. /**
  64675. * Gets parent bone
  64676. * @returns a bone or null if the bone is the root of the bone hierarchy
  64677. */
  64678. getParent(): Nullable<Bone>;
  64679. /**
  64680. * Sets the parent bone
  64681. * @param parent defines the parent (can be null if the bone is the root)
  64682. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64683. */
  64684. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  64685. /**
  64686. * Gets the local matrix
  64687. * @returns a matrix
  64688. */
  64689. getLocalMatrix(): Matrix;
  64690. /**
  64691. * Gets the base matrix (initial matrix which remains unchanged)
  64692. * @returns a matrix
  64693. */
  64694. getBaseMatrix(): Matrix;
  64695. /**
  64696. * Gets the rest pose matrix
  64697. * @returns a matrix
  64698. */
  64699. getRestPose(): Matrix;
  64700. /**
  64701. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  64702. */
  64703. getWorldMatrix(): Matrix;
  64704. /**
  64705. * Sets the local matrix to rest pose matrix
  64706. */
  64707. returnToRest(): void;
  64708. /**
  64709. * Gets the inverse of the absolute transform matrix.
  64710. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  64711. * @returns a matrix
  64712. */
  64713. getInvertedAbsoluteTransform(): Matrix;
  64714. /**
  64715. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  64716. * @returns a matrix
  64717. */
  64718. getAbsoluteTransform(): Matrix;
  64719. /**
  64720. * Links with the given transform node.
  64721. * The local matrix of this bone is copied from the transform node every frame.
  64722. * @param transformNode defines the transform node to link to
  64723. */
  64724. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  64725. /** Gets or sets current position (in local space) */
  64726. position: Vector3;
  64727. /** Gets or sets current rotation (in local space) */
  64728. rotation: Vector3;
  64729. /** Gets or sets current rotation quaternion (in local space) */
  64730. rotationQuaternion: Quaternion;
  64731. /** Gets or sets current scaling (in local space) */
  64732. scaling: Vector3;
  64733. /**
  64734. * Gets the animation properties override
  64735. */
  64736. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64737. private _decompose;
  64738. private _compose;
  64739. /**
  64740. * Update the base and local matrices
  64741. * @param matrix defines the new base or local matrix
  64742. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64743. * @param updateLocalMatrix defines if the local matrix should be updated
  64744. */
  64745. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  64746. /** @hidden */
  64747. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  64748. /**
  64749. * Flag the bone as dirty (Forcing it to update everything)
  64750. */
  64751. markAsDirty(): void;
  64752. private _markAsDirtyAndCompose;
  64753. private _markAsDirtyAndDecompose;
  64754. /**
  64755. * Translate the bone in local or world space
  64756. * @param vec The amount to translate the bone
  64757. * @param space The space that the translation is in
  64758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64759. */
  64760. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64761. /**
  64762. * Set the postion of the bone in local or world space
  64763. * @param position The position to set the bone
  64764. * @param space The space that the position is in
  64765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64766. */
  64767. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64768. /**
  64769. * Set the absolute position of the bone (world space)
  64770. * @param position The position to set the bone
  64771. * @param mesh The mesh that this bone is attached to
  64772. */
  64773. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  64774. /**
  64775. * Scale the bone on the x, y and z axes (in local space)
  64776. * @param x The amount to scale the bone on the x axis
  64777. * @param y The amount to scale the bone on the y axis
  64778. * @param z The amount to scale the bone on the z axis
  64779. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  64780. */
  64781. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  64782. /**
  64783. * Set the bone scaling in local space
  64784. * @param scale defines the scaling vector
  64785. */
  64786. setScale(scale: Vector3): void;
  64787. /**
  64788. * Gets the current scaling in local space
  64789. * @returns the current scaling vector
  64790. */
  64791. getScale(): Vector3;
  64792. /**
  64793. * Gets the current scaling in local space and stores it in a target vector
  64794. * @param result defines the target vector
  64795. */
  64796. getScaleToRef(result: Vector3): void;
  64797. /**
  64798. * Set the yaw, pitch, and roll of the bone in local or world space
  64799. * @param yaw The rotation of the bone on the y axis
  64800. * @param pitch The rotation of the bone on the x axis
  64801. * @param roll The rotation of the bone on the z axis
  64802. * @param space The space that the axes of rotation are in
  64803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64804. */
  64805. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  64806. /**
  64807. * Add a rotation to the bone on an axis in local or world space
  64808. * @param axis The axis to rotate the bone on
  64809. * @param amount The amount to rotate the bone
  64810. * @param space The space that the axis is in
  64811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64812. */
  64813. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  64814. /**
  64815. * Set the rotation of the bone to a particular axis angle in local or world space
  64816. * @param axis The axis to rotate the bone on
  64817. * @param angle The angle that the bone should be rotated to
  64818. * @param space The space that the axis is in
  64819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64820. */
  64821. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  64822. /**
  64823. * Set the euler rotation of the bone in local of world space
  64824. * @param rotation The euler rotation that the bone should be set to
  64825. * @param space The space that the rotation is in
  64826. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64827. */
  64828. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64829. /**
  64830. * Set the quaternion rotation of the bone in local of world space
  64831. * @param quat The quaternion rotation that the bone should be set to
  64832. * @param space The space that the rotation is in
  64833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64834. */
  64835. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  64836. /**
  64837. * Set the rotation matrix of the bone in local of world space
  64838. * @param rotMat The rotation matrix that the bone should be set to
  64839. * @param space The space that the rotation is in
  64840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64841. */
  64842. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  64843. private _rotateWithMatrix;
  64844. private _getNegativeRotationToRef;
  64845. /**
  64846. * Get the position of the bone in local or world space
  64847. * @param space The space that the returned position is in
  64848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64849. * @returns The position of the bone
  64850. */
  64851. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  64852. /**
  64853. * Copy the position of the bone to a vector3 in local or world space
  64854. * @param space The space that the returned position is in
  64855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64856. * @param result The vector3 to copy the position to
  64857. */
  64858. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  64859. /**
  64860. * Get the absolute position of the bone (world space)
  64861. * @param mesh The mesh that this bone is attached to
  64862. * @returns The absolute position of the bone
  64863. */
  64864. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  64865. /**
  64866. * Copy the absolute position of the bone (world space) to the result param
  64867. * @param mesh The mesh that this bone is attached to
  64868. * @param result The vector3 to copy the absolute position to
  64869. */
  64870. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  64871. /**
  64872. * Compute the absolute transforms of this bone and its children
  64873. */
  64874. computeAbsoluteTransforms(): void;
  64875. /**
  64876. * Get the world direction from an axis that is in the local space of the bone
  64877. * @param localAxis The local direction that is used to compute the world direction
  64878. * @param mesh The mesh that this bone is attached to
  64879. * @returns The world direction
  64880. */
  64881. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  64882. /**
  64883. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  64884. * @param localAxis The local direction that is used to compute the world direction
  64885. * @param mesh The mesh that this bone is attached to
  64886. * @param result The vector3 that the world direction will be copied to
  64887. */
  64888. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  64889. /**
  64890. * Get the euler rotation of the bone in local or world space
  64891. * @param space The space that the rotation should be in
  64892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64893. * @returns The euler rotation
  64894. */
  64895. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  64896. /**
  64897. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  64898. * @param space The space that the rotation should be in
  64899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64900. * @param result The vector3 that the rotation should be copied to
  64901. */
  64902. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  64903. /**
  64904. * Get the quaternion rotation of the bone in either local or world space
  64905. * @param space The space that the rotation should be in
  64906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64907. * @returns The quaternion rotation
  64908. */
  64909. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  64910. /**
  64911. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  64912. * @param space The space that the rotation should be in
  64913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64914. * @param result The quaternion that the rotation should be copied to
  64915. */
  64916. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  64917. /**
  64918. * Get the rotation matrix of the bone in local or world space
  64919. * @param space The space that the rotation should be in
  64920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64921. * @returns The rotation matrix
  64922. */
  64923. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  64924. /**
  64925. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  64926. * @param space The space that the rotation should be in
  64927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64928. * @param result The quaternion that the rotation should be copied to
  64929. */
  64930. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  64931. /**
  64932. * Get the world position of a point that is in the local space of the bone
  64933. * @param position The local position
  64934. * @param mesh The mesh that this bone is attached to
  64935. * @returns The world position
  64936. */
  64937. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  64938. /**
  64939. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  64940. * @param position The local position
  64941. * @param mesh The mesh that this bone is attached to
  64942. * @param result The vector3 that the world position should be copied to
  64943. */
  64944. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  64945. /**
  64946. * Get the local position of a point that is in world space
  64947. * @param position The world position
  64948. * @param mesh The mesh that this bone is attached to
  64949. * @returns The local position
  64950. */
  64951. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  64952. /**
  64953. * Get the local position of a point that is in world space and copy it to the result param
  64954. * @param position The world position
  64955. * @param mesh The mesh that this bone is attached to
  64956. * @param result The vector3 that the local position should be copied to
  64957. */
  64958. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  64959. }
  64960. }
  64961. declare module BABYLON {
  64962. /**
  64963. * Class for creating a cube texture
  64964. */
  64965. export class CubeTexture extends BaseTexture {
  64966. private _delayedOnLoad;
  64967. /**
  64968. * The url of the texture
  64969. */
  64970. url: string;
  64971. /**
  64972. * Gets or sets the center of the bounding box associated with the cube texture.
  64973. * It must define where the camera used to render the texture was set
  64974. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64975. */
  64976. boundingBoxPosition: Vector3;
  64977. private _boundingBoxSize;
  64978. /**
  64979. * Gets or sets the size of the bounding box associated with the cube texture
  64980. * When defined, the cubemap will switch to local mode
  64981. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64982. * @example https://www.babylonjs-playground.com/#RNASML
  64983. */
  64984. /**
  64985. * Returns the bounding box size
  64986. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64987. */
  64988. boundingBoxSize: Vector3;
  64989. protected _rotationY: number;
  64990. /**
  64991. * Sets texture matrix rotation angle around Y axis in radians.
  64992. */
  64993. /**
  64994. * Gets texture matrix rotation angle around Y axis radians.
  64995. */
  64996. rotationY: number;
  64997. /**
  64998. * Are mip maps generated for this texture or not.
  64999. */
  65000. readonly noMipmap: boolean;
  65001. private _noMipmap;
  65002. private _files;
  65003. private _extensions;
  65004. private _textureMatrix;
  65005. private _format;
  65006. private _createPolynomials;
  65007. /** @hidden */
  65008. _prefiltered: boolean;
  65009. /**
  65010. * Creates a cube texture from an array of image urls
  65011. * @param files defines an array of image urls
  65012. * @param scene defines the hosting scene
  65013. * @param noMipmap specifies if mip maps are not used
  65014. * @returns a cube texture
  65015. */
  65016. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65017. /**
  65018. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65019. * @param url defines the url of the prefiltered texture
  65020. * @param scene defines the scene the texture is attached to
  65021. * @param forcedExtension defines the extension of the file if different from the url
  65022. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65023. * @return the prefiltered texture
  65024. */
  65025. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65026. /**
  65027. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65028. * as prefiltered data.
  65029. * @param rootUrl defines the url of the texture or the root name of the six images
  65030. * @param scene defines the scene the texture is attached to
  65031. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65032. * @param noMipmap defines if mipmaps should be created or not
  65033. * @param files defines the six files to load for the different faces
  65034. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65035. * @param onError defines a callback triggered in case of error during load
  65036. * @param format defines the internal format to use for the texture once loaded
  65037. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65038. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65039. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65040. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65041. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65042. * @return the cube texture
  65043. */
  65044. 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);
  65045. /**
  65046. * Get the current class name of the texture useful for serialization or dynamic coding.
  65047. * @returns "CubeTexture"
  65048. */
  65049. getClassName(): string;
  65050. /**
  65051. * Update the url (and optional buffer) of this texture if url was null during construction.
  65052. * @param url the url of the texture
  65053. * @param forcedExtension defines the extension to use
  65054. * @param onLoad callback called when the texture is loaded (defaults to null)
  65055. */
  65056. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65057. /**
  65058. * Delays loading of the cube texture
  65059. * @param forcedExtension defines the extension to use
  65060. */
  65061. delayLoad(forcedExtension?: string): void;
  65062. /**
  65063. * Returns the reflection texture matrix
  65064. * @returns the reflection texture matrix
  65065. */
  65066. getReflectionTextureMatrix(): Matrix;
  65067. /**
  65068. * Sets the reflection texture matrix
  65069. * @param value Reflection texture matrix
  65070. */
  65071. setReflectionTextureMatrix(value: Matrix): void;
  65072. /**
  65073. * Parses text to create a cube texture
  65074. * @param parsedTexture define the serialized text to read from
  65075. * @param scene defines the hosting scene
  65076. * @param rootUrl defines the root url of the cube texture
  65077. * @returns a cube texture
  65078. */
  65079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65080. /**
  65081. * Makes a clone, or deep copy, of the cube texture
  65082. * @returns a new cube texture
  65083. */
  65084. clone(): CubeTexture;
  65085. }
  65086. }
  65087. declare module BABYLON {
  65088. /** @hidden */
  65089. export var postprocessVertexShader: {
  65090. name: string;
  65091. shader: string;
  65092. };
  65093. }
  65094. declare module BABYLON {
  65095. /**
  65096. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65097. * This is the base of the follow, arc rotate cameras and Free camera
  65098. * @see http://doc.babylonjs.com/features/cameras
  65099. */
  65100. export class TargetCamera extends Camera {
  65101. private static _RigCamTransformMatrix;
  65102. private static _TargetTransformMatrix;
  65103. private static _TargetFocalPoint;
  65104. /**
  65105. * Define the current direction the camera is moving to
  65106. */
  65107. cameraDirection: Vector3;
  65108. /**
  65109. * Define the current rotation the camera is rotating to
  65110. */
  65111. cameraRotation: Vector2;
  65112. /**
  65113. * When set, the up vector of the camera will be updated by the rotation of the camera
  65114. */
  65115. updateUpVectorFromRotation: boolean;
  65116. private _tmpQuaternion;
  65117. /**
  65118. * Define the current rotation of the camera
  65119. */
  65120. rotation: Vector3;
  65121. /**
  65122. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65123. */
  65124. rotationQuaternion: Quaternion;
  65125. /**
  65126. * Define the current speed of the camera
  65127. */
  65128. speed: number;
  65129. /**
  65130. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65131. * around all axis.
  65132. */
  65133. noRotationConstraint: boolean;
  65134. /**
  65135. * Define the current target of the camera as an object or a position.
  65136. */
  65137. lockedTarget: any;
  65138. /** @hidden */
  65139. _currentTarget: Vector3;
  65140. /** @hidden */
  65141. _initialFocalDistance: number;
  65142. /** @hidden */
  65143. _viewMatrix: Matrix;
  65144. /** @hidden */
  65145. _camMatrix: Matrix;
  65146. /** @hidden */
  65147. _cameraTransformMatrix: Matrix;
  65148. /** @hidden */
  65149. _cameraRotationMatrix: Matrix;
  65150. /** @hidden */
  65151. _referencePoint: Vector3;
  65152. /** @hidden */
  65153. _transformedReferencePoint: Vector3;
  65154. protected _globalCurrentTarget: Vector3;
  65155. protected _globalCurrentUpVector: Vector3;
  65156. /** @hidden */
  65157. _reset: () => void;
  65158. private _defaultUp;
  65159. /**
  65160. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65161. * This is the base of the follow, arc rotate cameras and Free camera
  65162. * @see http://doc.babylonjs.com/features/cameras
  65163. * @param name Defines the name of the camera in the scene
  65164. * @param position Defines the start position of the camera in the scene
  65165. * @param scene Defines the scene the camera belongs to
  65166. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65167. */
  65168. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65169. /**
  65170. * Gets the position in front of the camera at a given distance.
  65171. * @param distance The distance from the camera we want the position to be
  65172. * @returns the position
  65173. */
  65174. getFrontPosition(distance: number): Vector3;
  65175. /** @hidden */
  65176. _getLockedTargetPosition(): Nullable<Vector3>;
  65177. private _storedPosition;
  65178. private _storedRotation;
  65179. private _storedRotationQuaternion;
  65180. /**
  65181. * Store current camera state of the camera (fov, position, rotation, etc..)
  65182. * @returns the camera
  65183. */
  65184. storeState(): Camera;
  65185. /**
  65186. * Restored camera state. You must call storeState() first
  65187. * @returns whether it was successful or not
  65188. * @hidden
  65189. */
  65190. _restoreStateValues(): boolean;
  65191. /** @hidden */
  65192. _initCache(): void;
  65193. /** @hidden */
  65194. _updateCache(ignoreParentClass?: boolean): void;
  65195. /** @hidden */
  65196. _isSynchronizedViewMatrix(): boolean;
  65197. /** @hidden */
  65198. _computeLocalCameraSpeed(): number;
  65199. /** @hidden */
  65200. setTarget(target: Vector3): void;
  65201. /**
  65202. * Return the current target position of the camera. This value is expressed in local space.
  65203. * @returns the target position
  65204. */
  65205. getTarget(): Vector3;
  65206. /** @hidden */
  65207. _decideIfNeedsToMove(): boolean;
  65208. /** @hidden */
  65209. _updatePosition(): void;
  65210. /** @hidden */
  65211. _checkInputs(): void;
  65212. protected _updateCameraRotationMatrix(): void;
  65213. /**
  65214. * 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)
  65215. * @returns the current camera
  65216. */
  65217. private _rotateUpVectorWithCameraRotationMatrix;
  65218. private _cachedRotationZ;
  65219. private _cachedQuaternionRotationZ;
  65220. /** @hidden */
  65221. _getViewMatrix(): Matrix;
  65222. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65223. /**
  65224. * @hidden
  65225. */
  65226. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65227. /**
  65228. * @hidden
  65229. */
  65230. _updateRigCameras(): void;
  65231. private _getRigCamPositionAndTarget;
  65232. /**
  65233. * Gets the current object class name.
  65234. * @return the class name
  65235. */
  65236. getClassName(): string;
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /**
  65241. * @ignore
  65242. * This is a list of all the different input types that are available in the application.
  65243. * Fo instance: ArcRotateCameraGamepadInput...
  65244. */
  65245. export var CameraInputTypes: {};
  65246. /**
  65247. * This is the contract to implement in order to create a new input class.
  65248. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65249. */
  65250. export interface ICameraInput<TCamera extends Camera> {
  65251. /**
  65252. * Defines the camera the input is attached to.
  65253. */
  65254. camera: Nullable<TCamera>;
  65255. /**
  65256. * Gets the class name of the current intput.
  65257. * @returns the class name
  65258. */
  65259. getClassName(): string;
  65260. /**
  65261. * Get the friendly name associated with the input class.
  65262. * @returns the input friendly name
  65263. */
  65264. getSimpleName(): string;
  65265. /**
  65266. * Attach the input controls to a specific dom element to get the input from.
  65267. * @param element Defines the element the controls should be listened from
  65268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65269. */
  65270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65271. /**
  65272. * Detach the current controls from the specified dom element.
  65273. * @param element Defines the element to stop listening the inputs from
  65274. */
  65275. detachControl(element: Nullable<HTMLElement>): void;
  65276. /**
  65277. * Update the current camera state depending on the inputs that have been used this frame.
  65278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65279. */
  65280. checkInputs?: () => void;
  65281. }
  65282. /**
  65283. * Represents a map of input types to input instance or input index to input instance.
  65284. */
  65285. export interface CameraInputsMap<TCamera extends Camera> {
  65286. /**
  65287. * Accessor to the input by input type.
  65288. */
  65289. [name: string]: ICameraInput<TCamera>;
  65290. /**
  65291. * Accessor to the input by input index.
  65292. */
  65293. [idx: number]: ICameraInput<TCamera>;
  65294. }
  65295. /**
  65296. * This represents the input manager used within a camera.
  65297. * It helps dealing with all the different kind of input attached to a camera.
  65298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65299. */
  65300. export class CameraInputsManager<TCamera extends Camera> {
  65301. /**
  65302. * Defines the list of inputs attahed to the camera.
  65303. */
  65304. attached: CameraInputsMap<TCamera>;
  65305. /**
  65306. * Defines the dom element the camera is collecting inputs from.
  65307. * This is null if the controls have not been attached.
  65308. */
  65309. attachedElement: Nullable<HTMLElement>;
  65310. /**
  65311. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65312. */
  65313. noPreventDefault: boolean;
  65314. /**
  65315. * Defined the camera the input manager belongs to.
  65316. */
  65317. camera: TCamera;
  65318. /**
  65319. * Update the current camera state depending on the inputs that have been used this frame.
  65320. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65321. */
  65322. checkInputs: () => void;
  65323. /**
  65324. * Instantiate a new Camera Input Manager.
  65325. * @param camera Defines the camera the input manager blongs to
  65326. */
  65327. constructor(camera: TCamera);
  65328. /**
  65329. * Add an input method to a camera
  65330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65331. * @param input camera input method
  65332. */
  65333. add(input: ICameraInput<TCamera>): void;
  65334. /**
  65335. * Remove a specific input method from a camera
  65336. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65337. * @param inputToRemove camera input method
  65338. */
  65339. remove(inputToRemove: ICameraInput<TCamera>): void;
  65340. /**
  65341. * Remove a specific input type from a camera
  65342. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65343. * @param inputType the type of the input to remove
  65344. */
  65345. removeByType(inputType: string): void;
  65346. private _addCheckInputs;
  65347. /**
  65348. * Attach the input controls to the currently attached dom element to listen the events from.
  65349. * @param input Defines the input to attach
  65350. */
  65351. attachInput(input: ICameraInput<TCamera>): void;
  65352. /**
  65353. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65354. * @param element Defines the dom element to collect the events from
  65355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65356. */
  65357. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65358. /**
  65359. * Detach the current manager inputs controls from a specific dom element.
  65360. * @param element Defines the dom element to collect the events from
  65361. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65362. */
  65363. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65364. /**
  65365. * Rebuild the dynamic inputCheck function from the current list of
  65366. * defined inputs in the manager.
  65367. */
  65368. rebuildInputCheck(): void;
  65369. /**
  65370. * Remove all attached input methods from a camera
  65371. */
  65372. clear(): void;
  65373. /**
  65374. * Serialize the current input manager attached to a camera.
  65375. * This ensures than once parsed,
  65376. * the input associated to the camera will be identical to the current ones
  65377. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65378. */
  65379. serialize(serializedCamera: any): void;
  65380. /**
  65381. * Parses an input manager serialized JSON to restore the previous list of inputs
  65382. * and states associated to a camera.
  65383. * @param parsedCamera Defines the JSON to parse
  65384. */
  65385. parse(parsedCamera: any): void;
  65386. }
  65387. }
  65388. declare module BABYLON {
  65389. /**
  65390. * Gather the list of keyboard event types as constants.
  65391. */
  65392. export class KeyboardEventTypes {
  65393. /**
  65394. * The keydown event is fired when a key becomes active (pressed).
  65395. */
  65396. static readonly KEYDOWN: number;
  65397. /**
  65398. * The keyup event is fired when a key has been released.
  65399. */
  65400. static readonly KEYUP: number;
  65401. }
  65402. /**
  65403. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65404. */
  65405. export class KeyboardInfo {
  65406. /**
  65407. * Defines the type of event (KeyboardEventTypes)
  65408. */
  65409. type: number;
  65410. /**
  65411. * Defines the related dom event
  65412. */
  65413. event: KeyboardEvent;
  65414. /**
  65415. * Instantiates a new keyboard info.
  65416. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65417. * @param type Defines the type of event (KeyboardEventTypes)
  65418. * @param event Defines the related dom event
  65419. */
  65420. constructor(
  65421. /**
  65422. * Defines the type of event (KeyboardEventTypes)
  65423. */
  65424. type: number,
  65425. /**
  65426. * Defines the related dom event
  65427. */
  65428. event: KeyboardEvent);
  65429. }
  65430. /**
  65431. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65432. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  65433. */
  65434. export class KeyboardInfoPre extends KeyboardInfo {
  65435. /**
  65436. * Defines the type of event (KeyboardEventTypes)
  65437. */
  65438. type: number;
  65439. /**
  65440. * Defines the related dom event
  65441. */
  65442. event: KeyboardEvent;
  65443. /**
  65444. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  65445. */
  65446. skipOnPointerObservable: boolean;
  65447. /**
  65448. * Instantiates a new keyboard pre info.
  65449. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65450. * @param type Defines the type of event (KeyboardEventTypes)
  65451. * @param event Defines the related dom event
  65452. */
  65453. constructor(
  65454. /**
  65455. * Defines the type of event (KeyboardEventTypes)
  65456. */
  65457. type: number,
  65458. /**
  65459. * Defines the related dom event
  65460. */
  65461. event: KeyboardEvent);
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * Manage the keyboard inputs to control the movement of a free camera.
  65467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65468. */
  65469. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  65470. /**
  65471. * Defines the camera the input is attached to.
  65472. */
  65473. camera: FreeCamera;
  65474. /**
  65475. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  65476. */
  65477. keysUp: number[];
  65478. /**
  65479. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  65480. */
  65481. keysDown: number[];
  65482. /**
  65483. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  65484. */
  65485. keysLeft: number[];
  65486. /**
  65487. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  65488. */
  65489. keysRight: number[];
  65490. private _keys;
  65491. private _onCanvasBlurObserver;
  65492. private _onKeyboardObserver;
  65493. private _engine;
  65494. private _scene;
  65495. /**
  65496. * Attach the input controls to a specific dom element to get the input from.
  65497. * @param element Defines the element the controls should be listened from
  65498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65499. */
  65500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65501. /**
  65502. * Detach the current controls from the specified dom element.
  65503. * @param element Defines the element to stop listening the inputs from
  65504. */
  65505. detachControl(element: Nullable<HTMLElement>): void;
  65506. /**
  65507. * Update the current camera state depending on the inputs that have been used this frame.
  65508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65509. */
  65510. checkInputs(): void;
  65511. /**
  65512. * Gets the class name of the current intput.
  65513. * @returns the class name
  65514. */
  65515. getClassName(): string;
  65516. /** @hidden */
  65517. _onLostFocus(): void;
  65518. /**
  65519. * Get the friendly name associated with the input class.
  65520. * @returns the input friendly name
  65521. */
  65522. getSimpleName(): string;
  65523. }
  65524. }
  65525. declare module BABYLON {
  65526. /**
  65527. * Interface describing all the common properties and methods a shadow light needs to implement.
  65528. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65529. * as well as binding the different shadow properties to the effects.
  65530. */
  65531. export interface IShadowLight extends Light {
  65532. /**
  65533. * The light id in the scene (used in scene.findLighById for instance)
  65534. */
  65535. id: string;
  65536. /**
  65537. * The position the shdow will be casted from.
  65538. */
  65539. position: Vector3;
  65540. /**
  65541. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65542. */
  65543. direction: Vector3;
  65544. /**
  65545. * The transformed position. Position of the light in world space taking parenting in account.
  65546. */
  65547. transformedPosition: Vector3;
  65548. /**
  65549. * The transformed direction. Direction of the light in world space taking parenting in account.
  65550. */
  65551. transformedDirection: Vector3;
  65552. /**
  65553. * The friendly name of the light in the scene.
  65554. */
  65555. name: string;
  65556. /**
  65557. * Defines the shadow projection clipping minimum z value.
  65558. */
  65559. shadowMinZ: number;
  65560. /**
  65561. * Defines the shadow projection clipping maximum z value.
  65562. */
  65563. shadowMaxZ: number;
  65564. /**
  65565. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65566. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65567. */
  65568. computeTransformedInformation(): boolean;
  65569. /**
  65570. * Gets the scene the light belongs to.
  65571. * @returns The scene
  65572. */
  65573. getScene(): Scene;
  65574. /**
  65575. * Callback defining a custom Projection Matrix Builder.
  65576. * This can be used to override the default projection matrix computation.
  65577. */
  65578. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65579. /**
  65580. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65581. * @param matrix The materix to updated with the projection information
  65582. * @param viewMatrix The transform matrix of the light
  65583. * @param renderList The list of mesh to render in the map
  65584. * @returns The current light
  65585. */
  65586. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65587. /**
  65588. * Gets the current depth scale used in ESM.
  65589. * @returns The scale
  65590. */
  65591. getDepthScale(): number;
  65592. /**
  65593. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65594. * @returns true if a cube texture needs to be use
  65595. */
  65596. needCube(): boolean;
  65597. /**
  65598. * Detects if the projection matrix requires to be recomputed this frame.
  65599. * @returns true if it requires to be recomputed otherwise, false.
  65600. */
  65601. needProjectionMatrixCompute(): boolean;
  65602. /**
  65603. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65604. */
  65605. forceProjectionMatrixCompute(): void;
  65606. /**
  65607. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65608. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65609. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65610. */
  65611. getShadowDirection(faceIndex?: number): Vector3;
  65612. /**
  65613. * Gets the minZ used for shadow according to both the scene and the light.
  65614. * @param activeCamera The camera we are returning the min for
  65615. * @returns the depth min z
  65616. */
  65617. getDepthMinZ(activeCamera: Camera): number;
  65618. /**
  65619. * Gets the maxZ used for shadow according to both the scene and the light.
  65620. * @param activeCamera The camera we are returning the max for
  65621. * @returns the depth max z
  65622. */
  65623. getDepthMaxZ(activeCamera: Camera): number;
  65624. }
  65625. /**
  65626. * Base implementation IShadowLight
  65627. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65628. */
  65629. export abstract class ShadowLight extends Light implements IShadowLight {
  65630. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65631. protected _position: Vector3;
  65632. protected _setPosition(value: Vector3): void;
  65633. /**
  65634. * Sets the position the shadow will be casted from. Also use as the light position for both
  65635. * point and spot lights.
  65636. */
  65637. /**
  65638. * Sets the position the shadow will be casted from. Also use as the light position for both
  65639. * point and spot lights.
  65640. */
  65641. position: Vector3;
  65642. protected _direction: Vector3;
  65643. protected _setDirection(value: Vector3): void;
  65644. /**
  65645. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65646. * Also use as the light direction on spot and directional lights.
  65647. */
  65648. /**
  65649. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65650. * Also use as the light direction on spot and directional lights.
  65651. */
  65652. direction: Vector3;
  65653. private _shadowMinZ;
  65654. /**
  65655. * Gets the shadow projection clipping minimum z value.
  65656. */
  65657. /**
  65658. * Sets the shadow projection clipping minimum z value.
  65659. */
  65660. shadowMinZ: number;
  65661. private _shadowMaxZ;
  65662. /**
  65663. * Sets the shadow projection clipping maximum z value.
  65664. */
  65665. /**
  65666. * Gets the shadow projection clipping maximum z value.
  65667. */
  65668. shadowMaxZ: number;
  65669. /**
  65670. * Callback defining a custom Projection Matrix Builder.
  65671. * This can be used to override the default projection matrix computation.
  65672. */
  65673. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65674. /**
  65675. * The transformed position. Position of the light in world space taking parenting in account.
  65676. */
  65677. transformedPosition: Vector3;
  65678. /**
  65679. * The transformed direction. Direction of the light in world space taking parenting in account.
  65680. */
  65681. transformedDirection: Vector3;
  65682. private _needProjectionMatrixCompute;
  65683. /**
  65684. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65685. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65686. */
  65687. computeTransformedInformation(): boolean;
  65688. /**
  65689. * Return the depth scale used for the shadow map.
  65690. * @returns the depth scale.
  65691. */
  65692. getDepthScale(): number;
  65693. /**
  65694. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65695. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65696. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65697. */
  65698. getShadowDirection(faceIndex?: number): Vector3;
  65699. /**
  65700. * Returns the ShadowLight absolute position in the World.
  65701. * @returns the position vector in world space
  65702. */
  65703. getAbsolutePosition(): Vector3;
  65704. /**
  65705. * Sets the ShadowLight direction toward the passed target.
  65706. * @param target The point to target in local space
  65707. * @returns the updated ShadowLight direction
  65708. */
  65709. setDirectionToTarget(target: Vector3): Vector3;
  65710. /**
  65711. * Returns the light rotation in euler definition.
  65712. * @returns the x y z rotation in local space.
  65713. */
  65714. getRotation(): Vector3;
  65715. /**
  65716. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65717. * @returns true if a cube texture needs to be use
  65718. */
  65719. needCube(): boolean;
  65720. /**
  65721. * Detects if the projection matrix requires to be recomputed this frame.
  65722. * @returns true if it requires to be recomputed otherwise, false.
  65723. */
  65724. needProjectionMatrixCompute(): boolean;
  65725. /**
  65726. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65727. */
  65728. forceProjectionMatrixCompute(): void;
  65729. /** @hidden */
  65730. _initCache(): void;
  65731. /** @hidden */
  65732. _isSynchronized(): boolean;
  65733. /**
  65734. * Computes the world matrix of the node
  65735. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65736. * @returns the world matrix
  65737. */
  65738. computeWorldMatrix(force?: boolean): Matrix;
  65739. /**
  65740. * Gets the minZ used for shadow according to both the scene and the light.
  65741. * @param activeCamera The camera we are returning the min for
  65742. * @returns the depth min z
  65743. */
  65744. getDepthMinZ(activeCamera: Camera): number;
  65745. /**
  65746. * Gets the maxZ used for shadow according to both the scene and the light.
  65747. * @param activeCamera The camera we are returning the max for
  65748. * @returns the depth max z
  65749. */
  65750. getDepthMaxZ(activeCamera: Camera): number;
  65751. /**
  65752. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65753. * @param matrix The materix to updated with the projection information
  65754. * @param viewMatrix The transform matrix of the light
  65755. * @param renderList The list of mesh to render in the map
  65756. * @returns The current light
  65757. */
  65758. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65759. }
  65760. }
  65761. declare module BABYLON {
  65762. /**
  65763. * "Static Class" containing the most commonly used helper while dealing with material for
  65764. * rendering purpose.
  65765. *
  65766. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65767. *
  65768. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65769. */
  65770. export class MaterialHelper {
  65771. /**
  65772. * Bind the current view position to an effect.
  65773. * @param effect The effect to be bound
  65774. * @param scene The scene the eyes position is used from
  65775. */
  65776. static BindEyePosition(effect: Effect, scene: Scene): void;
  65777. /**
  65778. * Helps preparing the defines values about the UVs in used in the effect.
  65779. * UVs are shared as much as we can accross channels in the shaders.
  65780. * @param texture The texture we are preparing the UVs for
  65781. * @param defines The defines to update
  65782. * @param key The channel key "diffuse", "specular"... used in the shader
  65783. */
  65784. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65785. /**
  65786. * Binds a texture matrix value to its corrsponding uniform
  65787. * @param texture The texture to bind the matrix for
  65788. * @param uniformBuffer The uniform buffer receivin the data
  65789. * @param key The channel key "diffuse", "specular"... used in the shader
  65790. */
  65791. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65792. /**
  65793. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65794. * @param mesh defines the current mesh
  65795. * @param scene defines the current scene
  65796. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65797. * @param pointsCloud defines if point cloud rendering has to be turned on
  65798. * @param fogEnabled defines if fog has to be turned on
  65799. * @param alphaTest defines if alpha testing has to be turned on
  65800. * @param defines defines the current list of defines
  65801. */
  65802. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65803. /**
  65804. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65805. * @param scene defines the current scene
  65806. * @param engine defines the current engine
  65807. * @param defines specifies the list of active defines
  65808. * @param useInstances defines if instances have to be turned on
  65809. * @param useClipPlane defines if clip plane have to be turned on
  65810. */
  65811. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65812. /**
  65813. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65814. * @param mesh The mesh containing the geometry data we will draw
  65815. * @param defines The defines to update
  65816. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65817. * @param useBones Precise whether bones should be used or not (override mesh info)
  65818. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65819. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65820. * @returns false if defines are considered not dirty and have not been checked
  65821. */
  65822. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65823. /**
  65824. * Prepares the defines related to the light information passed in parameter
  65825. * @param scene The scene we are intending to draw
  65826. * @param mesh The mesh the effect is compiling for
  65827. * @param defines The defines to update
  65828. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65829. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65830. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65831. * @returns true if normals will be required for the rest of the effect
  65832. */
  65833. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65834. /**
  65835. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65836. * that won t be acctive due to defines being turned off.
  65837. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65838. * @param samplersList The samplers list
  65839. * @param defines The defines helping in the list generation
  65840. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65841. */
  65842. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65843. /**
  65844. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65845. * @param defines The defines to update while falling back
  65846. * @param fallbacks The authorized effect fallbacks
  65847. * @param maxSimultaneousLights The maximum number of lights allowed
  65848. * @param rank the current rank of the Effect
  65849. * @returns The newly affected rank
  65850. */
  65851. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65852. /**
  65853. * Prepares the list of attributes required for morph targets according to the effect defines.
  65854. * @param attribs The current list of supported attribs
  65855. * @param mesh The mesh to prepare the morph targets attributes for
  65856. * @param defines The current Defines of the effect
  65857. */
  65858. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65859. /**
  65860. * Prepares the list of attributes required for bones according to the effect defines.
  65861. * @param attribs The current list of supported attribs
  65862. * @param mesh The mesh to prepare the bones attributes for
  65863. * @param defines The current Defines of the effect
  65864. * @param fallbacks The current efffect fallback strategy
  65865. */
  65866. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  65867. /**
  65868. * Prepares the list of attributes required for instances according to the effect defines.
  65869. * @param attribs The current list of supported attribs
  65870. * @param defines The current Defines of the effect
  65871. */
  65872. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  65873. /**
  65874. * Binds the light shadow information to the effect for the given mesh.
  65875. * @param light The light containing the generator
  65876. * @param scene The scene the lights belongs to
  65877. * @param mesh The mesh we are binding the information to render
  65878. * @param lightIndex The light index in the effect used to render the mesh
  65879. * @param effect The effect we are binding the data to
  65880. */
  65881. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  65882. /**
  65883. * Binds the light information to the effect.
  65884. * @param light The light containing the generator
  65885. * @param effect The effect we are binding the data to
  65886. * @param lightIndex The light index in the effect used to render
  65887. */
  65888. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  65889. /**
  65890. * Binds the lights information from the scene to the effect for the given mesh.
  65891. * @param scene The scene the lights belongs to
  65892. * @param mesh The mesh we are binding the information to render
  65893. * @param effect The effect we are binding the data to
  65894. * @param defines The generated defines for the effect
  65895. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65896. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65897. */
  65898. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  65899. private static _tempFogColor;
  65900. /**
  65901. * Binds the fog information from the scene to the effect for the given mesh.
  65902. * @param scene The scene the lights belongs to
  65903. * @param mesh The mesh we are binding the information to render
  65904. * @param effect The effect we are binding the data to
  65905. * @param linearSpace Defines if the fog effect is applied in linear space
  65906. */
  65907. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  65908. /**
  65909. * Binds the bones information from the mesh to the effect.
  65910. * @param mesh The mesh we are binding the information to render
  65911. * @param effect The effect we are binding the data to
  65912. */
  65913. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  65914. /**
  65915. * Binds the morph targets information from the mesh to the effect.
  65916. * @param abstractMesh The mesh we are binding the information to render
  65917. * @param effect The effect we are binding the data to
  65918. */
  65919. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  65920. /**
  65921. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65922. * @param defines The generated defines used in the effect
  65923. * @param effect The effect we are binding the data to
  65924. * @param scene The scene we are willing to render with logarithmic scale for
  65925. */
  65926. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  65927. /**
  65928. * Binds the clip plane information from the scene to the effect.
  65929. * @param scene The scene the clip plane information are extracted from
  65930. * @param effect The effect we are binding the data to
  65931. */
  65932. static BindClipPlane(effect: Effect, scene: Scene): void;
  65933. }
  65934. }
  65935. declare module BABYLON {
  65936. /** @hidden */
  65937. export var kernelBlurVaryingDeclaration: {
  65938. name: string;
  65939. shader: string;
  65940. };
  65941. }
  65942. declare module BABYLON {
  65943. /** @hidden */
  65944. export var kernelBlurFragment: {
  65945. name: string;
  65946. shader: string;
  65947. };
  65948. }
  65949. declare module BABYLON {
  65950. /** @hidden */
  65951. export var kernelBlurFragment2: {
  65952. name: string;
  65953. shader: string;
  65954. };
  65955. }
  65956. declare module BABYLON {
  65957. /** @hidden */
  65958. export var kernelBlurPixelShader: {
  65959. name: string;
  65960. shader: string;
  65961. };
  65962. }
  65963. declare module BABYLON {
  65964. /** @hidden */
  65965. export var kernelBlurVertex: {
  65966. name: string;
  65967. shader: string;
  65968. };
  65969. }
  65970. declare module BABYLON {
  65971. /** @hidden */
  65972. export var kernelBlurVertexShader: {
  65973. name: string;
  65974. shader: string;
  65975. };
  65976. }
  65977. declare module BABYLON {
  65978. /**
  65979. * The Blur Post Process which blurs an image based on a kernel and direction.
  65980. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  65981. */
  65982. export class BlurPostProcess extends PostProcess {
  65983. /** The direction in which to blur the image. */
  65984. direction: Vector2;
  65985. private blockCompilation;
  65986. protected _kernel: number;
  65987. protected _idealKernel: number;
  65988. protected _packedFloat: boolean;
  65989. private _staticDefines;
  65990. /**
  65991. * Sets the length in pixels of the blur sample region
  65992. */
  65993. /**
  65994. * Gets the length in pixels of the blur sample region
  65995. */
  65996. kernel: number;
  65997. /**
  65998. * Sets wether or not the blur needs to unpack/repack floats
  65999. */
  66000. /**
  66001. * Gets wether or not the blur is unpacking/repacking floats
  66002. */
  66003. packedFloat: boolean;
  66004. /**
  66005. * Creates a new instance BlurPostProcess
  66006. * @param name The name of the effect.
  66007. * @param direction The direction in which to blur the image.
  66008. * @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.
  66009. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66010. * @param camera The camera to apply the render pass to.
  66011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66012. * @param engine The engine which the post process will be applied. (default: current engine)
  66013. * @param reusable If the post process can be reused on the same frame. (default: false)
  66014. * @param textureType Type of textures used when performing the post process. (default: 0)
  66015. * @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)
  66016. */
  66017. constructor(name: string,
  66018. /** The direction in which to blur the image. */
  66019. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66020. /**
  66021. * Updates the effect with the current post process compile time values and recompiles the shader.
  66022. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66023. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66024. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66025. * @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
  66026. * @param onCompiled Called when the shader has been compiled.
  66027. * @param onError Called if there is an error when compiling a shader.
  66028. */
  66029. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66030. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66031. /**
  66032. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66033. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66034. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66035. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66036. * The gaps between physical kernels are compensated for in the weighting of the samples
  66037. * @param idealKernel Ideal blur kernel.
  66038. * @return Nearest best kernel.
  66039. */
  66040. protected _nearestBestKernel(idealKernel: number): number;
  66041. /**
  66042. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66043. * @param x The point on the Gaussian distribution to sample.
  66044. * @return the value of the Gaussian function at x.
  66045. */
  66046. protected _gaussianWeight(x: number): number;
  66047. /**
  66048. * Generates a string that can be used as a floating point number in GLSL.
  66049. * @param x Value to print.
  66050. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66051. * @return GLSL float string.
  66052. */
  66053. protected _glslFloat(x: number, decimalFigures?: number): string;
  66054. }
  66055. }
  66056. declare module BABYLON {
  66057. /** @hidden */
  66058. export var shadowMapPixelShader: {
  66059. name: string;
  66060. shader: string;
  66061. };
  66062. }
  66063. declare module BABYLON {
  66064. /** @hidden */
  66065. export var bonesDeclaration: {
  66066. name: string;
  66067. shader: string;
  66068. };
  66069. }
  66070. declare module BABYLON {
  66071. /** @hidden */
  66072. export var morphTargetsVertexGlobalDeclaration: {
  66073. name: string;
  66074. shader: string;
  66075. };
  66076. }
  66077. declare module BABYLON {
  66078. /** @hidden */
  66079. export var morphTargetsVertexDeclaration: {
  66080. name: string;
  66081. shader: string;
  66082. };
  66083. }
  66084. declare module BABYLON {
  66085. /** @hidden */
  66086. export var instancesDeclaration: {
  66087. name: string;
  66088. shader: string;
  66089. };
  66090. }
  66091. declare module BABYLON {
  66092. /** @hidden */
  66093. export var helperFunctions: {
  66094. name: string;
  66095. shader: string;
  66096. };
  66097. }
  66098. declare module BABYLON {
  66099. /** @hidden */
  66100. export var morphTargetsVertex: {
  66101. name: string;
  66102. shader: string;
  66103. };
  66104. }
  66105. declare module BABYLON {
  66106. /** @hidden */
  66107. export var instancesVertex: {
  66108. name: string;
  66109. shader: string;
  66110. };
  66111. }
  66112. declare module BABYLON {
  66113. /** @hidden */
  66114. export var bonesVertex: {
  66115. name: string;
  66116. shader: string;
  66117. };
  66118. }
  66119. declare module BABYLON {
  66120. /** @hidden */
  66121. export var shadowMapVertexShader: {
  66122. name: string;
  66123. shader: string;
  66124. };
  66125. }
  66126. declare module BABYLON {
  66127. /** @hidden */
  66128. export var depthBoxBlurPixelShader: {
  66129. name: string;
  66130. shader: string;
  66131. };
  66132. }
  66133. declare module BABYLON {
  66134. /**
  66135. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66136. */
  66137. export interface ICustomShaderOptions {
  66138. /**
  66139. * Gets or sets the custom shader name to use
  66140. */
  66141. shaderName: string;
  66142. /**
  66143. * The list of attribute names used in the shader
  66144. */
  66145. attributes?: string[];
  66146. /**
  66147. * The list of unifrom names used in the shader
  66148. */
  66149. uniforms?: string[];
  66150. /**
  66151. * The list of sampler names used in the shader
  66152. */
  66153. samplers?: string[];
  66154. /**
  66155. * The list of defines used in the shader
  66156. */
  66157. defines?: string[];
  66158. }
  66159. /**
  66160. * Interface to implement to create a shadow generator compatible with BJS.
  66161. */
  66162. export interface IShadowGenerator {
  66163. /**
  66164. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66165. * @returns The render target texture if present otherwise, null
  66166. */
  66167. getShadowMap(): Nullable<RenderTargetTexture>;
  66168. /**
  66169. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66170. * @returns The render target texture if the shadow map is present otherwise, null
  66171. */
  66172. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66173. /**
  66174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66175. * @param subMesh The submesh we want to render in the shadow map
  66176. * @param useInstances Defines wether will draw in the map using instances
  66177. * @returns true if ready otherwise, false
  66178. */
  66179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66180. /**
  66181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66182. * @param defines Defines of the material we want to update
  66183. * @param lightIndex Index of the light in the enabled light list of the material
  66184. */
  66185. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66186. /**
  66187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66188. * defined in the generator but impacting the effect).
  66189. * It implies the unifroms available on the materials are the standard BJS ones.
  66190. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66191. * @param effect The effect we are binfing the information for
  66192. */
  66193. bindShadowLight(lightIndex: string, effect: Effect): void;
  66194. /**
  66195. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66196. * (eq to shadow prjection matrix * light transform matrix)
  66197. * @returns The transform matrix used to create the shadow map
  66198. */
  66199. getTransformMatrix(): Matrix;
  66200. /**
  66201. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66202. * Cube and 2D textures for instance.
  66203. */
  66204. recreateShadowMap(): void;
  66205. /**
  66206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66207. * @param onCompiled Callback triggered at the and of the effects compilation
  66208. * @param options Sets of optional options forcing the compilation with different modes
  66209. */
  66210. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66211. useInstances: boolean;
  66212. }>): void;
  66213. /**
  66214. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66215. * @param options Sets of optional options forcing the compilation with different modes
  66216. * @returns A promise that resolves when the compilation completes
  66217. */
  66218. forceCompilationAsync(options?: Partial<{
  66219. useInstances: boolean;
  66220. }>): Promise<void>;
  66221. /**
  66222. * Serializes the shadow generator setup to a json object.
  66223. * @returns The serialized JSON object
  66224. */
  66225. serialize(): any;
  66226. /**
  66227. * Disposes the Shadow map and related Textures and effects.
  66228. */
  66229. dispose(): void;
  66230. }
  66231. /**
  66232. * Default implementation IShadowGenerator.
  66233. * This is the main object responsible of generating shadows in the framework.
  66234. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66235. */
  66236. export class ShadowGenerator implements IShadowGenerator {
  66237. /**
  66238. * Shadow generator mode None: no filtering applied.
  66239. */
  66240. static readonly FILTER_NONE: number;
  66241. /**
  66242. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66243. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66244. */
  66245. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66246. /**
  66247. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66248. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66249. */
  66250. static readonly FILTER_POISSONSAMPLING: number;
  66251. /**
  66252. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66253. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66254. */
  66255. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66256. /**
  66257. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66258. * edge artifacts on steep falloff.
  66259. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66260. */
  66261. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66262. /**
  66263. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66264. * edge artifacts on steep falloff.
  66265. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66266. */
  66267. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66268. /**
  66269. * Shadow generator mode PCF: Percentage Closer Filtering
  66270. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66271. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66272. */
  66273. static readonly FILTER_PCF: number;
  66274. /**
  66275. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66276. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66277. * Contact Hardening
  66278. */
  66279. static readonly FILTER_PCSS: number;
  66280. /**
  66281. * Reserved for PCF and PCSS
  66282. * Highest Quality.
  66283. *
  66284. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66285. *
  66286. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66287. */
  66288. static readonly QUALITY_HIGH: number;
  66289. /**
  66290. * Reserved for PCF and PCSS
  66291. * Good tradeoff for quality/perf cross devices
  66292. *
  66293. * Execute PCF on a 3*3 kernel.
  66294. *
  66295. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66296. */
  66297. static readonly QUALITY_MEDIUM: number;
  66298. /**
  66299. * Reserved for PCF and PCSS
  66300. * The lowest quality but the fastest.
  66301. *
  66302. * Execute PCF on a 1*1 kernel.
  66303. *
  66304. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66305. */
  66306. static readonly QUALITY_LOW: number;
  66307. /** Gets or sets the custom shader name to use */
  66308. customShaderOptions: ICustomShaderOptions;
  66309. /**
  66310. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66311. */
  66312. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66313. private _bias;
  66314. /**
  66315. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66316. */
  66317. /**
  66318. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66319. */
  66320. bias: number;
  66321. private _normalBias;
  66322. /**
  66323. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66324. */
  66325. /**
  66326. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66327. */
  66328. normalBias: number;
  66329. private _blurBoxOffset;
  66330. /**
  66331. * Gets the blur box offset: offset applied during the blur pass.
  66332. * Only useful if useKernelBlur = false
  66333. */
  66334. /**
  66335. * Sets the blur box offset: offset applied during the blur pass.
  66336. * Only useful if useKernelBlur = false
  66337. */
  66338. blurBoxOffset: number;
  66339. private _blurScale;
  66340. /**
  66341. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66342. * 2 means half of the size.
  66343. */
  66344. /**
  66345. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66346. * 2 means half of the size.
  66347. */
  66348. blurScale: number;
  66349. private _blurKernel;
  66350. /**
  66351. * Gets the blur kernel: kernel size of the blur pass.
  66352. * Only useful if useKernelBlur = true
  66353. */
  66354. /**
  66355. * Sets the blur kernel: kernel size of the blur pass.
  66356. * Only useful if useKernelBlur = true
  66357. */
  66358. blurKernel: number;
  66359. private _useKernelBlur;
  66360. /**
  66361. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66362. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66363. */
  66364. /**
  66365. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66366. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66367. */
  66368. useKernelBlur: boolean;
  66369. private _depthScale;
  66370. /**
  66371. * Gets the depth scale used in ESM mode.
  66372. */
  66373. /**
  66374. * Sets the depth scale used in ESM mode.
  66375. * This can override the scale stored on the light.
  66376. */
  66377. depthScale: number;
  66378. private _filter;
  66379. /**
  66380. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66381. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66382. */
  66383. /**
  66384. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66385. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66386. */
  66387. filter: number;
  66388. /**
  66389. * Gets if the current filter is set to Poisson Sampling.
  66390. */
  66391. /**
  66392. * Sets the current filter to Poisson Sampling.
  66393. */
  66394. usePoissonSampling: boolean;
  66395. /**
  66396. * Gets if the current filter is set to ESM.
  66397. */
  66398. /**
  66399. * Sets the current filter is to ESM.
  66400. */
  66401. useExponentialShadowMap: boolean;
  66402. /**
  66403. * Gets if the current filter is set to filtered ESM.
  66404. */
  66405. /**
  66406. * Gets if the current filter is set to filtered ESM.
  66407. */
  66408. useBlurExponentialShadowMap: boolean;
  66409. /**
  66410. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66411. * exponential to prevent steep falloff artifacts).
  66412. */
  66413. /**
  66414. * Sets the current filter to "close ESM" (using the inverse of the
  66415. * exponential to prevent steep falloff artifacts).
  66416. */
  66417. useCloseExponentialShadowMap: boolean;
  66418. /**
  66419. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66420. * exponential to prevent steep falloff artifacts).
  66421. */
  66422. /**
  66423. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66424. * exponential to prevent steep falloff artifacts).
  66425. */
  66426. useBlurCloseExponentialShadowMap: boolean;
  66427. /**
  66428. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66429. */
  66430. /**
  66431. * Sets the current filter to "PCF" (percentage closer filtering).
  66432. */
  66433. usePercentageCloserFiltering: boolean;
  66434. private _filteringQuality;
  66435. /**
  66436. * Gets the PCF or PCSS Quality.
  66437. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66438. */
  66439. /**
  66440. * Sets the PCF or PCSS Quality.
  66441. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66442. */
  66443. filteringQuality: number;
  66444. /**
  66445. * Gets if the current filter is set to "PCSS" (contact hardening).
  66446. */
  66447. /**
  66448. * Sets the current filter to "PCSS" (contact hardening).
  66449. */
  66450. useContactHardeningShadow: boolean;
  66451. private _contactHardeningLightSizeUVRatio;
  66452. /**
  66453. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66454. * Using a ratio helps keeping shape stability independently of the map size.
  66455. *
  66456. * It does not account for the light projection as it was having too much
  66457. * instability during the light setup or during light position changes.
  66458. *
  66459. * Only valid if useContactHardeningShadow is true.
  66460. */
  66461. /**
  66462. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66463. * Using a ratio helps keeping shape stability independently of the map size.
  66464. *
  66465. * It does not account for the light projection as it was having too much
  66466. * instability during the light setup or during light position changes.
  66467. *
  66468. * Only valid if useContactHardeningShadow is true.
  66469. */
  66470. contactHardeningLightSizeUVRatio: number;
  66471. private _darkness;
  66472. /**
  66473. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66474. * 0 means strongest and 1 would means no shadow.
  66475. * @returns the darkness.
  66476. */
  66477. getDarkness(): number;
  66478. /**
  66479. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66480. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66481. * @returns the shadow generator allowing fluent coding.
  66482. */
  66483. setDarkness(darkness: number): ShadowGenerator;
  66484. private _transparencyShadow;
  66485. /**
  66486. * Sets the ability to have transparent shadow (boolean).
  66487. * @param transparent True if transparent else False
  66488. * @returns the shadow generator allowing fluent coding
  66489. */
  66490. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66491. private _shadowMap;
  66492. private _shadowMap2;
  66493. /**
  66494. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66495. * @returns The render target texture if present otherwise, null
  66496. */
  66497. getShadowMap(): Nullable<RenderTargetTexture>;
  66498. /**
  66499. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66500. * @returns The render target texture if the shadow map is present otherwise, null
  66501. */
  66502. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66503. /**
  66504. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66505. * @param mesh Mesh to add
  66506. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66507. * @returns the Shadow Generator itself
  66508. */
  66509. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66510. /**
  66511. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66512. * @param mesh Mesh to remove
  66513. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66514. * @returns the Shadow Generator itself
  66515. */
  66516. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66517. /**
  66518. * Controls the extent to which the shadows fade out at the edge of the frustum
  66519. * Used only by directionals and spots
  66520. */
  66521. frustumEdgeFalloff: number;
  66522. private _light;
  66523. /**
  66524. * Returns the associated light object.
  66525. * @returns the light generating the shadow
  66526. */
  66527. getLight(): IShadowLight;
  66528. /**
  66529. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66530. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66531. * It might on the other hand introduce peter panning.
  66532. */
  66533. forceBackFacesOnly: boolean;
  66534. private _scene;
  66535. private _lightDirection;
  66536. private _effect;
  66537. private _viewMatrix;
  66538. private _projectionMatrix;
  66539. private _transformMatrix;
  66540. private _cachedPosition;
  66541. private _cachedDirection;
  66542. private _cachedDefines;
  66543. private _currentRenderID;
  66544. private _boxBlurPostprocess;
  66545. private _kernelBlurXPostprocess;
  66546. private _kernelBlurYPostprocess;
  66547. private _blurPostProcesses;
  66548. private _mapSize;
  66549. private _currentFaceIndex;
  66550. private _currentFaceIndexCache;
  66551. private _textureType;
  66552. private _defaultTextureMatrix;
  66553. /** @hidden */
  66554. static _SceneComponentInitialization: (scene: Scene) => void;
  66555. /**
  66556. * Creates a ShadowGenerator object.
  66557. * A ShadowGenerator is the required tool to use the shadows.
  66558. * Each light casting shadows needs to use its own ShadowGenerator.
  66559. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66560. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66561. * @param light The light object generating the shadows.
  66562. * @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.
  66563. */
  66564. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66565. private _initializeGenerator;
  66566. private _initializeShadowMap;
  66567. private _initializeBlurRTTAndPostProcesses;
  66568. private _renderForShadowMap;
  66569. private _renderSubMeshForShadowMap;
  66570. private _applyFilterValues;
  66571. /**
  66572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66573. * @param onCompiled Callback triggered at the and of the effects compilation
  66574. * @param options Sets of optional options forcing the compilation with different modes
  66575. */
  66576. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66577. useInstances: boolean;
  66578. }>): void;
  66579. /**
  66580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66581. * @param options Sets of optional options forcing the compilation with different modes
  66582. * @returns A promise that resolves when the compilation completes
  66583. */
  66584. forceCompilationAsync(options?: Partial<{
  66585. useInstances: boolean;
  66586. }>): Promise<void>;
  66587. /**
  66588. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66589. * @param subMesh The submesh we want to render in the shadow map
  66590. * @param useInstances Defines wether will draw in the map using instances
  66591. * @returns true if ready otherwise, false
  66592. */
  66593. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66594. /**
  66595. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66596. * @param defines Defines of the material we want to update
  66597. * @param lightIndex Index of the light in the enabled light list of the material
  66598. */
  66599. prepareDefines(defines: any, lightIndex: number): void;
  66600. /**
  66601. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66602. * defined in the generator but impacting the effect).
  66603. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66604. * @param effect The effect we are binfing the information for
  66605. */
  66606. bindShadowLight(lightIndex: string, effect: Effect): void;
  66607. /**
  66608. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66609. * (eq to shadow prjection matrix * light transform matrix)
  66610. * @returns The transform matrix used to create the shadow map
  66611. */
  66612. getTransformMatrix(): Matrix;
  66613. /**
  66614. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66615. * Cube and 2D textures for instance.
  66616. */
  66617. recreateShadowMap(): void;
  66618. private _disposeBlurPostProcesses;
  66619. private _disposeRTTandPostProcesses;
  66620. /**
  66621. * Disposes the ShadowGenerator.
  66622. * Returns nothing.
  66623. */
  66624. dispose(): void;
  66625. /**
  66626. * Serializes the shadow generator setup to a json object.
  66627. * @returns The serialized JSON object
  66628. */
  66629. serialize(): any;
  66630. /**
  66631. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66632. * @param parsedShadowGenerator The JSON object to parse
  66633. * @param scene The scene to create the shadow map for
  66634. * @returns The parsed shadow generator
  66635. */
  66636. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66637. }
  66638. }
  66639. declare module BABYLON {
  66640. /**
  66641. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66642. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66643. * 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.
  66644. */
  66645. export abstract class Light extends Node {
  66646. /**
  66647. * Falloff Default: light is falling off following the material specification:
  66648. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66649. */
  66650. static readonly FALLOFF_DEFAULT: number;
  66651. /**
  66652. * Falloff Physical: light is falling off following the inverse squared distance law.
  66653. */
  66654. static readonly FALLOFF_PHYSICAL: number;
  66655. /**
  66656. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66657. * to enhance interoperability with other engines.
  66658. */
  66659. static readonly FALLOFF_GLTF: number;
  66660. /**
  66661. * Falloff Standard: light is falling off like in the standard material
  66662. * to enhance interoperability with other materials.
  66663. */
  66664. static readonly FALLOFF_STANDARD: number;
  66665. /**
  66666. * If every light affecting the material is in this lightmapMode,
  66667. * material.lightmapTexture adds or multiplies
  66668. * (depends on material.useLightmapAsShadowmap)
  66669. * after every other light calculations.
  66670. */
  66671. static readonly LIGHTMAP_DEFAULT: number;
  66672. /**
  66673. * material.lightmapTexture as only diffuse lighting from this light
  66674. * adds only specular lighting from this light
  66675. * adds dynamic shadows
  66676. */
  66677. static readonly LIGHTMAP_SPECULAR: number;
  66678. /**
  66679. * material.lightmapTexture as only lighting
  66680. * no light calculation from this light
  66681. * only adds dynamic shadows from this light
  66682. */
  66683. static readonly LIGHTMAP_SHADOWSONLY: number;
  66684. /**
  66685. * Each light type uses the default quantity according to its type:
  66686. * point/spot lights use luminous intensity
  66687. * directional lights use illuminance
  66688. */
  66689. static readonly INTENSITYMODE_AUTOMATIC: number;
  66690. /**
  66691. * lumen (lm)
  66692. */
  66693. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66694. /**
  66695. * candela (lm/sr)
  66696. */
  66697. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66698. /**
  66699. * lux (lm/m^2)
  66700. */
  66701. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66702. /**
  66703. * nit (cd/m^2)
  66704. */
  66705. static readonly INTENSITYMODE_LUMINANCE: number;
  66706. /**
  66707. * Light type const id of the point light.
  66708. */
  66709. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66710. /**
  66711. * Light type const id of the directional light.
  66712. */
  66713. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66714. /**
  66715. * Light type const id of the spot light.
  66716. */
  66717. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66718. /**
  66719. * Light type const id of the hemispheric light.
  66720. */
  66721. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66722. /**
  66723. * Diffuse gives the basic color to an object.
  66724. */
  66725. diffuse: Color3;
  66726. /**
  66727. * Specular produces a highlight color on an object.
  66728. * Note: This is note affecting PBR materials.
  66729. */
  66730. specular: Color3;
  66731. /**
  66732. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66733. * falling off base on range or angle.
  66734. * This can be set to any values in Light.FALLOFF_x.
  66735. *
  66736. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66737. * other types of materials.
  66738. */
  66739. falloffType: number;
  66740. /**
  66741. * Strength of the light.
  66742. * Note: By default it is define in the framework own unit.
  66743. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66744. */
  66745. intensity: number;
  66746. private _range;
  66747. protected _inverseSquaredRange: number;
  66748. /**
  66749. * Defines how far from the source the light is impacting in scene units.
  66750. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66751. */
  66752. /**
  66753. * Defines how far from the source the light is impacting in scene units.
  66754. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66755. */
  66756. range: number;
  66757. /**
  66758. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66759. * of light.
  66760. */
  66761. private _photometricScale;
  66762. private _intensityMode;
  66763. /**
  66764. * Gets the photometric scale used to interpret the intensity.
  66765. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66766. */
  66767. /**
  66768. * Sets the photometric scale used to interpret the intensity.
  66769. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66770. */
  66771. intensityMode: number;
  66772. private _radius;
  66773. /**
  66774. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66775. */
  66776. /**
  66777. * sets the light radius used by PBR Materials to simulate soft area lights.
  66778. */
  66779. radius: number;
  66780. private _renderPriority;
  66781. /**
  66782. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66783. * exceeding the number allowed of the materials.
  66784. */
  66785. renderPriority: number;
  66786. private _shadowEnabled;
  66787. /**
  66788. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66789. * the current shadow generator.
  66790. */
  66791. /**
  66792. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66793. * the current shadow generator.
  66794. */
  66795. shadowEnabled: boolean;
  66796. private _includedOnlyMeshes;
  66797. /**
  66798. * Gets the only meshes impacted by this light.
  66799. */
  66800. /**
  66801. * Sets the only meshes impacted by this light.
  66802. */
  66803. includedOnlyMeshes: AbstractMesh[];
  66804. private _excludedMeshes;
  66805. /**
  66806. * Gets the meshes not impacted by this light.
  66807. */
  66808. /**
  66809. * Sets the meshes not impacted by this light.
  66810. */
  66811. excludedMeshes: AbstractMesh[];
  66812. private _excludeWithLayerMask;
  66813. /**
  66814. * Gets the layer id use to find what meshes are not impacted by the light.
  66815. * Inactive if 0
  66816. */
  66817. /**
  66818. * Sets the layer id use to find what meshes are not impacted by the light.
  66819. * Inactive if 0
  66820. */
  66821. excludeWithLayerMask: number;
  66822. private _includeOnlyWithLayerMask;
  66823. /**
  66824. * Gets the layer id use to find what meshes are impacted by the light.
  66825. * Inactive if 0
  66826. */
  66827. /**
  66828. * Sets the layer id use to find what meshes are impacted by the light.
  66829. * Inactive if 0
  66830. */
  66831. includeOnlyWithLayerMask: number;
  66832. private _lightmapMode;
  66833. /**
  66834. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66835. */
  66836. /**
  66837. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66838. */
  66839. lightmapMode: number;
  66840. /**
  66841. * Shadow generator associted to the light.
  66842. * @hidden Internal use only.
  66843. */
  66844. _shadowGenerator: Nullable<IShadowGenerator>;
  66845. /**
  66846. * @hidden Internal use only.
  66847. */
  66848. _excludedMeshesIds: string[];
  66849. /**
  66850. * @hidden Internal use only.
  66851. */
  66852. _includedOnlyMeshesIds: string[];
  66853. /**
  66854. * The current light unifom buffer.
  66855. * @hidden Internal use only.
  66856. */
  66857. _uniformBuffer: UniformBuffer;
  66858. /**
  66859. * Creates a Light object in the scene.
  66860. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66861. * @param name The firendly name of the light
  66862. * @param scene The scene the light belongs too
  66863. */
  66864. constructor(name: string, scene: Scene);
  66865. protected abstract _buildUniformLayout(): void;
  66866. /**
  66867. * Sets the passed Effect "effect" with the Light information.
  66868. * @param effect The effect to update
  66869. * @param lightIndex The index of the light in the effect to update
  66870. * @returns The light
  66871. */
  66872. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  66873. /**
  66874. * Returns the string "Light".
  66875. * @returns the class name
  66876. */
  66877. getClassName(): string;
  66878. /** @hidden */
  66879. readonly _isLight: boolean;
  66880. /**
  66881. * Converts the light information to a readable string for debug purpose.
  66882. * @param fullDetails Supports for multiple levels of logging within scene loading
  66883. * @returns the human readable light info
  66884. */
  66885. toString(fullDetails?: boolean): string;
  66886. /** @hidden */
  66887. protected _syncParentEnabledState(): void;
  66888. /**
  66889. * Set the enabled state of this node.
  66890. * @param value - the new enabled state
  66891. */
  66892. setEnabled(value: boolean): void;
  66893. /**
  66894. * Returns the Light associated shadow generator if any.
  66895. * @return the associated shadow generator.
  66896. */
  66897. getShadowGenerator(): Nullable<IShadowGenerator>;
  66898. /**
  66899. * Returns a Vector3, the absolute light position in the World.
  66900. * @returns the world space position of the light
  66901. */
  66902. getAbsolutePosition(): Vector3;
  66903. /**
  66904. * Specifies if the light will affect the passed mesh.
  66905. * @param mesh The mesh to test against the light
  66906. * @return true the mesh is affected otherwise, false.
  66907. */
  66908. canAffectMesh(mesh: AbstractMesh): boolean;
  66909. /**
  66910. * Sort function to order lights for rendering.
  66911. * @param a First Light object to compare to second.
  66912. * @param b Second Light object to compare first.
  66913. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  66914. */
  66915. static CompareLightsPriority(a: Light, b: Light): number;
  66916. /**
  66917. * Releases resources associated with this node.
  66918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66920. */
  66921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66922. /**
  66923. * Returns the light type ID (integer).
  66924. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  66925. */
  66926. getTypeID(): number;
  66927. /**
  66928. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  66929. * @returns the scaled intensity in intensity mode unit
  66930. */
  66931. getScaledIntensity(): number;
  66932. /**
  66933. * Returns a new Light object, named "name", from the current one.
  66934. * @param name The name of the cloned light
  66935. * @returns the new created light
  66936. */
  66937. clone(name: string): Nullable<Light>;
  66938. /**
  66939. * Serializes the current light into a Serialization object.
  66940. * @returns the serialized object.
  66941. */
  66942. serialize(): any;
  66943. /**
  66944. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  66945. * This new light is named "name" and added to the passed scene.
  66946. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  66947. * @param name The friendly name of the light
  66948. * @param scene The scene the new light will belong to
  66949. * @returns the constructor function
  66950. */
  66951. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  66952. /**
  66953. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  66954. * @param parsedLight The JSON representation of the light
  66955. * @param scene The scene to create the parsed light in
  66956. * @returns the created light after parsing
  66957. */
  66958. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  66959. private _hookArrayForExcluded;
  66960. private _hookArrayForIncludedOnly;
  66961. private _resyncMeshes;
  66962. /**
  66963. * Forces the meshes to update their light related information in their rendering used effects
  66964. * @hidden Internal Use Only
  66965. */
  66966. _markMeshesAsLightDirty(): void;
  66967. /**
  66968. * Recomputes the cached photometric scale if needed.
  66969. */
  66970. private _computePhotometricScale;
  66971. /**
  66972. * Returns the Photometric Scale according to the light type and intensity mode.
  66973. */
  66974. private _getPhotometricScale;
  66975. /**
  66976. * Reorder the light in the scene according to their defined priority.
  66977. * @hidden Internal Use Only
  66978. */
  66979. _reorderLightsInScene(): void;
  66980. /**
  66981. * Prepares the list of defines specific to the light type.
  66982. * @param defines the list of defines
  66983. * @param lightIndex defines the index of the light for the effect
  66984. */
  66985. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  66986. }
  66987. }
  66988. declare module BABYLON {
  66989. /**
  66990. * Interface used to define Action
  66991. */
  66992. export interface IAction {
  66993. /**
  66994. * Trigger for the action
  66995. */
  66996. trigger: number;
  66997. /** Options of the trigger */
  66998. triggerOptions: any;
  66999. /**
  67000. * Gets the trigger parameters
  67001. * @returns the trigger parameters
  67002. */
  67003. getTriggerParameter(): any;
  67004. /**
  67005. * Internal only - executes current action event
  67006. * @hidden
  67007. */
  67008. _executeCurrent(evt?: ActionEvent): void;
  67009. /**
  67010. * Serialize placeholder for child classes
  67011. * @param parent of child
  67012. * @returns the serialized object
  67013. */
  67014. serialize(parent: any): any;
  67015. }
  67016. /**
  67017. * The action to be carried out following a trigger
  67018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67019. */
  67020. export class Action implements IAction {
  67021. /** the trigger, with or without parameters, for the action */
  67022. triggerOptions: any;
  67023. /**
  67024. * Trigger for the action
  67025. */
  67026. trigger: number;
  67027. /**
  67028. * Internal only - manager for action
  67029. * @hidden
  67030. */
  67031. _actionManager: ActionManager;
  67032. private _nextActiveAction;
  67033. private _child;
  67034. private _condition?;
  67035. private _triggerParameter;
  67036. /**
  67037. * An event triggered prior to action being executed.
  67038. */
  67039. onBeforeExecuteObservable: Observable<Action>;
  67040. /**
  67041. * Creates a new Action
  67042. * @param triggerOptions the trigger, with or without parameters, for the action
  67043. * @param condition an optional determinant of action
  67044. */
  67045. constructor(
  67046. /** the trigger, with or without parameters, for the action */
  67047. triggerOptions: any, condition?: Condition);
  67048. /**
  67049. * Internal only
  67050. * @hidden
  67051. */
  67052. _prepare(): void;
  67053. /**
  67054. * Gets the trigger parameters
  67055. * @returns the trigger parameters
  67056. */
  67057. getTriggerParameter(): any;
  67058. /**
  67059. * Internal only - executes current action event
  67060. * @hidden
  67061. */
  67062. _executeCurrent(evt?: ActionEvent): void;
  67063. /**
  67064. * Execute placeholder for child classes
  67065. * @param evt optional action event
  67066. */
  67067. execute(evt?: ActionEvent): void;
  67068. /**
  67069. * Skips to next active action
  67070. */
  67071. skipToNextActiveAction(): void;
  67072. /**
  67073. * Adds action to chain of actions, may be a DoNothingAction
  67074. * @param action defines the next action to execute
  67075. * @returns The action passed in
  67076. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67077. */
  67078. then(action: Action): Action;
  67079. /**
  67080. * Internal only
  67081. * @hidden
  67082. */
  67083. _getProperty(propertyPath: string): string;
  67084. /**
  67085. * Internal only
  67086. * @hidden
  67087. */
  67088. _getEffectiveTarget(target: any, propertyPath: string): any;
  67089. /**
  67090. * Serialize placeholder for child classes
  67091. * @param parent of child
  67092. * @returns the serialized object
  67093. */
  67094. serialize(parent: any): any;
  67095. /**
  67096. * Internal only called by serialize
  67097. * @hidden
  67098. */
  67099. protected _serialize(serializedAction: any, parent?: any): any;
  67100. /**
  67101. * Internal only
  67102. * @hidden
  67103. */
  67104. static _SerializeValueAsString: (value: any) => string;
  67105. /**
  67106. * Internal only
  67107. * @hidden
  67108. */
  67109. static _GetTargetProperty: (target: Scene | Node) => {
  67110. name: string;
  67111. targetType: string;
  67112. value: string;
  67113. };
  67114. }
  67115. }
  67116. declare module BABYLON {
  67117. /**
  67118. * A Condition applied to an Action
  67119. */
  67120. export class Condition {
  67121. /**
  67122. * Internal only - manager for action
  67123. * @hidden
  67124. */
  67125. _actionManager: ActionManager;
  67126. /**
  67127. * Internal only
  67128. * @hidden
  67129. */
  67130. _evaluationId: number;
  67131. /**
  67132. * Internal only
  67133. * @hidden
  67134. */
  67135. _currentResult: boolean;
  67136. /**
  67137. * Creates a new Condition
  67138. * @param actionManager the manager of the action the condition is applied to
  67139. */
  67140. constructor(actionManager: ActionManager);
  67141. /**
  67142. * Check if the current condition is valid
  67143. * @returns a boolean
  67144. */
  67145. isValid(): boolean;
  67146. /**
  67147. * Internal only
  67148. * @hidden
  67149. */
  67150. _getProperty(propertyPath: string): string;
  67151. /**
  67152. * Internal only
  67153. * @hidden
  67154. */
  67155. _getEffectiveTarget(target: any, propertyPath: string): any;
  67156. /**
  67157. * Serialize placeholder for child classes
  67158. * @returns the serialized object
  67159. */
  67160. serialize(): any;
  67161. /**
  67162. * Internal only
  67163. * @hidden
  67164. */
  67165. protected _serialize(serializedCondition: any): any;
  67166. }
  67167. /**
  67168. * Defines specific conditional operators as extensions of Condition
  67169. */
  67170. export class ValueCondition extends Condition {
  67171. /** path to specify the property of the target the conditional operator uses */
  67172. propertyPath: string;
  67173. /** the value compared by the conditional operator against the current value of the property */
  67174. value: any;
  67175. /** the conditional operator, default ValueCondition.IsEqual */
  67176. operator: number;
  67177. /**
  67178. * Internal only
  67179. * @hidden
  67180. */
  67181. private static _IsEqual;
  67182. /**
  67183. * Internal only
  67184. * @hidden
  67185. */
  67186. private static _IsDifferent;
  67187. /**
  67188. * Internal only
  67189. * @hidden
  67190. */
  67191. private static _IsGreater;
  67192. /**
  67193. * Internal only
  67194. * @hidden
  67195. */
  67196. private static _IsLesser;
  67197. /**
  67198. * returns the number for IsEqual
  67199. */
  67200. static readonly IsEqual: number;
  67201. /**
  67202. * Returns the number for IsDifferent
  67203. */
  67204. static readonly IsDifferent: number;
  67205. /**
  67206. * Returns the number for IsGreater
  67207. */
  67208. static readonly IsGreater: number;
  67209. /**
  67210. * Returns the number for IsLesser
  67211. */
  67212. static readonly IsLesser: number;
  67213. /**
  67214. * Internal only The action manager for the condition
  67215. * @hidden
  67216. */
  67217. _actionManager: ActionManager;
  67218. /**
  67219. * Internal only
  67220. * @hidden
  67221. */
  67222. private _target;
  67223. /**
  67224. * Internal only
  67225. * @hidden
  67226. */
  67227. private _effectiveTarget;
  67228. /**
  67229. * Internal only
  67230. * @hidden
  67231. */
  67232. private _property;
  67233. /**
  67234. * Creates a new ValueCondition
  67235. * @param actionManager manager for the action the condition applies to
  67236. * @param target for the action
  67237. * @param propertyPath path to specify the property of the target the conditional operator uses
  67238. * @param value the value compared by the conditional operator against the current value of the property
  67239. * @param operator the conditional operator, default ValueCondition.IsEqual
  67240. */
  67241. constructor(actionManager: ActionManager, target: any,
  67242. /** path to specify the property of the target the conditional operator uses */
  67243. propertyPath: string,
  67244. /** the value compared by the conditional operator against the current value of the property */
  67245. value: any,
  67246. /** the conditional operator, default ValueCondition.IsEqual */
  67247. operator?: number);
  67248. /**
  67249. * Compares the given value with the property value for the specified conditional operator
  67250. * @returns the result of the comparison
  67251. */
  67252. isValid(): boolean;
  67253. /**
  67254. * Serialize the ValueCondition into a JSON compatible object
  67255. * @returns serialization object
  67256. */
  67257. serialize(): any;
  67258. /**
  67259. * Gets the name of the conditional operator for the ValueCondition
  67260. * @param operator the conditional operator
  67261. * @returns the name
  67262. */
  67263. static GetOperatorName(operator: number): string;
  67264. }
  67265. /**
  67266. * Defines a predicate condition as an extension of Condition
  67267. */
  67268. export class PredicateCondition extends Condition {
  67269. /** defines the predicate function used to validate the condition */
  67270. predicate: () => boolean;
  67271. /**
  67272. * Internal only - manager for action
  67273. * @hidden
  67274. */
  67275. _actionManager: ActionManager;
  67276. /**
  67277. * Creates a new PredicateCondition
  67278. * @param actionManager manager for the action the condition applies to
  67279. * @param predicate defines the predicate function used to validate the condition
  67280. */
  67281. constructor(actionManager: ActionManager,
  67282. /** defines the predicate function used to validate the condition */
  67283. predicate: () => boolean);
  67284. /**
  67285. * @returns the validity of the predicate condition
  67286. */
  67287. isValid(): boolean;
  67288. }
  67289. /**
  67290. * Defines a state condition as an extension of Condition
  67291. */
  67292. export class StateCondition extends Condition {
  67293. /** Value to compare with target state */
  67294. value: string;
  67295. /**
  67296. * Internal only - manager for action
  67297. * @hidden
  67298. */
  67299. _actionManager: ActionManager;
  67300. /**
  67301. * Internal only
  67302. * @hidden
  67303. */
  67304. private _target;
  67305. /**
  67306. * Creates a new StateCondition
  67307. * @param actionManager manager for the action the condition applies to
  67308. * @param target of the condition
  67309. * @param value to compare with target state
  67310. */
  67311. constructor(actionManager: ActionManager, target: any,
  67312. /** Value to compare with target state */
  67313. value: string);
  67314. /**
  67315. * Gets a boolean indicating if the current condition is met
  67316. * @returns the validity of the state
  67317. */
  67318. isValid(): boolean;
  67319. /**
  67320. * Serialize the StateCondition into a JSON compatible object
  67321. * @returns serialization object
  67322. */
  67323. serialize(): any;
  67324. }
  67325. }
  67326. declare module BABYLON {
  67327. /**
  67328. * This defines an action responsible to toggle a boolean once triggered.
  67329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67330. */
  67331. export class SwitchBooleanAction extends Action {
  67332. /**
  67333. * The path to the boolean property in the target object
  67334. */
  67335. propertyPath: string;
  67336. private _target;
  67337. private _effectiveTarget;
  67338. private _property;
  67339. /**
  67340. * Instantiate the action
  67341. * @param triggerOptions defines the trigger options
  67342. * @param target defines the object containing the boolean
  67343. * @param propertyPath defines the path to the boolean property in the target object
  67344. * @param condition defines the trigger related conditions
  67345. */
  67346. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67347. /** @hidden */
  67348. _prepare(): void;
  67349. /**
  67350. * Execute the action toggle the boolean value.
  67351. */
  67352. execute(): void;
  67353. /**
  67354. * Serializes the actions and its related information.
  67355. * @param parent defines the object to serialize in
  67356. * @returns the serialized object
  67357. */
  67358. serialize(parent: any): any;
  67359. }
  67360. /**
  67361. * This defines an action responsible to set a the state field of the target
  67362. * to a desired value once triggered.
  67363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67364. */
  67365. export class SetStateAction extends Action {
  67366. /**
  67367. * The value to store in the state field.
  67368. */
  67369. value: string;
  67370. private _target;
  67371. /**
  67372. * Instantiate the action
  67373. * @param triggerOptions defines the trigger options
  67374. * @param target defines the object containing the state property
  67375. * @param value defines the value to store in the state field
  67376. * @param condition defines the trigger related conditions
  67377. */
  67378. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67379. /**
  67380. * Execute the action and store the value on the target state property.
  67381. */
  67382. execute(): void;
  67383. /**
  67384. * Serializes the actions and its related information.
  67385. * @param parent defines the object to serialize in
  67386. * @returns the serialized object
  67387. */
  67388. serialize(parent: any): any;
  67389. }
  67390. /**
  67391. * This defines an action responsible to set a property of the target
  67392. * to a desired value once triggered.
  67393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67394. */
  67395. export class SetValueAction extends Action {
  67396. /**
  67397. * The path of the property to set in the target.
  67398. */
  67399. propertyPath: string;
  67400. /**
  67401. * The value to set in the property
  67402. */
  67403. value: any;
  67404. private _target;
  67405. private _effectiveTarget;
  67406. private _property;
  67407. /**
  67408. * Instantiate the action
  67409. * @param triggerOptions defines the trigger options
  67410. * @param target defines the object containing the property
  67411. * @param propertyPath defines the path of the property to set in the target
  67412. * @param value defines the value to set in the property
  67413. * @param condition defines the trigger related conditions
  67414. */
  67415. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67416. /** @hidden */
  67417. _prepare(): void;
  67418. /**
  67419. * Execute the action and set the targetted property to the desired value.
  67420. */
  67421. execute(): void;
  67422. /**
  67423. * Serializes the actions and its related information.
  67424. * @param parent defines the object to serialize in
  67425. * @returns the serialized object
  67426. */
  67427. serialize(parent: any): any;
  67428. }
  67429. /**
  67430. * This defines an action responsible to increment the target value
  67431. * to a desired value once triggered.
  67432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67433. */
  67434. export class IncrementValueAction extends Action {
  67435. /**
  67436. * The path of the property to increment in the target.
  67437. */
  67438. propertyPath: string;
  67439. /**
  67440. * The value we should increment the property by.
  67441. */
  67442. value: any;
  67443. private _target;
  67444. private _effectiveTarget;
  67445. private _property;
  67446. /**
  67447. * Instantiate the action
  67448. * @param triggerOptions defines the trigger options
  67449. * @param target defines the object containing the property
  67450. * @param propertyPath defines the path of the property to increment in the target
  67451. * @param value defines the value value we should increment the property by
  67452. * @param condition defines the trigger related conditions
  67453. */
  67454. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67455. /** @hidden */
  67456. _prepare(): void;
  67457. /**
  67458. * Execute the action and increment the target of the value amount.
  67459. */
  67460. execute(): void;
  67461. /**
  67462. * Serializes the actions and its related information.
  67463. * @param parent defines the object to serialize in
  67464. * @returns the serialized object
  67465. */
  67466. serialize(parent: any): any;
  67467. }
  67468. /**
  67469. * This defines an action responsible to start an animation once triggered.
  67470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67471. */
  67472. export class PlayAnimationAction extends Action {
  67473. /**
  67474. * Where the animation should start (animation frame)
  67475. */
  67476. from: number;
  67477. /**
  67478. * Where the animation should stop (animation frame)
  67479. */
  67480. to: number;
  67481. /**
  67482. * Define if the animation should loop or stop after the first play.
  67483. */
  67484. loop?: boolean;
  67485. private _target;
  67486. /**
  67487. * Instantiate the action
  67488. * @param triggerOptions defines the trigger options
  67489. * @param target defines the target animation or animation name
  67490. * @param from defines from where the animation should start (animation frame)
  67491. * @param end defines where the animation should stop (animation frame)
  67492. * @param loop defines if the animation should loop or stop after the first play
  67493. * @param condition defines the trigger related conditions
  67494. */
  67495. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67496. /** @hidden */
  67497. _prepare(): void;
  67498. /**
  67499. * Execute the action and play the animation.
  67500. */
  67501. execute(): void;
  67502. /**
  67503. * Serializes the actions and its related information.
  67504. * @param parent defines the object to serialize in
  67505. * @returns the serialized object
  67506. */
  67507. serialize(parent: any): any;
  67508. }
  67509. /**
  67510. * This defines an action responsible to stop an animation once triggered.
  67511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67512. */
  67513. export class StopAnimationAction extends Action {
  67514. private _target;
  67515. /**
  67516. * Instantiate the action
  67517. * @param triggerOptions defines the trigger options
  67518. * @param target defines the target animation or animation name
  67519. * @param condition defines the trigger related conditions
  67520. */
  67521. constructor(triggerOptions: any, target: any, condition?: Condition);
  67522. /** @hidden */
  67523. _prepare(): void;
  67524. /**
  67525. * Execute the action and stop the animation.
  67526. */
  67527. execute(): void;
  67528. /**
  67529. * Serializes the actions and its related information.
  67530. * @param parent defines the object to serialize in
  67531. * @returns the serialized object
  67532. */
  67533. serialize(parent: any): any;
  67534. }
  67535. /**
  67536. * This defines an action responsible that does nothing once triggered.
  67537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67538. */
  67539. export class DoNothingAction extends Action {
  67540. /**
  67541. * Instantiate the action
  67542. * @param triggerOptions defines the trigger options
  67543. * @param condition defines the trigger related conditions
  67544. */
  67545. constructor(triggerOptions?: any, condition?: Condition);
  67546. /**
  67547. * Execute the action and do nothing.
  67548. */
  67549. execute(): void;
  67550. /**
  67551. * Serializes the actions and its related information.
  67552. * @param parent defines the object to serialize in
  67553. * @returns the serialized object
  67554. */
  67555. serialize(parent: any): any;
  67556. }
  67557. /**
  67558. * This defines an action responsible to trigger several actions once triggered.
  67559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67560. */
  67561. export class CombineAction extends Action {
  67562. /**
  67563. * The list of aggregated animations to run.
  67564. */
  67565. children: Action[];
  67566. /**
  67567. * Instantiate the action
  67568. * @param triggerOptions defines the trigger options
  67569. * @param children defines the list of aggregated animations to run
  67570. * @param condition defines the trigger related conditions
  67571. */
  67572. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67573. /** @hidden */
  67574. _prepare(): void;
  67575. /**
  67576. * Execute the action and executes all the aggregated actions.
  67577. */
  67578. execute(evt: ActionEvent): void;
  67579. /**
  67580. * Serializes the actions and its related information.
  67581. * @param parent defines the object to serialize in
  67582. * @returns the serialized object
  67583. */
  67584. serialize(parent: any): any;
  67585. }
  67586. /**
  67587. * This defines an action responsible to run code (external event) once triggered.
  67588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67589. */
  67590. export class ExecuteCodeAction extends Action {
  67591. /**
  67592. * The callback function to run.
  67593. */
  67594. func: (evt: ActionEvent) => void;
  67595. /**
  67596. * Instantiate the action
  67597. * @param triggerOptions defines the trigger options
  67598. * @param func defines the callback function to run
  67599. * @param condition defines the trigger related conditions
  67600. */
  67601. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67602. /**
  67603. * Execute the action and run the attached code.
  67604. */
  67605. execute(evt: ActionEvent): void;
  67606. }
  67607. /**
  67608. * This defines an action responsible to set the parent property of the target once triggered.
  67609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67610. */
  67611. export class SetParentAction extends Action {
  67612. private _parent;
  67613. private _target;
  67614. /**
  67615. * Instantiate the action
  67616. * @param triggerOptions defines the trigger options
  67617. * @param target defines the target containing the parent property
  67618. * @param parent defines from where the animation should start (animation frame)
  67619. * @param condition defines the trigger related conditions
  67620. */
  67621. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67622. /** @hidden */
  67623. _prepare(): void;
  67624. /**
  67625. * Execute the action and set the parent property.
  67626. */
  67627. execute(): void;
  67628. /**
  67629. * Serializes the actions and its related information.
  67630. * @param parent defines the object to serialize in
  67631. * @returns the serialized object
  67632. */
  67633. serialize(parent: any): any;
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /**
  67638. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67639. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67641. */
  67642. export class ActionManager extends AbstractActionManager {
  67643. /**
  67644. * Nothing
  67645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67646. */
  67647. static readonly NothingTrigger: number;
  67648. /**
  67649. * On pick
  67650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67651. */
  67652. static readonly OnPickTrigger: number;
  67653. /**
  67654. * On left pick
  67655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67656. */
  67657. static readonly OnLeftPickTrigger: number;
  67658. /**
  67659. * On right pick
  67660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67661. */
  67662. static readonly OnRightPickTrigger: number;
  67663. /**
  67664. * On center pick
  67665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67666. */
  67667. static readonly OnCenterPickTrigger: number;
  67668. /**
  67669. * On pick down
  67670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67671. */
  67672. static readonly OnPickDownTrigger: number;
  67673. /**
  67674. * On double pick
  67675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67676. */
  67677. static readonly OnDoublePickTrigger: number;
  67678. /**
  67679. * On pick up
  67680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67681. */
  67682. static readonly OnPickUpTrigger: number;
  67683. /**
  67684. * On pick out.
  67685. * This trigger will only be raised if you also declared a OnPickDown
  67686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67687. */
  67688. static readonly OnPickOutTrigger: number;
  67689. /**
  67690. * On long press
  67691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67692. */
  67693. static readonly OnLongPressTrigger: number;
  67694. /**
  67695. * On pointer over
  67696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67697. */
  67698. static readonly OnPointerOverTrigger: number;
  67699. /**
  67700. * On pointer out
  67701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67702. */
  67703. static readonly OnPointerOutTrigger: number;
  67704. /**
  67705. * On every frame
  67706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67707. */
  67708. static readonly OnEveryFrameTrigger: number;
  67709. /**
  67710. * On intersection enter
  67711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67712. */
  67713. static readonly OnIntersectionEnterTrigger: number;
  67714. /**
  67715. * On intersection exit
  67716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67717. */
  67718. static readonly OnIntersectionExitTrigger: number;
  67719. /**
  67720. * On key down
  67721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67722. */
  67723. static readonly OnKeyDownTrigger: number;
  67724. /**
  67725. * On key up
  67726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67727. */
  67728. static readonly OnKeyUpTrigger: number;
  67729. private _scene;
  67730. /**
  67731. * Creates a new action manager
  67732. * @param scene defines the hosting scene
  67733. */
  67734. constructor(scene: Scene);
  67735. /**
  67736. * Releases all associated resources
  67737. */
  67738. dispose(): void;
  67739. /**
  67740. * Gets hosting scene
  67741. * @returns the hosting scene
  67742. */
  67743. getScene(): Scene;
  67744. /**
  67745. * Does this action manager handles actions of any of the given triggers
  67746. * @param triggers defines the triggers to be tested
  67747. * @return a boolean indicating whether one (or more) of the triggers is handled
  67748. */
  67749. hasSpecificTriggers(triggers: number[]): boolean;
  67750. /**
  67751. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67752. * speed.
  67753. * @param triggerA defines the trigger to be tested
  67754. * @param triggerB defines the trigger to be tested
  67755. * @return a boolean indicating whether one (or more) of the triggers is handled
  67756. */
  67757. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67758. /**
  67759. * Does this action manager handles actions of a given trigger
  67760. * @param trigger defines the trigger to be tested
  67761. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67762. * @return whether the trigger is handled
  67763. */
  67764. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67765. /**
  67766. * Does this action manager has pointer triggers
  67767. */
  67768. readonly hasPointerTriggers: boolean;
  67769. /**
  67770. * Does this action manager has pick triggers
  67771. */
  67772. readonly hasPickTriggers: boolean;
  67773. /**
  67774. * Registers an action to this action manager
  67775. * @param action defines the action to be registered
  67776. * @return the action amended (prepared) after registration
  67777. */
  67778. registerAction(action: Action): Nullable<Action>;
  67779. /**
  67780. * Unregisters an action to this action manager
  67781. * @param action defines the action to be unregistered
  67782. * @return a boolean indicating whether the action has been unregistered
  67783. */
  67784. unregisterAction(action: Action): Boolean;
  67785. /**
  67786. * Process a specific trigger
  67787. * @param trigger defines the trigger to process
  67788. * @param evt defines the event details to be processed
  67789. */
  67790. processTrigger(trigger: number, evt?: IActionEvent): void;
  67791. /** @hidden */
  67792. _getEffectiveTarget(target: any, propertyPath: string): any;
  67793. /** @hidden */
  67794. _getProperty(propertyPath: string): string;
  67795. /**
  67796. * Serialize this manager to a JSON object
  67797. * @param name defines the property name to store this manager
  67798. * @returns a JSON representation of this manager
  67799. */
  67800. serialize(name: string): any;
  67801. /**
  67802. * Creates a new ActionManager from a JSON data
  67803. * @param parsedActions defines the JSON data to read from
  67804. * @param object defines the hosting mesh
  67805. * @param scene defines the hosting scene
  67806. */
  67807. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67808. /**
  67809. * Get a trigger name by index
  67810. * @param trigger defines the trigger index
  67811. * @returns a trigger name
  67812. */
  67813. static GetTriggerName(trigger: number): string;
  67814. }
  67815. }
  67816. declare module BABYLON {
  67817. /**
  67818. * Class representing a ray with position and direction
  67819. */
  67820. export class Ray {
  67821. /** origin point */
  67822. origin: Vector3;
  67823. /** direction */
  67824. direction: Vector3;
  67825. /** length of the ray */
  67826. length: number;
  67827. private static readonly TmpVector3;
  67828. private _tmpRay;
  67829. /**
  67830. * Creates a new ray
  67831. * @param origin origin point
  67832. * @param direction direction
  67833. * @param length length of the ray
  67834. */
  67835. constructor(
  67836. /** origin point */
  67837. origin: Vector3,
  67838. /** direction */
  67839. direction: Vector3,
  67840. /** length of the ray */
  67841. length?: number);
  67842. /**
  67843. * Checks if the ray intersects a box
  67844. * @param minimum bound of the box
  67845. * @param maximum bound of the box
  67846. * @param intersectionTreshold extra extend to be added to the box in all direction
  67847. * @returns if the box was hit
  67848. */
  67849. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67850. /**
  67851. * Checks if the ray intersects a box
  67852. * @param box the bounding box to check
  67853. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67854. * @returns if the box was hit
  67855. */
  67856. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67857. /**
  67858. * If the ray hits a sphere
  67859. * @param sphere the bounding sphere to check
  67860. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  67861. * @returns true if it hits the sphere
  67862. */
  67863. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  67864. /**
  67865. * If the ray hits a triange
  67866. * @param vertex0 triangle vertex
  67867. * @param vertex1 triangle vertex
  67868. * @param vertex2 triangle vertex
  67869. * @returns intersection information if hit
  67870. */
  67871. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  67872. /**
  67873. * Checks if ray intersects a plane
  67874. * @param plane the plane to check
  67875. * @returns the distance away it was hit
  67876. */
  67877. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  67878. /**
  67879. * Checks if ray intersects a mesh
  67880. * @param mesh the mesh to check
  67881. * @param fastCheck if only the bounding box should checked
  67882. * @returns picking info of the intersecton
  67883. */
  67884. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  67885. /**
  67886. * Checks if ray intersects a mesh
  67887. * @param meshes the meshes to check
  67888. * @param fastCheck if only the bounding box should checked
  67889. * @param results array to store result in
  67890. * @returns Array of picking infos
  67891. */
  67892. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  67893. private _comparePickingInfo;
  67894. private static smallnum;
  67895. private static rayl;
  67896. /**
  67897. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  67898. * @param sega the first point of the segment to test the intersection against
  67899. * @param segb the second point of the segment to test the intersection against
  67900. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  67901. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  67902. */
  67903. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  67904. /**
  67905. * Update the ray from viewport position
  67906. * @param x position
  67907. * @param y y position
  67908. * @param viewportWidth viewport width
  67909. * @param viewportHeight viewport height
  67910. * @param world world matrix
  67911. * @param view view matrix
  67912. * @param projection projection matrix
  67913. * @returns this ray updated
  67914. */
  67915. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67916. /**
  67917. * Creates a ray with origin and direction of 0,0,0
  67918. * @returns the new ray
  67919. */
  67920. static Zero(): Ray;
  67921. /**
  67922. * Creates a new ray from screen space and viewport
  67923. * @param x position
  67924. * @param y y position
  67925. * @param viewportWidth viewport width
  67926. * @param viewportHeight viewport height
  67927. * @param world world matrix
  67928. * @param view view matrix
  67929. * @param projection projection matrix
  67930. * @returns new ray
  67931. */
  67932. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67933. /**
  67934. * 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
  67935. * transformed to the given world matrix.
  67936. * @param origin The origin point
  67937. * @param end The end point
  67938. * @param world a matrix to transform the ray to. Default is the identity matrix.
  67939. * @returns the new ray
  67940. */
  67941. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  67942. /**
  67943. * Transforms a ray by a matrix
  67944. * @param ray ray to transform
  67945. * @param matrix matrix to apply
  67946. * @returns the resulting new ray
  67947. */
  67948. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  67949. /**
  67950. * Transforms a ray by a matrix
  67951. * @param ray ray to transform
  67952. * @param matrix matrix to apply
  67953. * @param result ray to store result in
  67954. */
  67955. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  67956. /**
  67957. * Unproject a ray from screen space to object space
  67958. * @param sourceX defines the screen space x coordinate to use
  67959. * @param sourceY defines the screen space y coordinate to use
  67960. * @param viewportWidth defines the current width of the viewport
  67961. * @param viewportHeight defines the current height of the viewport
  67962. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67963. * @param view defines the view matrix to use
  67964. * @param projection defines the projection matrix to use
  67965. */
  67966. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  67967. }
  67968. interface Scene {
  67969. /** @hidden */
  67970. _tempPickingRay: Nullable<Ray>;
  67971. /** @hidden */
  67972. _cachedRayForTransform: Ray;
  67973. /** @hidden */
  67974. _pickWithRayInverseMatrix: Matrix;
  67975. /** @hidden */
  67976. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67977. /** @hidden */
  67978. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /**
  67983. * Groups all the scene component constants in one place to ease maintenance.
  67984. * @hidden
  67985. */
  67986. export class SceneComponentConstants {
  67987. static readonly NAME_EFFECTLAYER: string;
  67988. static readonly NAME_LAYER: string;
  67989. static readonly NAME_LENSFLARESYSTEM: string;
  67990. static readonly NAME_BOUNDINGBOXRENDERER: string;
  67991. static readonly NAME_PARTICLESYSTEM: string;
  67992. static readonly NAME_GAMEPAD: string;
  67993. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  67994. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  67995. static readonly NAME_DEPTHRENDERER: string;
  67996. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  67997. static readonly NAME_SPRITE: string;
  67998. static readonly NAME_OUTLINERENDERER: string;
  67999. static readonly NAME_PROCEDURALTEXTURE: string;
  68000. static readonly NAME_SHADOWGENERATOR: string;
  68001. static readonly NAME_OCTREE: string;
  68002. static readonly NAME_PHYSICSENGINE: string;
  68003. static readonly NAME_AUDIO: string;
  68004. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68005. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68006. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68007. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68008. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68009. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68010. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68011. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68012. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68013. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68014. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68015. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68016. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68017. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68018. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68019. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68020. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68021. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68022. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68023. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68024. static readonly STEP_AFTERRENDER_AUDIO: number;
  68025. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68026. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68027. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68028. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68029. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68030. static readonly STEP_POINTERMOVE_SPRITE: number;
  68031. static readonly STEP_POINTERDOWN_SPRITE: number;
  68032. static readonly STEP_POINTERUP_SPRITE: number;
  68033. }
  68034. /**
  68035. * This represents a scene component.
  68036. *
  68037. * This is used to decouple the dependency the scene is having on the different workloads like
  68038. * layers, post processes...
  68039. */
  68040. export interface ISceneComponent {
  68041. /**
  68042. * The name of the component. Each component must have a unique name.
  68043. */
  68044. name: string;
  68045. /**
  68046. * The scene the component belongs to.
  68047. */
  68048. scene: Scene;
  68049. /**
  68050. * Register the component to one instance of a scene.
  68051. */
  68052. register(): void;
  68053. /**
  68054. * Rebuilds the elements related to this component in case of
  68055. * context lost for instance.
  68056. */
  68057. rebuild(): void;
  68058. /**
  68059. * Disposes the component and the associated ressources.
  68060. */
  68061. dispose(): void;
  68062. }
  68063. /**
  68064. * This represents a SERIALIZABLE scene component.
  68065. *
  68066. * This extends Scene Component to add Serialization methods on top.
  68067. */
  68068. export interface ISceneSerializableComponent extends ISceneComponent {
  68069. /**
  68070. * Adds all the element from the container to the scene
  68071. * @param container the container holding the elements
  68072. */
  68073. addFromContainer(container: AbstractScene): void;
  68074. /**
  68075. * Removes all the elements in the container from the scene
  68076. * @param container contains the elements to remove
  68077. */
  68078. removeFromContainer(container: AbstractScene): void;
  68079. /**
  68080. * Serializes the component data to the specified json object
  68081. * @param serializationObject The object to serialize to
  68082. */
  68083. serialize(serializationObject: any): void;
  68084. }
  68085. /**
  68086. * Strong typing of a Mesh related stage step action
  68087. */
  68088. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68089. /**
  68090. * Strong typing of a Evaluate Sub Mesh related stage step action
  68091. */
  68092. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68093. /**
  68094. * Strong typing of a Active Mesh related stage step action
  68095. */
  68096. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68097. /**
  68098. * Strong typing of a Camera related stage step action
  68099. */
  68100. export type CameraStageAction = (camera: Camera) => void;
  68101. /**
  68102. * Strong typing of a Render Target related stage step action
  68103. */
  68104. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68105. /**
  68106. * Strong typing of a RenderingGroup related stage step action
  68107. */
  68108. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68109. /**
  68110. * Strong typing of a Mesh Render related stage step action
  68111. */
  68112. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68113. /**
  68114. * Strong typing of a simple stage step action
  68115. */
  68116. export type SimpleStageAction = () => void;
  68117. /**
  68118. * Strong typing of a render target action.
  68119. */
  68120. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68121. /**
  68122. * Strong typing of a pointer move action.
  68123. */
  68124. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68125. /**
  68126. * Strong typing of a pointer up/down action.
  68127. */
  68128. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68129. /**
  68130. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68131. * @hidden
  68132. */
  68133. export class Stage<T extends Function> extends Array<{
  68134. index: number;
  68135. component: ISceneComponent;
  68136. action: T;
  68137. }> {
  68138. /**
  68139. * Hide ctor from the rest of the world.
  68140. * @param items The items to add.
  68141. */
  68142. private constructor();
  68143. /**
  68144. * Creates a new Stage.
  68145. * @returns A new instance of a Stage
  68146. */
  68147. static Create<T extends Function>(): Stage<T>;
  68148. /**
  68149. * Registers a step in an ordered way in the targeted stage.
  68150. * @param index Defines the position to register the step in
  68151. * @param component Defines the component attached to the step
  68152. * @param action Defines the action to launch during the step
  68153. */
  68154. registerStep(index: number, component: ISceneComponent, action: T): void;
  68155. /**
  68156. * Clears all the steps from the stage.
  68157. */
  68158. clear(): void;
  68159. }
  68160. }
  68161. declare module BABYLON {
  68162. interface Scene {
  68163. /** @hidden */
  68164. _pointerOverSprite: Nullable<Sprite>;
  68165. /** @hidden */
  68166. _pickedDownSprite: Nullable<Sprite>;
  68167. /** @hidden */
  68168. _tempSpritePickingRay: Nullable<Ray>;
  68169. /**
  68170. * All of the sprite managers added to this scene
  68171. * @see http://doc.babylonjs.com/babylon101/sprites
  68172. */
  68173. spriteManagers: Array<ISpriteManager>;
  68174. /**
  68175. * An event triggered when sprites rendering is about to start
  68176. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68177. */
  68178. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68179. /**
  68180. * An event triggered when sprites rendering is done
  68181. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68182. */
  68183. onAfterSpritesRenderingObservable: Observable<Scene>;
  68184. /** @hidden */
  68185. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68186. /** Launch a ray to try to pick a sprite in the scene
  68187. * @param x position on screen
  68188. * @param y position on screen
  68189. * @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
  68190. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68191. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68192. * @returns a PickingInfo
  68193. */
  68194. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68195. /** Use the given ray to pick a sprite in the scene
  68196. * @param ray The ray (in world space) to use to pick meshes
  68197. * @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
  68198. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68199. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68200. * @returns a PickingInfo
  68201. */
  68202. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68203. /**
  68204. * Force the sprite under the pointer
  68205. * @param sprite defines the sprite to use
  68206. */
  68207. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68208. /**
  68209. * Gets the sprite under the pointer
  68210. * @returns a Sprite or null if no sprite is under the pointer
  68211. */
  68212. getPointerOverSprite(): Nullable<Sprite>;
  68213. }
  68214. /**
  68215. * Defines the sprite scene component responsible to manage sprites
  68216. * in a given scene.
  68217. */
  68218. export class SpriteSceneComponent implements ISceneComponent {
  68219. /**
  68220. * The component name helpfull to identify the component in the list of scene components.
  68221. */
  68222. readonly name: string;
  68223. /**
  68224. * The scene the component belongs to.
  68225. */
  68226. scene: Scene;
  68227. /** @hidden */
  68228. private _spritePredicate;
  68229. /**
  68230. * Creates a new instance of the component for the given scene
  68231. * @param scene Defines the scene to register the component in
  68232. */
  68233. constructor(scene: Scene);
  68234. /**
  68235. * Registers the component in a given scene
  68236. */
  68237. register(): void;
  68238. /**
  68239. * Rebuilds the elements related to this component in case of
  68240. * context lost for instance.
  68241. */
  68242. rebuild(): void;
  68243. /**
  68244. * Disposes the component and the associated ressources.
  68245. */
  68246. dispose(): void;
  68247. private _pickSpriteButKeepRay;
  68248. private _pointerMove;
  68249. private _pointerDown;
  68250. private _pointerUp;
  68251. }
  68252. }
  68253. declare module BABYLON {
  68254. /** @hidden */
  68255. export var fogFragmentDeclaration: {
  68256. name: string;
  68257. shader: string;
  68258. };
  68259. }
  68260. declare module BABYLON {
  68261. /** @hidden */
  68262. export var fogFragment: {
  68263. name: string;
  68264. shader: string;
  68265. };
  68266. }
  68267. declare module BABYLON {
  68268. /** @hidden */
  68269. export var spritesPixelShader: {
  68270. name: string;
  68271. shader: string;
  68272. };
  68273. }
  68274. declare module BABYLON {
  68275. /** @hidden */
  68276. export var fogVertexDeclaration: {
  68277. name: string;
  68278. shader: string;
  68279. };
  68280. }
  68281. declare module BABYLON {
  68282. /** @hidden */
  68283. export var spritesVertexShader: {
  68284. name: string;
  68285. shader: string;
  68286. };
  68287. }
  68288. declare module BABYLON {
  68289. /**
  68290. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68291. */
  68292. export interface ISpriteManager extends IDisposable {
  68293. /**
  68294. * Restricts the camera to viewing objects with the same layerMask.
  68295. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68296. */
  68297. layerMask: number;
  68298. /**
  68299. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68300. */
  68301. isPickable: boolean;
  68302. /**
  68303. * Specifies the rendering group id for this mesh (0 by default)
  68304. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68305. */
  68306. renderingGroupId: number;
  68307. /**
  68308. * Defines the list of sprites managed by the manager.
  68309. */
  68310. sprites: Array<Sprite>;
  68311. /**
  68312. * Tests the intersection of a sprite with a specific ray.
  68313. * @param ray The ray we are sending to test the collision
  68314. * @param camera The camera space we are sending rays in
  68315. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68316. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68317. * @returns picking info or null.
  68318. */
  68319. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68320. /**
  68321. * Renders the list of sprites on screen.
  68322. */
  68323. render(): void;
  68324. }
  68325. /**
  68326. * Class used to manage multiple sprites on the same spritesheet
  68327. * @see http://doc.babylonjs.com/babylon101/sprites
  68328. */
  68329. export class SpriteManager implements ISpriteManager {
  68330. /** defines the manager's name */
  68331. name: string;
  68332. /** Gets the list of sprites */
  68333. sprites: Sprite[];
  68334. /** Gets or sets the rendering group id (0 by default) */
  68335. renderingGroupId: number;
  68336. /** Gets or sets camera layer mask */
  68337. layerMask: number;
  68338. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68339. fogEnabled: boolean;
  68340. /** Gets or sets a boolean indicating if the sprites are pickable */
  68341. isPickable: boolean;
  68342. /** Defines the default width of a cell in the spritesheet */
  68343. cellWidth: number;
  68344. /** Defines the default height of a cell in the spritesheet */
  68345. cellHeight: number;
  68346. /**
  68347. * An event triggered when the manager is disposed.
  68348. */
  68349. onDisposeObservable: Observable<SpriteManager>;
  68350. private _onDisposeObserver;
  68351. /**
  68352. * Callback called when the manager is disposed
  68353. */
  68354. onDispose: () => void;
  68355. private _capacity;
  68356. private _spriteTexture;
  68357. private _epsilon;
  68358. private _scene;
  68359. private _vertexData;
  68360. private _buffer;
  68361. private _vertexBuffers;
  68362. private _indexBuffer;
  68363. private _effectBase;
  68364. private _effectFog;
  68365. /**
  68366. * Gets or sets the spritesheet texture
  68367. */
  68368. texture: Texture;
  68369. /**
  68370. * Creates a new sprite manager
  68371. * @param name defines the manager's name
  68372. * @param imgUrl defines the sprite sheet url
  68373. * @param capacity defines the maximum allowed number of sprites
  68374. * @param cellSize defines the size of a sprite cell
  68375. * @param scene defines the hosting scene
  68376. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68377. * @param samplingMode defines the smapling mode to use with spritesheet
  68378. */
  68379. constructor(
  68380. /** defines the manager's name */
  68381. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68382. private _appendSpriteVertex;
  68383. /**
  68384. * Intersects the sprites with a ray
  68385. * @param ray defines the ray to intersect with
  68386. * @param camera defines the current active camera
  68387. * @param predicate defines a predicate used to select candidate sprites
  68388. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68389. * @returns null if no hit or a PickingInfo
  68390. */
  68391. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68392. /**
  68393. * Render all child sprites
  68394. */
  68395. render(): void;
  68396. /**
  68397. * Release associated resources
  68398. */
  68399. dispose(): void;
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. /**
  68404. * Class used to represent a sprite
  68405. * @see http://doc.babylonjs.com/babylon101/sprites
  68406. */
  68407. export class Sprite {
  68408. /** defines the name */
  68409. name: string;
  68410. /** Gets or sets the current world position */
  68411. position: Vector3;
  68412. /** Gets or sets the main color */
  68413. color: Color4;
  68414. /** Gets or sets the width */
  68415. width: number;
  68416. /** Gets or sets the height */
  68417. height: number;
  68418. /** Gets or sets rotation angle */
  68419. angle: number;
  68420. /** Gets or sets the cell index in the sprite sheet */
  68421. cellIndex: number;
  68422. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68423. invertU: number;
  68424. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68425. invertV: number;
  68426. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68427. disposeWhenFinishedAnimating: boolean;
  68428. /** Gets the list of attached animations */
  68429. animations: Animation[];
  68430. /** Gets or sets a boolean indicating if the sprite can be picked */
  68431. isPickable: boolean;
  68432. /**
  68433. * Gets or sets the associated action manager
  68434. */
  68435. actionManager: Nullable<ActionManager>;
  68436. private _animationStarted;
  68437. private _loopAnimation;
  68438. private _fromIndex;
  68439. private _toIndex;
  68440. private _delay;
  68441. private _direction;
  68442. private _manager;
  68443. private _time;
  68444. private _onAnimationEnd;
  68445. /**
  68446. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68447. */
  68448. isVisible: boolean;
  68449. /**
  68450. * Gets or sets the sprite size
  68451. */
  68452. size: number;
  68453. /**
  68454. * Creates a new Sprite
  68455. * @param name defines the name
  68456. * @param manager defines the manager
  68457. */
  68458. constructor(
  68459. /** defines the name */
  68460. name: string, manager: ISpriteManager);
  68461. /**
  68462. * Starts an animation
  68463. * @param from defines the initial key
  68464. * @param to defines the end key
  68465. * @param loop defines if the animation must loop
  68466. * @param delay defines the start delay (in ms)
  68467. * @param onAnimationEnd defines a callback to call when animation ends
  68468. */
  68469. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68470. /** Stops current animation (if any) */
  68471. stopAnimation(): void;
  68472. /** @hidden */
  68473. _animate(deltaTime: number): void;
  68474. /** Release associated resources */
  68475. dispose(): void;
  68476. }
  68477. }
  68478. declare module BABYLON {
  68479. /**
  68480. * Information about the result of picking within a scene
  68481. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68482. */
  68483. export class PickingInfo {
  68484. /** @hidden */
  68485. _pickingUnavailable: boolean;
  68486. /**
  68487. * If the pick collided with an object
  68488. */
  68489. hit: boolean;
  68490. /**
  68491. * Distance away where the pick collided
  68492. */
  68493. distance: number;
  68494. /**
  68495. * The location of pick collision
  68496. */
  68497. pickedPoint: Nullable<Vector3>;
  68498. /**
  68499. * The mesh corresponding the the pick collision
  68500. */
  68501. pickedMesh: Nullable<AbstractMesh>;
  68502. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68503. bu: number;
  68504. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68505. bv: number;
  68506. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68507. faceId: number;
  68508. /** Id of the the submesh that was picked */
  68509. subMeshId: number;
  68510. /** If a sprite was picked, this will be the sprite the pick collided with */
  68511. pickedSprite: Nullable<Sprite>;
  68512. /**
  68513. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68514. */
  68515. originMesh: Nullable<AbstractMesh>;
  68516. /**
  68517. * The ray that was used to perform the picking.
  68518. */
  68519. ray: Nullable<Ray>;
  68520. /**
  68521. * Gets the normal correspodning to the face the pick collided with
  68522. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68523. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68524. * @returns The normal correspodning to the face the pick collided with
  68525. */
  68526. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68527. /**
  68528. * Gets the texture coordinates of where the pick occured
  68529. * @returns the vector containing the coordnates of the texture
  68530. */
  68531. getTextureCoordinates(): Nullable<Vector2>;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Gather the list of pointer event types as constants.
  68537. */
  68538. export class PointerEventTypes {
  68539. /**
  68540. * 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.
  68541. */
  68542. static readonly POINTERDOWN: number;
  68543. /**
  68544. * The pointerup event is fired when a pointer is no longer active.
  68545. */
  68546. static readonly POINTERUP: number;
  68547. /**
  68548. * The pointermove event is fired when a pointer changes coordinates.
  68549. */
  68550. static readonly POINTERMOVE: number;
  68551. /**
  68552. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68553. */
  68554. static readonly POINTERWHEEL: number;
  68555. /**
  68556. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68557. */
  68558. static readonly POINTERPICK: number;
  68559. /**
  68560. * The pointertap event is fired when a the object has been touched and released without drag.
  68561. */
  68562. static readonly POINTERTAP: number;
  68563. /**
  68564. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68565. */
  68566. static readonly POINTERDOUBLETAP: number;
  68567. }
  68568. /**
  68569. * Base class of pointer info types.
  68570. */
  68571. export class PointerInfoBase {
  68572. /**
  68573. * Defines the type of event (PointerEventTypes)
  68574. */
  68575. type: number;
  68576. /**
  68577. * Defines the related dom event
  68578. */
  68579. event: PointerEvent | MouseWheelEvent;
  68580. /**
  68581. * Instantiates the base class of pointers info.
  68582. * @param type Defines the type of event (PointerEventTypes)
  68583. * @param event Defines the related dom event
  68584. */
  68585. constructor(
  68586. /**
  68587. * Defines the type of event (PointerEventTypes)
  68588. */
  68589. type: number,
  68590. /**
  68591. * Defines the related dom event
  68592. */
  68593. event: PointerEvent | MouseWheelEvent);
  68594. }
  68595. /**
  68596. * This class is used to store pointer related info for the onPrePointerObservable event.
  68597. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68598. */
  68599. export class PointerInfoPre extends PointerInfoBase {
  68600. /**
  68601. * Ray from a pointer if availible (eg. 6dof controller)
  68602. */
  68603. ray: Nullable<Ray>;
  68604. /**
  68605. * Defines the local position of the pointer on the canvas.
  68606. */
  68607. localPosition: Vector2;
  68608. /**
  68609. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68610. */
  68611. skipOnPointerObservable: boolean;
  68612. /**
  68613. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68614. * @param type Defines the type of event (PointerEventTypes)
  68615. * @param event Defines the related dom event
  68616. * @param localX Defines the local x coordinates of the pointer when the event occured
  68617. * @param localY Defines the local y coordinates of the pointer when the event occured
  68618. */
  68619. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68620. }
  68621. /**
  68622. * This type contains all the data related to a pointer event in Babylon.js.
  68623. * 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.
  68624. */
  68625. export class PointerInfo extends PointerInfoBase {
  68626. /**
  68627. * Defines the picking info associated to the info (if any)\
  68628. */
  68629. pickInfo: Nullable<PickingInfo>;
  68630. /**
  68631. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68632. * @param type Defines the type of event (PointerEventTypes)
  68633. * @param event Defines the related dom event
  68634. * @param pickInfo Defines the picking info associated to the info (if any)\
  68635. */
  68636. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68637. /**
  68638. * Defines the picking info associated to the info (if any)\
  68639. */
  68640. pickInfo: Nullable<PickingInfo>);
  68641. }
  68642. }
  68643. declare module BABYLON {
  68644. /**
  68645. * Manage the mouse inputs to control the movement of a free camera.
  68646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68647. */
  68648. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68649. /**
  68650. * Define if touch is enabled in the mouse input
  68651. */
  68652. touchEnabled: boolean;
  68653. /**
  68654. * Defines the camera the input is attached to.
  68655. */
  68656. camera: FreeCamera;
  68657. /**
  68658. * Defines the buttons associated with the input to handle camera move.
  68659. */
  68660. buttons: number[];
  68661. /**
  68662. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68663. */
  68664. angularSensibility: number;
  68665. private _pointerInput;
  68666. private _onMouseMove;
  68667. private _observer;
  68668. private previousPosition;
  68669. /**
  68670. * Manage the mouse inputs to control the movement of a free camera.
  68671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68672. * @param touchEnabled Defines if touch is enabled or not
  68673. */
  68674. constructor(
  68675. /**
  68676. * Define if touch is enabled in the mouse input
  68677. */
  68678. touchEnabled?: boolean);
  68679. /**
  68680. * Attach the input controls to a specific dom element to get the input from.
  68681. * @param element Defines the element the controls should be listened from
  68682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68683. */
  68684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68685. /**
  68686. * Detach the current controls from the specified dom element.
  68687. * @param element Defines the element to stop listening the inputs from
  68688. */
  68689. detachControl(element: Nullable<HTMLElement>): void;
  68690. /**
  68691. * Gets the class name of the current intput.
  68692. * @returns the class name
  68693. */
  68694. getClassName(): string;
  68695. /**
  68696. * Get the friendly name associated with the input class.
  68697. * @returns the input friendly name
  68698. */
  68699. getSimpleName(): string;
  68700. }
  68701. }
  68702. declare module BABYLON {
  68703. /**
  68704. * Manage the touch inputs to control the movement of a free camera.
  68705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68706. */
  68707. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68708. /**
  68709. * Defines the camera the input is attached to.
  68710. */
  68711. camera: FreeCamera;
  68712. /**
  68713. * Defines the touch sensibility for rotation.
  68714. * The higher the faster.
  68715. */
  68716. touchAngularSensibility: number;
  68717. /**
  68718. * Defines the touch sensibility for move.
  68719. * The higher the faster.
  68720. */
  68721. touchMoveSensibility: number;
  68722. private _offsetX;
  68723. private _offsetY;
  68724. private _pointerPressed;
  68725. private _pointerInput;
  68726. private _observer;
  68727. private _onLostFocus;
  68728. /**
  68729. * Attach the input controls to a specific dom element to get the input from.
  68730. * @param element Defines the element the controls should be listened from
  68731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68732. */
  68733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68734. /**
  68735. * Detach the current controls from the specified dom element.
  68736. * @param element Defines the element to stop listening the inputs from
  68737. */
  68738. detachControl(element: Nullable<HTMLElement>): void;
  68739. /**
  68740. * Update the current camera state depending on the inputs that have been used this frame.
  68741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68742. */
  68743. checkInputs(): void;
  68744. /**
  68745. * Gets the class name of the current intput.
  68746. * @returns the class name
  68747. */
  68748. getClassName(): string;
  68749. /**
  68750. * Get the friendly name associated with the input class.
  68751. * @returns the input friendly name
  68752. */
  68753. getSimpleName(): string;
  68754. }
  68755. }
  68756. declare module BABYLON {
  68757. /**
  68758. * Default Inputs manager for the FreeCamera.
  68759. * It groups all the default supported inputs for ease of use.
  68760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68761. */
  68762. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68763. /**
  68764. * Instantiates a new FreeCameraInputsManager.
  68765. * @param camera Defines the camera the inputs belong to
  68766. */
  68767. constructor(camera: FreeCamera);
  68768. /**
  68769. * Add keyboard input support to the input manager.
  68770. * @returns the current input manager
  68771. */
  68772. addKeyboard(): FreeCameraInputsManager;
  68773. /**
  68774. * Add mouse input support to the input manager.
  68775. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68776. * @returns the current input manager
  68777. */
  68778. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68779. /**
  68780. * Add touch input support to the input manager.
  68781. * @returns the current input manager
  68782. */
  68783. addTouch(): FreeCameraInputsManager;
  68784. }
  68785. }
  68786. declare module BABYLON {
  68787. /**
  68788. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68789. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68791. */
  68792. export class FreeCamera extends TargetCamera {
  68793. /**
  68794. * Define the collision ellipsoid of the camera.
  68795. * This is helpful to simulate a camera body like the player body around the camera
  68796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68797. */
  68798. ellipsoid: Vector3;
  68799. /**
  68800. * Define an offset for the position of the ellipsoid around the camera.
  68801. * This can be helpful to determine the center of the body near the gravity center of the body
  68802. * instead of its head.
  68803. */
  68804. ellipsoidOffset: Vector3;
  68805. /**
  68806. * Enable or disable collisions of the camera with the rest of the scene objects.
  68807. */
  68808. checkCollisions: boolean;
  68809. /**
  68810. * Enable or disable gravity on the camera.
  68811. */
  68812. applyGravity: boolean;
  68813. /**
  68814. * Define the input manager associated to the camera.
  68815. */
  68816. inputs: FreeCameraInputsManager;
  68817. /**
  68818. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68819. * Higher values reduce sensitivity.
  68820. */
  68821. /**
  68822. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68823. * Higher values reduce sensitivity.
  68824. */
  68825. angularSensibility: number;
  68826. /**
  68827. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68828. */
  68829. keysUp: number[];
  68830. /**
  68831. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68832. */
  68833. keysDown: number[];
  68834. /**
  68835. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68836. */
  68837. keysLeft: number[];
  68838. /**
  68839. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68840. */
  68841. keysRight: number[];
  68842. /**
  68843. * Event raised when the camera collide with a mesh in the scene.
  68844. */
  68845. onCollide: (collidedMesh: AbstractMesh) => void;
  68846. private _collider;
  68847. private _needMoveForGravity;
  68848. private _oldPosition;
  68849. private _diffPosition;
  68850. private _newPosition;
  68851. /** @hidden */
  68852. _localDirection: Vector3;
  68853. /** @hidden */
  68854. _transformedDirection: Vector3;
  68855. /**
  68856. * Instantiates a Free Camera.
  68857. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68858. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68859. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68860. * @param name Define the name of the camera in the scene
  68861. * @param position Define the start position of the camera in the scene
  68862. * @param scene Define the scene the camera belongs to
  68863. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68864. */
  68865. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68866. /**
  68867. * Attached controls to the current camera.
  68868. * @param element Defines the element the controls should be listened from
  68869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68870. */
  68871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68872. /**
  68873. * Detach the current controls from the camera.
  68874. * The camera will stop reacting to inputs.
  68875. * @param element Defines the element to stop listening the inputs from
  68876. */
  68877. detachControl(element: HTMLElement): void;
  68878. private _collisionMask;
  68879. /**
  68880. * Define a collision mask to limit the list of object the camera can collide with
  68881. */
  68882. collisionMask: number;
  68883. /** @hidden */
  68884. _collideWithWorld(displacement: Vector3): void;
  68885. private _onCollisionPositionChange;
  68886. /** @hidden */
  68887. _checkInputs(): void;
  68888. /** @hidden */
  68889. _decideIfNeedsToMove(): boolean;
  68890. /** @hidden */
  68891. _updatePosition(): void;
  68892. /**
  68893. * Destroy the camera and release the current resources hold by it.
  68894. */
  68895. dispose(): void;
  68896. /**
  68897. * Gets the current object class name.
  68898. * @return the class name
  68899. */
  68900. getClassName(): string;
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. /**
  68905. * Represents a gamepad control stick position
  68906. */
  68907. export class StickValues {
  68908. /**
  68909. * The x component of the control stick
  68910. */
  68911. x: number;
  68912. /**
  68913. * The y component of the control stick
  68914. */
  68915. y: number;
  68916. /**
  68917. * Initializes the gamepad x and y control stick values
  68918. * @param x The x component of the gamepad control stick value
  68919. * @param y The y component of the gamepad control stick value
  68920. */
  68921. constructor(
  68922. /**
  68923. * The x component of the control stick
  68924. */
  68925. x: number,
  68926. /**
  68927. * The y component of the control stick
  68928. */
  68929. y: number);
  68930. }
  68931. /**
  68932. * An interface which manages callbacks for gamepad button changes
  68933. */
  68934. export interface GamepadButtonChanges {
  68935. /**
  68936. * Called when a gamepad has been changed
  68937. */
  68938. changed: boolean;
  68939. /**
  68940. * Called when a gamepad press event has been triggered
  68941. */
  68942. pressChanged: boolean;
  68943. /**
  68944. * Called when a touch event has been triggered
  68945. */
  68946. touchChanged: boolean;
  68947. /**
  68948. * Called when a value has changed
  68949. */
  68950. valueChanged: boolean;
  68951. }
  68952. /**
  68953. * Represents a gamepad
  68954. */
  68955. export class Gamepad {
  68956. /**
  68957. * The id of the gamepad
  68958. */
  68959. id: string;
  68960. /**
  68961. * The index of the gamepad
  68962. */
  68963. index: number;
  68964. /**
  68965. * The browser gamepad
  68966. */
  68967. browserGamepad: any;
  68968. /**
  68969. * Specifies what type of gamepad this represents
  68970. */
  68971. type: number;
  68972. private _leftStick;
  68973. private _rightStick;
  68974. /** @hidden */
  68975. _isConnected: boolean;
  68976. private _leftStickAxisX;
  68977. private _leftStickAxisY;
  68978. private _rightStickAxisX;
  68979. private _rightStickAxisY;
  68980. /**
  68981. * Triggered when the left control stick has been changed
  68982. */
  68983. private _onleftstickchanged;
  68984. /**
  68985. * Triggered when the right control stick has been changed
  68986. */
  68987. private _onrightstickchanged;
  68988. /**
  68989. * Represents a gamepad controller
  68990. */
  68991. static GAMEPAD: number;
  68992. /**
  68993. * Represents a generic controller
  68994. */
  68995. static GENERIC: number;
  68996. /**
  68997. * Represents an XBox controller
  68998. */
  68999. static XBOX: number;
  69000. /**
  69001. * Represents a pose-enabled controller
  69002. */
  69003. static POSE_ENABLED: number;
  69004. /**
  69005. * Specifies whether the left control stick should be Y-inverted
  69006. */
  69007. protected _invertLeftStickY: boolean;
  69008. /**
  69009. * Specifies if the gamepad has been connected
  69010. */
  69011. readonly isConnected: boolean;
  69012. /**
  69013. * Initializes the gamepad
  69014. * @param id The id of the gamepad
  69015. * @param index The index of the gamepad
  69016. * @param browserGamepad The browser gamepad
  69017. * @param leftStickX The x component of the left joystick
  69018. * @param leftStickY The y component of the left joystick
  69019. * @param rightStickX The x component of the right joystick
  69020. * @param rightStickY The y component of the right joystick
  69021. */
  69022. constructor(
  69023. /**
  69024. * The id of the gamepad
  69025. */
  69026. id: string,
  69027. /**
  69028. * The index of the gamepad
  69029. */
  69030. index: number,
  69031. /**
  69032. * The browser gamepad
  69033. */
  69034. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69035. /**
  69036. * Callback triggered when the left joystick has changed
  69037. * @param callback
  69038. */
  69039. onleftstickchanged(callback: (values: StickValues) => void): void;
  69040. /**
  69041. * Callback triggered when the right joystick has changed
  69042. * @param callback
  69043. */
  69044. onrightstickchanged(callback: (values: StickValues) => void): void;
  69045. /**
  69046. * Gets the left joystick
  69047. */
  69048. /**
  69049. * Sets the left joystick values
  69050. */
  69051. leftStick: StickValues;
  69052. /**
  69053. * Gets the right joystick
  69054. */
  69055. /**
  69056. * Sets the right joystick value
  69057. */
  69058. rightStick: StickValues;
  69059. /**
  69060. * Updates the gamepad joystick positions
  69061. */
  69062. update(): void;
  69063. /**
  69064. * Disposes the gamepad
  69065. */
  69066. dispose(): void;
  69067. }
  69068. /**
  69069. * Represents a generic gamepad
  69070. */
  69071. export class GenericPad extends Gamepad {
  69072. private _buttons;
  69073. private _onbuttondown;
  69074. private _onbuttonup;
  69075. /**
  69076. * Observable triggered when a button has been pressed
  69077. */
  69078. onButtonDownObservable: Observable<number>;
  69079. /**
  69080. * Observable triggered when a button has been released
  69081. */
  69082. onButtonUpObservable: Observable<number>;
  69083. /**
  69084. * Callback triggered when a button has been pressed
  69085. * @param callback Called when a button has been pressed
  69086. */
  69087. onbuttondown(callback: (buttonPressed: number) => void): void;
  69088. /**
  69089. * Callback triggered when a button has been released
  69090. * @param callback Called when a button has been released
  69091. */
  69092. onbuttonup(callback: (buttonReleased: number) => void): void;
  69093. /**
  69094. * Initializes the generic gamepad
  69095. * @param id The id of the generic gamepad
  69096. * @param index The index of the generic gamepad
  69097. * @param browserGamepad The browser gamepad
  69098. */
  69099. constructor(id: string, index: number, browserGamepad: any);
  69100. private _setButtonValue;
  69101. /**
  69102. * Updates the generic gamepad
  69103. */
  69104. update(): void;
  69105. /**
  69106. * Disposes the generic gamepad
  69107. */
  69108. dispose(): void;
  69109. }
  69110. }
  69111. declare module BABYLON {
  69112. /**
  69113. * Defines the types of pose enabled controllers that are supported
  69114. */
  69115. export enum PoseEnabledControllerType {
  69116. /**
  69117. * HTC Vive
  69118. */
  69119. VIVE = 0,
  69120. /**
  69121. * Oculus Rift
  69122. */
  69123. OCULUS = 1,
  69124. /**
  69125. * Windows mixed reality
  69126. */
  69127. WINDOWS = 2,
  69128. /**
  69129. * Samsung gear VR
  69130. */
  69131. GEAR_VR = 3,
  69132. /**
  69133. * Google Daydream
  69134. */
  69135. DAYDREAM = 4,
  69136. /**
  69137. * Generic
  69138. */
  69139. GENERIC = 5
  69140. }
  69141. /**
  69142. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69143. */
  69144. export interface MutableGamepadButton {
  69145. /**
  69146. * Value of the button/trigger
  69147. */
  69148. value: number;
  69149. /**
  69150. * If the button/trigger is currently touched
  69151. */
  69152. touched: boolean;
  69153. /**
  69154. * If the button/trigger is currently pressed
  69155. */
  69156. pressed: boolean;
  69157. }
  69158. /**
  69159. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69160. * @hidden
  69161. */
  69162. export interface ExtendedGamepadButton extends GamepadButton {
  69163. /**
  69164. * If the button/trigger is currently pressed
  69165. */
  69166. readonly pressed: boolean;
  69167. /**
  69168. * If the button/trigger is currently touched
  69169. */
  69170. readonly touched: boolean;
  69171. /**
  69172. * Value of the button/trigger
  69173. */
  69174. readonly value: number;
  69175. }
  69176. /** @hidden */
  69177. export interface _GamePadFactory {
  69178. /**
  69179. * Returns wether or not the current gamepad can be created for this type of controller.
  69180. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69181. * @returns true if it can be created, otherwise false
  69182. */
  69183. canCreate(gamepadInfo: any): boolean;
  69184. /**
  69185. * Creates a new instance of the Gamepad.
  69186. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69187. * @returns the new gamepad instance
  69188. */
  69189. create(gamepadInfo: any): Gamepad;
  69190. }
  69191. /**
  69192. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69193. */
  69194. export class PoseEnabledControllerHelper {
  69195. /** @hidden */
  69196. static _ControllerFactories: _GamePadFactory[];
  69197. /** @hidden */
  69198. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69199. /**
  69200. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69201. * @param vrGamepad the gamepad to initialized
  69202. * @returns a vr controller of the type the gamepad identified as
  69203. */
  69204. static InitiateController(vrGamepad: any): Gamepad;
  69205. }
  69206. /**
  69207. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69208. */
  69209. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69210. private _deviceRoomPosition;
  69211. private _deviceRoomRotationQuaternion;
  69212. /**
  69213. * The device position in babylon space
  69214. */
  69215. devicePosition: Vector3;
  69216. /**
  69217. * The device rotation in babylon space
  69218. */
  69219. deviceRotationQuaternion: Quaternion;
  69220. /**
  69221. * The scale factor of the device in babylon space
  69222. */
  69223. deviceScaleFactor: number;
  69224. /**
  69225. * (Likely devicePosition should be used instead) The device position in its room space
  69226. */
  69227. position: Vector3;
  69228. /**
  69229. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69230. */
  69231. rotationQuaternion: Quaternion;
  69232. /**
  69233. * The type of controller (Eg. Windows mixed reality)
  69234. */
  69235. controllerType: PoseEnabledControllerType;
  69236. protected _calculatedPosition: Vector3;
  69237. private _calculatedRotation;
  69238. /**
  69239. * The raw pose from the device
  69240. */
  69241. rawPose: DevicePose;
  69242. private _trackPosition;
  69243. private _maxRotationDistFromHeadset;
  69244. private _draggedRoomRotation;
  69245. /**
  69246. * @hidden
  69247. */
  69248. _disableTrackPosition(fixedPosition: Vector3): void;
  69249. /**
  69250. * Internal, the mesh attached to the controller
  69251. * @hidden
  69252. */
  69253. _mesh: Nullable<AbstractMesh>;
  69254. private _poseControlledCamera;
  69255. private _leftHandSystemQuaternion;
  69256. /**
  69257. * Internal, matrix used to convert room space to babylon space
  69258. * @hidden
  69259. */
  69260. _deviceToWorld: Matrix;
  69261. /**
  69262. * Node to be used when casting a ray from the controller
  69263. * @hidden
  69264. */
  69265. _pointingPoseNode: Nullable<TransformNode>;
  69266. /**
  69267. * Name of the child mesh that can be used to cast a ray from the controller
  69268. */
  69269. static readonly POINTING_POSE: string;
  69270. /**
  69271. * Creates a new PoseEnabledController from a gamepad
  69272. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69273. */
  69274. constructor(browserGamepad: any);
  69275. private _workingMatrix;
  69276. /**
  69277. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69278. */
  69279. update(): void;
  69280. /**
  69281. * Updates only the pose device and mesh without doing any button event checking
  69282. */
  69283. protected _updatePoseAndMesh(): void;
  69284. /**
  69285. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69286. * @param poseData raw pose fromthe device
  69287. */
  69288. updateFromDevice(poseData: DevicePose): void;
  69289. /**
  69290. * @hidden
  69291. */
  69292. _meshAttachedObservable: Observable<AbstractMesh>;
  69293. /**
  69294. * Attaches a mesh to the controller
  69295. * @param mesh the mesh to be attached
  69296. */
  69297. attachToMesh(mesh: AbstractMesh): void;
  69298. /**
  69299. * Attaches the controllers mesh to a camera
  69300. * @param camera the camera the mesh should be attached to
  69301. */
  69302. attachToPoseControlledCamera(camera: TargetCamera): void;
  69303. /**
  69304. * Disposes of the controller
  69305. */
  69306. dispose(): void;
  69307. /**
  69308. * The mesh that is attached to the controller
  69309. */
  69310. readonly mesh: Nullable<AbstractMesh>;
  69311. /**
  69312. * Gets the ray of the controller in the direction the controller is pointing
  69313. * @param length the length the resulting ray should be
  69314. * @returns a ray in the direction the controller is pointing
  69315. */
  69316. getForwardRay(length?: number): Ray;
  69317. }
  69318. }
  69319. declare module BABYLON {
  69320. /**
  69321. * Defines the WebVRController object that represents controllers tracked in 3D space
  69322. */
  69323. export abstract class WebVRController extends PoseEnabledController {
  69324. /**
  69325. * Internal, the default controller model for the controller
  69326. */
  69327. protected _defaultModel: AbstractMesh;
  69328. /**
  69329. * Fired when the trigger state has changed
  69330. */
  69331. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69332. /**
  69333. * Fired when the main button state has changed
  69334. */
  69335. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69336. /**
  69337. * Fired when the secondary button state has changed
  69338. */
  69339. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69340. /**
  69341. * Fired when the pad state has changed
  69342. */
  69343. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69344. /**
  69345. * Fired when controllers stick values have changed
  69346. */
  69347. onPadValuesChangedObservable: Observable<StickValues>;
  69348. /**
  69349. * Array of button availible on the controller
  69350. */
  69351. protected _buttons: Array<MutableGamepadButton>;
  69352. private _onButtonStateChange;
  69353. /**
  69354. * Fired when a controller button's state has changed
  69355. * @param callback the callback containing the button that was modified
  69356. */
  69357. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69358. /**
  69359. * X and Y axis corrisponding to the controllers joystick
  69360. */
  69361. pad: StickValues;
  69362. /**
  69363. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69364. */
  69365. hand: string;
  69366. /**
  69367. * The default controller model for the controller
  69368. */
  69369. readonly defaultModel: AbstractMesh;
  69370. /**
  69371. * Creates a new WebVRController from a gamepad
  69372. * @param vrGamepad the gamepad that the WebVRController should be created from
  69373. */
  69374. constructor(vrGamepad: any);
  69375. /**
  69376. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69377. */
  69378. update(): void;
  69379. /**
  69380. * Function to be called when a button is modified
  69381. */
  69382. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69383. /**
  69384. * Loads a mesh and attaches it to the controller
  69385. * @param scene the scene the mesh should be added to
  69386. * @param meshLoaded callback for when the mesh has been loaded
  69387. */
  69388. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69389. private _setButtonValue;
  69390. private _changes;
  69391. private _checkChanges;
  69392. /**
  69393. * Disposes of th webVRCOntroller
  69394. */
  69395. dispose(): void;
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * The HemisphericLight simulates the ambient environment light,
  69401. * so the passed direction is the light reflection direction, not the incoming direction.
  69402. */
  69403. export class HemisphericLight extends Light {
  69404. /**
  69405. * The groundColor is the light in the opposite direction to the one specified during creation.
  69406. * 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.
  69407. */
  69408. groundColor: Color3;
  69409. /**
  69410. * The light reflection direction, not the incoming direction.
  69411. */
  69412. direction: Vector3;
  69413. /**
  69414. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69415. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69416. * The HemisphericLight can't cast shadows.
  69417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69418. * @param name The friendly name of the light
  69419. * @param direction The direction of the light reflection
  69420. * @param scene The scene the light belongs to
  69421. */
  69422. constructor(name: string, direction: Vector3, scene: Scene);
  69423. protected _buildUniformLayout(): void;
  69424. /**
  69425. * Returns the string "HemisphericLight".
  69426. * @return The class name
  69427. */
  69428. getClassName(): string;
  69429. /**
  69430. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69431. * Returns the updated direction.
  69432. * @param target The target the direction should point to
  69433. * @return The computed direction
  69434. */
  69435. setDirectionToTarget(target: Vector3): Vector3;
  69436. /**
  69437. * Returns the shadow generator associated to the light.
  69438. * @returns Always null for hemispheric lights because it does not support shadows.
  69439. */
  69440. getShadowGenerator(): Nullable<IShadowGenerator>;
  69441. /**
  69442. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69443. * @param effect The effect to update
  69444. * @param lightIndex The index of the light in the effect to update
  69445. * @returns The hemispheric light
  69446. */
  69447. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69448. /**
  69449. * Computes the world matrix of the node
  69450. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69451. * @param useWasUpdatedFlag defines a reserved property
  69452. * @returns the world matrix
  69453. */
  69454. computeWorldMatrix(): Matrix;
  69455. /**
  69456. * Returns the integer 3.
  69457. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69458. */
  69459. getTypeID(): number;
  69460. /**
  69461. * Prepares the list of defines specific to the light type.
  69462. * @param defines the list of defines
  69463. * @param lightIndex defines the index of the light for the effect
  69464. */
  69465. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /**
  69470. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69471. * IMPORTANT!! The data is right-hand data.
  69472. * @export
  69473. * @interface DevicePose
  69474. */
  69475. export interface DevicePose {
  69476. /**
  69477. * The position of the device, values in array are [x,y,z].
  69478. */
  69479. readonly position: Nullable<Float32Array>;
  69480. /**
  69481. * The linearVelocity of the device, values in array are [x,y,z].
  69482. */
  69483. readonly linearVelocity: Nullable<Float32Array>;
  69484. /**
  69485. * The linearAcceleration of the device, values in array are [x,y,z].
  69486. */
  69487. readonly linearAcceleration: Nullable<Float32Array>;
  69488. /**
  69489. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69490. */
  69491. readonly orientation: Nullable<Float32Array>;
  69492. /**
  69493. * The angularVelocity of the device, values in array are [x,y,z].
  69494. */
  69495. readonly angularVelocity: Nullable<Float32Array>;
  69496. /**
  69497. * The angularAcceleration of the device, values in array are [x,y,z].
  69498. */
  69499. readonly angularAcceleration: Nullable<Float32Array>;
  69500. }
  69501. /**
  69502. * Interface representing a pose controlled object in Babylon.
  69503. * A pose controlled object has both regular pose values as well as pose values
  69504. * from an external device such as a VR head mounted display
  69505. */
  69506. export interface PoseControlled {
  69507. /**
  69508. * The position of the object in babylon space.
  69509. */
  69510. position: Vector3;
  69511. /**
  69512. * The rotation quaternion of the object in babylon space.
  69513. */
  69514. rotationQuaternion: Quaternion;
  69515. /**
  69516. * The position of the device in babylon space.
  69517. */
  69518. devicePosition?: Vector3;
  69519. /**
  69520. * The rotation quaternion of the device in babylon space.
  69521. */
  69522. deviceRotationQuaternion: Quaternion;
  69523. /**
  69524. * The raw pose coming from the device.
  69525. */
  69526. rawPose: Nullable<DevicePose>;
  69527. /**
  69528. * The scale of the device to be used when translating from device space to babylon space.
  69529. */
  69530. deviceScaleFactor: number;
  69531. /**
  69532. * Updates the poseControlled values based on the input device pose.
  69533. * @param poseData the pose data to update the object with
  69534. */
  69535. updateFromDevice(poseData: DevicePose): void;
  69536. }
  69537. /**
  69538. * Set of options to customize the webVRCamera
  69539. */
  69540. export interface WebVROptions {
  69541. /**
  69542. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69543. */
  69544. trackPosition?: boolean;
  69545. /**
  69546. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69547. */
  69548. positionScale?: number;
  69549. /**
  69550. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69551. */
  69552. displayName?: string;
  69553. /**
  69554. * Should the native controller meshes be initialized. (default: true)
  69555. */
  69556. controllerMeshes?: boolean;
  69557. /**
  69558. * Creating a default HemiLight only on controllers. (default: true)
  69559. */
  69560. defaultLightingOnControllers?: boolean;
  69561. /**
  69562. * If you don't want to use the default VR button of the helper. (default: false)
  69563. */
  69564. useCustomVRButton?: boolean;
  69565. /**
  69566. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69567. */
  69568. customVRButton?: HTMLButtonElement;
  69569. /**
  69570. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69571. */
  69572. rayLength?: number;
  69573. /**
  69574. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69575. */
  69576. defaultHeight?: number;
  69577. }
  69578. /**
  69579. * This represents a WebVR camera.
  69580. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69581. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69582. */
  69583. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69584. private webVROptions;
  69585. /**
  69586. * @hidden
  69587. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69588. */
  69589. _vrDevice: any;
  69590. /**
  69591. * The rawPose of the vrDevice.
  69592. */
  69593. rawPose: Nullable<DevicePose>;
  69594. private _onVREnabled;
  69595. private _specsVersion;
  69596. private _attached;
  69597. private _frameData;
  69598. protected _descendants: Array<Node>;
  69599. private _deviceRoomPosition;
  69600. /** @hidden */
  69601. _deviceRoomRotationQuaternion: Quaternion;
  69602. private _standingMatrix;
  69603. /**
  69604. * Represents device position in babylon space.
  69605. */
  69606. devicePosition: Vector3;
  69607. /**
  69608. * Represents device rotation in babylon space.
  69609. */
  69610. deviceRotationQuaternion: Quaternion;
  69611. /**
  69612. * The scale of the device to be used when translating from device space to babylon space.
  69613. */
  69614. deviceScaleFactor: number;
  69615. private _deviceToWorld;
  69616. private _worldToDevice;
  69617. /**
  69618. * References to the webVR controllers for the vrDevice.
  69619. */
  69620. controllers: Array<WebVRController>;
  69621. /**
  69622. * Emits an event when a controller is attached.
  69623. */
  69624. onControllersAttachedObservable: Observable<WebVRController[]>;
  69625. /**
  69626. * Emits an event when a controller's mesh has been loaded;
  69627. */
  69628. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69629. /**
  69630. * Emits an event when the HMD's pose has been updated.
  69631. */
  69632. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69633. private _poseSet;
  69634. /**
  69635. * If the rig cameras be used as parent instead of this camera.
  69636. */
  69637. rigParenting: boolean;
  69638. private _lightOnControllers;
  69639. private _defaultHeight?;
  69640. /**
  69641. * Instantiates a WebVRFreeCamera.
  69642. * @param name The name of the WebVRFreeCamera
  69643. * @param position The starting anchor position for the camera
  69644. * @param scene The scene the camera belongs to
  69645. * @param webVROptions a set of customizable options for the webVRCamera
  69646. */
  69647. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69648. /**
  69649. * Gets the device distance from the ground in meters.
  69650. * @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.
  69651. */
  69652. deviceDistanceToRoomGround(): number;
  69653. /**
  69654. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69655. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69656. */
  69657. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69658. /**
  69659. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69660. * @returns A promise with a boolean set to if the standing matrix is supported.
  69661. */
  69662. useStandingMatrixAsync(): Promise<boolean>;
  69663. /**
  69664. * Disposes the camera
  69665. */
  69666. dispose(): void;
  69667. /**
  69668. * Gets a vrController by name.
  69669. * @param name The name of the controller to retreive
  69670. * @returns the controller matching the name specified or null if not found
  69671. */
  69672. getControllerByName(name: string): Nullable<WebVRController>;
  69673. private _leftController;
  69674. /**
  69675. * The controller corrisponding to the users left hand.
  69676. */
  69677. readonly leftController: Nullable<WebVRController>;
  69678. private _rightController;
  69679. /**
  69680. * The controller corrisponding to the users right hand.
  69681. */
  69682. readonly rightController: Nullable<WebVRController>;
  69683. /**
  69684. * Casts a ray forward from the vrCamera's gaze.
  69685. * @param length Length of the ray (default: 100)
  69686. * @returns the ray corrisponding to the gaze
  69687. */
  69688. getForwardRay(length?: number): Ray;
  69689. /**
  69690. * @hidden
  69691. * Updates the camera based on device's frame data
  69692. */
  69693. _checkInputs(): void;
  69694. /**
  69695. * Updates the poseControlled values based on the input device pose.
  69696. * @param poseData Pose coming from the device
  69697. */
  69698. updateFromDevice(poseData: DevicePose): void;
  69699. private _htmlElementAttached;
  69700. private _detachIfAttached;
  69701. /**
  69702. * WebVR's attach control will start broadcasting frames to the device.
  69703. * Note that in certain browsers (chrome for example) this function must be called
  69704. * within a user-interaction callback. Example:
  69705. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69706. *
  69707. * @param element html element to attach the vrDevice to
  69708. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69709. */
  69710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69711. /**
  69712. * Detaches the camera from the html element and disables VR
  69713. *
  69714. * @param element html element to detach from
  69715. */
  69716. detachControl(element: HTMLElement): void;
  69717. /**
  69718. * @returns the name of this class
  69719. */
  69720. getClassName(): string;
  69721. /**
  69722. * Calls resetPose on the vrDisplay
  69723. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69724. */
  69725. resetToCurrentRotation(): void;
  69726. /**
  69727. * @hidden
  69728. * Updates the rig cameras (left and right eye)
  69729. */
  69730. _updateRigCameras(): void;
  69731. private _workingVector;
  69732. private _oneVector;
  69733. private _workingMatrix;
  69734. private updateCacheCalled;
  69735. private _correctPositionIfNotTrackPosition;
  69736. /**
  69737. * @hidden
  69738. * Updates the cached values of the camera
  69739. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69740. */
  69741. _updateCache(ignoreParentClass?: boolean): void;
  69742. /**
  69743. * @hidden
  69744. * Get current device position in babylon world
  69745. */
  69746. _computeDevicePosition(): void;
  69747. /**
  69748. * Updates the current device position and rotation in the babylon world
  69749. */
  69750. update(): void;
  69751. /**
  69752. * @hidden
  69753. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69754. * @returns an identity matrix
  69755. */
  69756. _getViewMatrix(): Matrix;
  69757. private _tmpMatrix;
  69758. /**
  69759. * This function is called by the two RIG cameras.
  69760. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69761. * @hidden
  69762. */
  69763. _getWebVRViewMatrix(): Matrix;
  69764. /** @hidden */
  69765. _getWebVRProjectionMatrix(): Matrix;
  69766. private _onGamepadConnectedObserver;
  69767. private _onGamepadDisconnectedObserver;
  69768. private _updateCacheWhenTrackingDisabledObserver;
  69769. /**
  69770. * Initializes the controllers and their meshes
  69771. */
  69772. initControllers(): void;
  69773. }
  69774. }
  69775. declare module BABYLON {
  69776. /**
  69777. * Size options for a post process
  69778. */
  69779. export type PostProcessOptions = {
  69780. width: number;
  69781. height: number;
  69782. };
  69783. /**
  69784. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69785. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69786. */
  69787. export class PostProcess {
  69788. /** Name of the PostProcess. */
  69789. name: string;
  69790. /**
  69791. * Gets or sets the unique id of the post process
  69792. */
  69793. uniqueId: number;
  69794. /**
  69795. * Width of the texture to apply the post process on
  69796. */
  69797. width: number;
  69798. /**
  69799. * Height of the texture to apply the post process on
  69800. */
  69801. height: number;
  69802. /**
  69803. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69804. * @hidden
  69805. */
  69806. _outputTexture: Nullable<InternalTexture>;
  69807. /**
  69808. * Sampling mode used by the shader
  69809. * See https://doc.babylonjs.com/classes/3.1/texture
  69810. */
  69811. renderTargetSamplingMode: number;
  69812. /**
  69813. * Clear color to use when screen clearing
  69814. */
  69815. clearColor: Color4;
  69816. /**
  69817. * If the buffer needs to be cleared before applying the post process. (default: true)
  69818. * Should be set to false if shader will overwrite all previous pixels.
  69819. */
  69820. autoClear: boolean;
  69821. /**
  69822. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69823. */
  69824. alphaMode: number;
  69825. /**
  69826. * Sets the setAlphaBlendConstants of the babylon engine
  69827. */
  69828. alphaConstants: Color4;
  69829. /**
  69830. * Animations to be used for the post processing
  69831. */
  69832. animations: Animation[];
  69833. /**
  69834. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69835. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69836. */
  69837. enablePixelPerfectMode: boolean;
  69838. /**
  69839. * Force the postprocess to be applied without taking in account viewport
  69840. */
  69841. forceFullscreenViewport: boolean;
  69842. /**
  69843. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69844. *
  69845. * | Value | Type | Description |
  69846. * | ----- | ----------------------------------- | ----------- |
  69847. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69848. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69849. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69850. *
  69851. */
  69852. scaleMode: number;
  69853. /**
  69854. * Force textures to be a power of two (default: false)
  69855. */
  69856. alwaysForcePOT: boolean;
  69857. private _samples;
  69858. /**
  69859. * Number of sample textures (default: 1)
  69860. */
  69861. samples: number;
  69862. /**
  69863. * Modify the scale of the post process to be the same as the viewport (default: false)
  69864. */
  69865. adaptScaleToCurrentViewport: boolean;
  69866. private _camera;
  69867. private _scene;
  69868. private _engine;
  69869. private _options;
  69870. private _reusable;
  69871. private _textureType;
  69872. /**
  69873. * Smart array of input and output textures for the post process.
  69874. * @hidden
  69875. */
  69876. _textures: SmartArray<InternalTexture>;
  69877. /**
  69878. * The index in _textures that corresponds to the output texture.
  69879. * @hidden
  69880. */
  69881. _currentRenderTextureInd: number;
  69882. private _effect;
  69883. private _samplers;
  69884. private _fragmentUrl;
  69885. private _vertexUrl;
  69886. private _parameters;
  69887. private _scaleRatio;
  69888. protected _indexParameters: any;
  69889. private _shareOutputWithPostProcess;
  69890. private _texelSize;
  69891. private _forcedOutputTexture;
  69892. /**
  69893. * Returns the fragment url or shader name used in the post process.
  69894. * @returns the fragment url or name in the shader store.
  69895. */
  69896. getEffectName(): string;
  69897. /**
  69898. * An event triggered when the postprocess is activated.
  69899. */
  69900. onActivateObservable: Observable<Camera>;
  69901. private _onActivateObserver;
  69902. /**
  69903. * A function that is added to the onActivateObservable
  69904. */
  69905. onActivate: Nullable<(camera: Camera) => void>;
  69906. /**
  69907. * An event triggered when the postprocess changes its size.
  69908. */
  69909. onSizeChangedObservable: Observable<PostProcess>;
  69910. private _onSizeChangedObserver;
  69911. /**
  69912. * A function that is added to the onSizeChangedObservable
  69913. */
  69914. onSizeChanged: (postProcess: PostProcess) => void;
  69915. /**
  69916. * An event triggered when the postprocess applies its effect.
  69917. */
  69918. onApplyObservable: Observable<Effect>;
  69919. private _onApplyObserver;
  69920. /**
  69921. * A function that is added to the onApplyObservable
  69922. */
  69923. onApply: (effect: Effect) => void;
  69924. /**
  69925. * An event triggered before rendering the postprocess
  69926. */
  69927. onBeforeRenderObservable: Observable<Effect>;
  69928. private _onBeforeRenderObserver;
  69929. /**
  69930. * A function that is added to the onBeforeRenderObservable
  69931. */
  69932. onBeforeRender: (effect: Effect) => void;
  69933. /**
  69934. * An event triggered after rendering the postprocess
  69935. */
  69936. onAfterRenderObservable: Observable<Effect>;
  69937. private _onAfterRenderObserver;
  69938. /**
  69939. * A function that is added to the onAfterRenderObservable
  69940. */
  69941. onAfterRender: (efect: Effect) => void;
  69942. /**
  69943. * 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
  69944. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  69945. */
  69946. inputTexture: InternalTexture;
  69947. /**
  69948. * Gets the camera which post process is applied to.
  69949. * @returns The camera the post process is applied to.
  69950. */
  69951. getCamera(): Camera;
  69952. /**
  69953. * Gets the texel size of the postprocess.
  69954. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  69955. */
  69956. readonly texelSize: Vector2;
  69957. /**
  69958. * Creates a new instance PostProcess
  69959. * @param name The name of the PostProcess.
  69960. * @param fragmentUrl The url of the fragment shader to be used.
  69961. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  69962. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  69963. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69964. * @param camera The camera to apply the render pass to.
  69965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69966. * @param engine The engine which the post process will be applied. (default: current engine)
  69967. * @param reusable If the post process can be reused on the same frame. (default: false)
  69968. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  69969. * @param textureType Type of textures used when performing the post process. (default: 0)
  69970. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  69971. * @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
  69972. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  69973. */
  69974. constructor(
  69975. /** Name of the PostProcess. */
  69976. 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);
  69977. /**
  69978. * Gets a string idenfifying the name of the class
  69979. * @returns "PostProcess" string
  69980. */
  69981. getClassName(): string;
  69982. /**
  69983. * Gets the engine which this post process belongs to.
  69984. * @returns The engine the post process was enabled with.
  69985. */
  69986. getEngine(): Engine;
  69987. /**
  69988. * The effect that is created when initializing the post process.
  69989. * @returns The created effect corrisponding the the postprocess.
  69990. */
  69991. getEffect(): Effect;
  69992. /**
  69993. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  69994. * @param postProcess The post process to share the output with.
  69995. * @returns This post process.
  69996. */
  69997. shareOutputWith(postProcess: PostProcess): PostProcess;
  69998. /**
  69999. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70000. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70001. */
  70002. useOwnOutput(): void;
  70003. /**
  70004. * Updates the effect with the current post process compile time values and recompiles the shader.
  70005. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70006. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70007. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70008. * @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
  70009. * @param onCompiled Called when the shader has been compiled.
  70010. * @param onError Called if there is an error when compiling a shader.
  70011. */
  70012. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70013. /**
  70014. * The post process is reusable if it can be used multiple times within one frame.
  70015. * @returns If the post process is reusable
  70016. */
  70017. isReusable(): boolean;
  70018. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70019. markTextureDirty(): void;
  70020. /**
  70021. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70022. * 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.
  70023. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70024. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70025. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70026. * @returns The target texture that was bound to be written to.
  70027. */
  70028. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70029. /**
  70030. * If the post process is supported.
  70031. */
  70032. readonly isSupported: boolean;
  70033. /**
  70034. * The aspect ratio of the output texture.
  70035. */
  70036. readonly aspectRatio: number;
  70037. /**
  70038. * Get a value indicating if the post-process is ready to be used
  70039. * @returns true if the post-process is ready (shader is compiled)
  70040. */
  70041. isReady(): boolean;
  70042. /**
  70043. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70044. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70045. */
  70046. apply(): Nullable<Effect>;
  70047. private _disposeTextures;
  70048. /**
  70049. * Disposes the post process.
  70050. * @param camera The camera to dispose the post process on.
  70051. */
  70052. dispose(camera?: Camera): void;
  70053. }
  70054. }
  70055. declare module BABYLON {
  70056. /**
  70057. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70058. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70059. */
  70060. export class PostProcessManager {
  70061. private _scene;
  70062. private _indexBuffer;
  70063. private _vertexBuffers;
  70064. /**
  70065. * Creates a new instance PostProcess
  70066. * @param scene The scene that the post process is associated with.
  70067. */
  70068. constructor(scene: Scene);
  70069. private _prepareBuffers;
  70070. private _buildIndexBuffer;
  70071. /**
  70072. * Rebuilds the vertex buffers of the manager.
  70073. * @hidden
  70074. */
  70075. _rebuild(): void;
  70076. /**
  70077. * Prepares a frame to be run through a post process.
  70078. * @param sourceTexture The input texture to the post procesess. (default: null)
  70079. * @param postProcesses An array of post processes to be run. (default: null)
  70080. * @returns True if the post processes were able to be run.
  70081. * @hidden
  70082. */
  70083. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70084. /**
  70085. * Manually render a set of post processes to a texture.
  70086. * @param postProcesses An array of post processes to be run.
  70087. * @param targetTexture The target texture to render to.
  70088. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70089. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70090. * @param lodLevel defines which lod of the texture to render to
  70091. */
  70092. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70093. /**
  70094. * Finalize the result of the output of the postprocesses.
  70095. * @param doNotPresent If true the result will not be displayed to the screen.
  70096. * @param targetTexture The target texture to render to.
  70097. * @param faceIndex The index of the face to bind the target texture to.
  70098. * @param postProcesses The array of post processes to render.
  70099. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70100. * @hidden
  70101. */
  70102. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70103. /**
  70104. * Disposes of the post process manager.
  70105. */
  70106. dispose(): void;
  70107. }
  70108. }
  70109. declare module BABYLON {
  70110. interface AbstractScene {
  70111. /**
  70112. * The list of layers (background and foreground) of the scene
  70113. */
  70114. layers: Array<Layer>;
  70115. }
  70116. /**
  70117. * Defines the layer scene component responsible to manage any layers
  70118. * in a given scene.
  70119. */
  70120. export class LayerSceneComponent implements ISceneComponent {
  70121. /**
  70122. * The component name helpfull to identify the component in the list of scene components.
  70123. */
  70124. readonly name: string;
  70125. /**
  70126. * The scene the component belongs to.
  70127. */
  70128. scene: Scene;
  70129. private _engine;
  70130. /**
  70131. * Creates a new instance of the component for the given scene
  70132. * @param scene Defines the scene to register the component in
  70133. */
  70134. constructor(scene: Scene);
  70135. /**
  70136. * Registers the component in a given scene
  70137. */
  70138. register(): void;
  70139. /**
  70140. * Rebuilds the elements related to this component in case of
  70141. * context lost for instance.
  70142. */
  70143. rebuild(): void;
  70144. /**
  70145. * Disposes the component and the associated ressources.
  70146. */
  70147. dispose(): void;
  70148. private _draw;
  70149. private _drawCameraPredicate;
  70150. private _drawCameraBackground;
  70151. private _drawCameraForeground;
  70152. private _drawRenderTargetPredicate;
  70153. private _drawRenderTargetBackground;
  70154. private _drawRenderTargetForeground;
  70155. }
  70156. }
  70157. declare module BABYLON {
  70158. /** @hidden */
  70159. export var layerPixelShader: {
  70160. name: string;
  70161. shader: string;
  70162. };
  70163. }
  70164. declare module BABYLON {
  70165. /** @hidden */
  70166. export var layerVertexShader: {
  70167. name: string;
  70168. shader: string;
  70169. };
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * This represents a full screen 2d layer.
  70174. * This can be useful to display a picture in the background of your scene for instance.
  70175. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70176. */
  70177. export class Layer {
  70178. /**
  70179. * Define the name of the layer.
  70180. */
  70181. name: string;
  70182. /**
  70183. * Define the texture the layer should display.
  70184. */
  70185. texture: Nullable<Texture>;
  70186. /**
  70187. * Is the layer in background or foreground.
  70188. */
  70189. isBackground: boolean;
  70190. /**
  70191. * Define the color of the layer (instead of texture).
  70192. */
  70193. color: Color4;
  70194. /**
  70195. * Define the scale of the layer in order to zoom in out of the texture.
  70196. */
  70197. scale: Vector2;
  70198. /**
  70199. * Define an offset for the layer in order to shift the texture.
  70200. */
  70201. offset: Vector2;
  70202. /**
  70203. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70204. */
  70205. alphaBlendingMode: number;
  70206. /**
  70207. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70208. * Alpha test will not mix with the background color in case of transparency.
  70209. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70210. */
  70211. alphaTest: boolean;
  70212. /**
  70213. * Define a mask to restrict the layer to only some of the scene cameras.
  70214. */
  70215. layerMask: number;
  70216. /**
  70217. * Define the list of render target the layer is visible into.
  70218. */
  70219. renderTargetTextures: RenderTargetTexture[];
  70220. /**
  70221. * Define if the layer is only used in renderTarget or if it also
  70222. * renders in the main frame buffer of the canvas.
  70223. */
  70224. renderOnlyInRenderTargetTextures: boolean;
  70225. private _scene;
  70226. private _vertexBuffers;
  70227. private _indexBuffer;
  70228. private _effect;
  70229. private _alphaTestEffect;
  70230. /**
  70231. * An event triggered when the layer is disposed.
  70232. */
  70233. onDisposeObservable: Observable<Layer>;
  70234. private _onDisposeObserver;
  70235. /**
  70236. * Back compatibility with callback before the onDisposeObservable existed.
  70237. * The set callback will be triggered when the layer has been disposed.
  70238. */
  70239. onDispose: () => void;
  70240. /**
  70241. * An event triggered before rendering the scene
  70242. */
  70243. onBeforeRenderObservable: Observable<Layer>;
  70244. private _onBeforeRenderObserver;
  70245. /**
  70246. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70247. * The set callback will be triggered just before rendering the layer.
  70248. */
  70249. onBeforeRender: () => void;
  70250. /**
  70251. * An event triggered after rendering the scene
  70252. */
  70253. onAfterRenderObservable: Observable<Layer>;
  70254. private _onAfterRenderObserver;
  70255. /**
  70256. * Back compatibility with callback before the onAfterRenderObservable existed.
  70257. * The set callback will be triggered just after rendering the layer.
  70258. */
  70259. onAfterRender: () => void;
  70260. /**
  70261. * Instantiates a new layer.
  70262. * This represents a full screen 2d layer.
  70263. * This can be useful to display a picture in the background of your scene for instance.
  70264. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70265. * @param name Define the name of the layer in the scene
  70266. * @param imgUrl Define the url of the texture to display in the layer
  70267. * @param scene Define the scene the layer belongs to
  70268. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70269. * @param color Defines a color for the layer
  70270. */
  70271. constructor(
  70272. /**
  70273. * Define the name of the layer.
  70274. */
  70275. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70276. private _createIndexBuffer;
  70277. /** @hidden */
  70278. _rebuild(): void;
  70279. /**
  70280. * Renders the layer in the scene.
  70281. */
  70282. render(): void;
  70283. /**
  70284. * Disposes and releases the associated ressources.
  70285. */
  70286. dispose(): void;
  70287. }
  70288. }
  70289. declare module BABYLON {
  70290. interface AbstractScene {
  70291. /**
  70292. * The list of procedural textures added to the scene
  70293. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70294. */
  70295. proceduralTextures: Array<ProceduralTexture>;
  70296. }
  70297. /**
  70298. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70299. * in a given scene.
  70300. */
  70301. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70302. /**
  70303. * The component name helpfull to identify the component in the list of scene components.
  70304. */
  70305. readonly name: string;
  70306. /**
  70307. * The scene the component belongs to.
  70308. */
  70309. scene: Scene;
  70310. /**
  70311. * Creates a new instance of the component for the given scene
  70312. * @param scene Defines the scene to register the component in
  70313. */
  70314. constructor(scene: Scene);
  70315. /**
  70316. * Registers the component in a given scene
  70317. */
  70318. register(): void;
  70319. /**
  70320. * Rebuilds the elements related to this component in case of
  70321. * context lost for instance.
  70322. */
  70323. rebuild(): void;
  70324. /**
  70325. * Disposes the component and the associated ressources.
  70326. */
  70327. dispose(): void;
  70328. private _beforeClear;
  70329. }
  70330. }
  70331. declare module BABYLON {
  70332. /** @hidden */
  70333. export var proceduralVertexShader: {
  70334. name: string;
  70335. shader: string;
  70336. };
  70337. }
  70338. declare module BABYLON {
  70339. /**
  70340. * 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.
  70341. * This is the base class of any Procedural texture and contains most of the shareable code.
  70342. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70343. */
  70344. export class ProceduralTexture extends Texture {
  70345. isCube: boolean;
  70346. /**
  70347. * Define if the texture is enabled or not (disabled texture will not render)
  70348. */
  70349. isEnabled: boolean;
  70350. /**
  70351. * Define if the texture must be cleared before rendering (default is true)
  70352. */
  70353. autoClear: boolean;
  70354. /**
  70355. * Callback called when the texture is generated
  70356. */
  70357. onGenerated: () => void;
  70358. /**
  70359. * Event raised when the texture is generated
  70360. */
  70361. onGeneratedObservable: Observable<ProceduralTexture>;
  70362. /** @hidden */
  70363. _generateMipMaps: boolean;
  70364. /** @hidden **/
  70365. _effect: Effect;
  70366. /** @hidden */
  70367. _textures: {
  70368. [key: string]: Texture;
  70369. };
  70370. private _size;
  70371. private _currentRefreshId;
  70372. private _refreshRate;
  70373. private _vertexBuffers;
  70374. private _indexBuffer;
  70375. private _uniforms;
  70376. private _samplers;
  70377. private _fragment;
  70378. private _floats;
  70379. private _ints;
  70380. private _floatsArrays;
  70381. private _colors3;
  70382. private _colors4;
  70383. private _vectors2;
  70384. private _vectors3;
  70385. private _matrices;
  70386. private _fallbackTexture;
  70387. private _fallbackTextureUsed;
  70388. private _engine;
  70389. private _cachedDefines;
  70390. private _contentUpdateId;
  70391. private _contentData;
  70392. /**
  70393. * Instantiates a new procedural texture.
  70394. * 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.
  70395. * This is the base class of any Procedural texture and contains most of the shareable code.
  70396. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70397. * @param name Define the name of the texture
  70398. * @param size Define the size of the texture to create
  70399. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70400. * @param scene Define the scene the texture belongs to
  70401. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70402. * @param generateMipMaps Define if the texture should creates mip maps or not
  70403. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70404. */
  70405. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70406. /**
  70407. * The effect that is created when initializing the post process.
  70408. * @returns The created effect corrisponding the the postprocess.
  70409. */
  70410. getEffect(): Effect;
  70411. /**
  70412. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70413. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70414. */
  70415. getContent(): Nullable<ArrayBufferView>;
  70416. private _createIndexBuffer;
  70417. /** @hidden */
  70418. _rebuild(): void;
  70419. /**
  70420. * Resets the texture in order to recreate its associated resources.
  70421. * This can be called in case of context loss
  70422. */
  70423. reset(): void;
  70424. protected _getDefines(): string;
  70425. /**
  70426. * Is the texture ready to be used ? (rendered at least once)
  70427. * @returns true if ready, otherwise, false.
  70428. */
  70429. isReady(): boolean;
  70430. /**
  70431. * Resets the refresh counter of the texture and start bak from scratch.
  70432. * Could be useful to regenerate the texture if it is setup to render only once.
  70433. */
  70434. resetRefreshCounter(): void;
  70435. /**
  70436. * Set the fragment shader to use in order to render the texture.
  70437. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70438. */
  70439. setFragment(fragment: any): void;
  70440. /**
  70441. * Define the refresh rate of the texture or the rendering frequency.
  70442. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70443. */
  70444. refreshRate: number;
  70445. /** @hidden */
  70446. _shouldRender(): boolean;
  70447. /**
  70448. * Get the size the texture is rendering at.
  70449. * @returns the size (texture is always squared)
  70450. */
  70451. getRenderSize(): number;
  70452. /**
  70453. * Resize the texture to new value.
  70454. * @param size Define the new size the texture should have
  70455. * @param generateMipMaps Define whether the new texture should create mip maps
  70456. */
  70457. resize(size: number, generateMipMaps: boolean): void;
  70458. private _checkUniform;
  70459. /**
  70460. * Set a texture in the shader program used to render.
  70461. * @param name Define the name of the uniform samplers as defined in the shader
  70462. * @param texture Define the texture to bind to this sampler
  70463. * @return the texture itself allowing "fluent" like uniform updates
  70464. */
  70465. setTexture(name: string, texture: Texture): ProceduralTexture;
  70466. /**
  70467. * Set a float in the shader.
  70468. * @param name Define the name of the uniform as defined in the shader
  70469. * @param value Define the value to give to the uniform
  70470. * @return the texture itself allowing "fluent" like uniform updates
  70471. */
  70472. setFloat(name: string, value: number): ProceduralTexture;
  70473. /**
  70474. * Set a int in the shader.
  70475. * @param name Define the name of the uniform as defined in the shader
  70476. * @param value Define the value to give to the uniform
  70477. * @return the texture itself allowing "fluent" like uniform updates
  70478. */
  70479. setInt(name: string, value: number): ProceduralTexture;
  70480. /**
  70481. * Set an array of floats in the shader.
  70482. * @param name Define the name of the uniform as defined in the shader
  70483. * @param value Define the value to give to the uniform
  70484. * @return the texture itself allowing "fluent" like uniform updates
  70485. */
  70486. setFloats(name: string, value: number[]): ProceduralTexture;
  70487. /**
  70488. * Set a vec3 in the shader from a Color3.
  70489. * @param name Define the name of the uniform as defined in the shader
  70490. * @param value Define the value to give to the uniform
  70491. * @return the texture itself allowing "fluent" like uniform updates
  70492. */
  70493. setColor3(name: string, value: Color3): ProceduralTexture;
  70494. /**
  70495. * Set a vec4 in the shader from a Color4.
  70496. * @param name Define the name of the uniform as defined in the shader
  70497. * @param value Define the value to give to the uniform
  70498. * @return the texture itself allowing "fluent" like uniform updates
  70499. */
  70500. setColor4(name: string, value: Color4): ProceduralTexture;
  70501. /**
  70502. * Set a vec2 in the shader from a Vector2.
  70503. * @param name Define the name of the uniform as defined in the shader
  70504. * @param value Define the value to give to the uniform
  70505. * @return the texture itself allowing "fluent" like uniform updates
  70506. */
  70507. setVector2(name: string, value: Vector2): ProceduralTexture;
  70508. /**
  70509. * Set a vec3 in the shader from a Vector3.
  70510. * @param name Define the name of the uniform as defined in the shader
  70511. * @param value Define the value to give to the uniform
  70512. * @return the texture itself allowing "fluent" like uniform updates
  70513. */
  70514. setVector3(name: string, value: Vector3): ProceduralTexture;
  70515. /**
  70516. * Set a mat4 in the shader from a MAtrix.
  70517. * @param name Define the name of the uniform as defined in the shader
  70518. * @param value Define the value to give to the uniform
  70519. * @return the texture itself allowing "fluent" like uniform updates
  70520. */
  70521. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70522. /**
  70523. * Render the texture to its associated render target.
  70524. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70525. */
  70526. render(useCameraPostProcess?: boolean): void;
  70527. /**
  70528. * Clone the texture.
  70529. * @returns the cloned texture
  70530. */
  70531. clone(): ProceduralTexture;
  70532. /**
  70533. * Dispose the texture and release its asoociated resources.
  70534. */
  70535. dispose(): void;
  70536. }
  70537. }
  70538. declare module BABYLON {
  70539. /**
  70540. * This represents the base class for particle system in Babylon.
  70541. * 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.
  70542. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70543. * @example https://doc.babylonjs.com/babylon101/particles
  70544. */
  70545. export class BaseParticleSystem {
  70546. /**
  70547. * Source color is added to the destination color without alpha affecting the result
  70548. */
  70549. static BLENDMODE_ONEONE: number;
  70550. /**
  70551. * Blend current color and particle color using particle’s alpha
  70552. */
  70553. static BLENDMODE_STANDARD: number;
  70554. /**
  70555. * Add current color and particle color multiplied by particle’s alpha
  70556. */
  70557. static BLENDMODE_ADD: number;
  70558. /**
  70559. * Multiply current color with particle color
  70560. */
  70561. static BLENDMODE_MULTIPLY: number;
  70562. /**
  70563. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70564. */
  70565. static BLENDMODE_MULTIPLYADD: number;
  70566. /**
  70567. * List of animations used by the particle system.
  70568. */
  70569. animations: Animation[];
  70570. /**
  70571. * The id of the Particle system.
  70572. */
  70573. id: string;
  70574. /**
  70575. * The friendly name of the Particle system.
  70576. */
  70577. name: string;
  70578. /**
  70579. * The rendering group used by the Particle system to chose when to render.
  70580. */
  70581. renderingGroupId: number;
  70582. /**
  70583. * The emitter represents the Mesh or position we are attaching the particle system to.
  70584. */
  70585. emitter: Nullable<AbstractMesh | Vector3>;
  70586. /**
  70587. * The maximum number of particles to emit per frame
  70588. */
  70589. emitRate: number;
  70590. /**
  70591. * If you want to launch only a few particles at once, that can be done, as well.
  70592. */
  70593. manualEmitCount: number;
  70594. /**
  70595. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70596. */
  70597. updateSpeed: number;
  70598. /**
  70599. * The amount of time the particle system is running (depends of the overall update speed).
  70600. */
  70601. targetStopDuration: number;
  70602. /**
  70603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70604. */
  70605. disposeOnStop: boolean;
  70606. /**
  70607. * Minimum power of emitting particles.
  70608. */
  70609. minEmitPower: number;
  70610. /**
  70611. * Maximum power of emitting particles.
  70612. */
  70613. maxEmitPower: number;
  70614. /**
  70615. * Minimum life time of emitting particles.
  70616. */
  70617. minLifeTime: number;
  70618. /**
  70619. * Maximum life time of emitting particles.
  70620. */
  70621. maxLifeTime: number;
  70622. /**
  70623. * Minimum Size of emitting particles.
  70624. */
  70625. minSize: number;
  70626. /**
  70627. * Maximum Size of emitting particles.
  70628. */
  70629. maxSize: number;
  70630. /**
  70631. * Minimum scale of emitting particles on X axis.
  70632. */
  70633. minScaleX: number;
  70634. /**
  70635. * Maximum scale of emitting particles on X axis.
  70636. */
  70637. maxScaleX: number;
  70638. /**
  70639. * Minimum scale of emitting particles on Y axis.
  70640. */
  70641. minScaleY: number;
  70642. /**
  70643. * Maximum scale of emitting particles on Y axis.
  70644. */
  70645. maxScaleY: number;
  70646. /**
  70647. * Gets or sets the minimal initial rotation in radians.
  70648. */
  70649. minInitialRotation: number;
  70650. /**
  70651. * Gets or sets the maximal initial rotation in radians.
  70652. */
  70653. maxInitialRotation: number;
  70654. /**
  70655. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70656. */
  70657. minAngularSpeed: number;
  70658. /**
  70659. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70660. */
  70661. maxAngularSpeed: number;
  70662. /**
  70663. * The texture used to render each particle. (this can be a spritesheet)
  70664. */
  70665. particleTexture: Nullable<Texture>;
  70666. /**
  70667. * The layer mask we are rendering the particles through.
  70668. */
  70669. layerMask: number;
  70670. /**
  70671. * This can help using your own shader to render the particle system.
  70672. * The according effect will be created
  70673. */
  70674. customShader: any;
  70675. /**
  70676. * By default particle system starts as soon as they are created. This prevents the
  70677. * automatic start to happen and let you decide when to start emitting particles.
  70678. */
  70679. preventAutoStart: boolean;
  70680. private _noiseTexture;
  70681. /**
  70682. * Gets or sets a texture used to add random noise to particle positions
  70683. */
  70684. noiseTexture: Nullable<ProceduralTexture>;
  70685. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70686. noiseStrength: Vector3;
  70687. /**
  70688. * Callback triggered when the particle animation is ending.
  70689. */
  70690. onAnimationEnd: Nullable<() => void>;
  70691. /**
  70692. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70693. */
  70694. blendMode: number;
  70695. /**
  70696. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70697. * to override the particles.
  70698. */
  70699. forceDepthWrite: boolean;
  70700. /** 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 */
  70701. preWarmCycles: number;
  70702. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70703. preWarmStepOffset: number;
  70704. /**
  70705. * 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)
  70706. */
  70707. spriteCellChangeSpeed: number;
  70708. /**
  70709. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70710. */
  70711. startSpriteCellID: number;
  70712. /**
  70713. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70714. */
  70715. endSpriteCellID: number;
  70716. /**
  70717. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70718. */
  70719. spriteCellWidth: number;
  70720. /**
  70721. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70722. */
  70723. spriteCellHeight: number;
  70724. /**
  70725. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70726. */
  70727. spriteRandomStartCell: boolean;
  70728. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70729. translationPivot: Vector2;
  70730. /** @hidden */
  70731. protected _isAnimationSheetEnabled: boolean;
  70732. /**
  70733. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70734. */
  70735. beginAnimationOnStart: boolean;
  70736. /**
  70737. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70738. */
  70739. beginAnimationFrom: number;
  70740. /**
  70741. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70742. */
  70743. beginAnimationTo: number;
  70744. /**
  70745. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70746. */
  70747. beginAnimationLoop: boolean;
  70748. /**
  70749. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70750. */
  70751. isAnimationSheetEnabled: boolean;
  70752. /**
  70753. * Get hosting scene
  70754. * @returns the scene
  70755. */
  70756. getScene(): Scene;
  70757. /**
  70758. * You can use gravity if you want to give an orientation to your particles.
  70759. */
  70760. gravity: Vector3;
  70761. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70762. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70763. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70764. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70765. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70766. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70767. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70768. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70769. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70770. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70771. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70772. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70773. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70774. /**
  70775. * Defines the delay in milliseconds before starting the system (0 by default)
  70776. */
  70777. startDelay: number;
  70778. /**
  70779. * Gets the current list of drag gradients.
  70780. * You must use addDragGradient and removeDragGradient to udpate this list
  70781. * @returns the list of drag gradients
  70782. */
  70783. getDragGradients(): Nullable<Array<FactorGradient>>;
  70784. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70785. limitVelocityDamping: number;
  70786. /**
  70787. * Gets the current list of limit velocity gradients.
  70788. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70789. * @returns the list of limit velocity gradients
  70790. */
  70791. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70792. /**
  70793. * Gets the current list of color gradients.
  70794. * You must use addColorGradient and removeColorGradient to udpate this list
  70795. * @returns the list of color gradients
  70796. */
  70797. getColorGradients(): Nullable<Array<ColorGradient>>;
  70798. /**
  70799. * Gets the current list of size gradients.
  70800. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70801. * @returns the list of size gradients
  70802. */
  70803. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70804. /**
  70805. * Gets the current list of color remap gradients.
  70806. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70807. * @returns the list of color remap gradients
  70808. */
  70809. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70810. /**
  70811. * Gets the current list of alpha remap gradients.
  70812. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70813. * @returns the list of alpha remap gradients
  70814. */
  70815. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70816. /**
  70817. * Gets the current list of life time gradients.
  70818. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70819. * @returns the list of life time gradients
  70820. */
  70821. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70822. /**
  70823. * Gets the current list of angular speed gradients.
  70824. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70825. * @returns the list of angular speed gradients
  70826. */
  70827. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70828. /**
  70829. * Gets the current list of velocity gradients.
  70830. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70831. * @returns the list of velocity gradients
  70832. */
  70833. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70834. /**
  70835. * Gets the current list of start size gradients.
  70836. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70837. * @returns the list of start size gradients
  70838. */
  70839. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70840. /**
  70841. * Gets the current list of emit rate gradients.
  70842. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70843. * @returns the list of emit rate gradients
  70844. */
  70845. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70846. /**
  70847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70849. */
  70850. direction1: Vector3;
  70851. /**
  70852. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70854. */
  70855. direction2: Vector3;
  70856. /**
  70857. * 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.
  70858. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70859. */
  70860. minEmitBox: Vector3;
  70861. /**
  70862. * 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.
  70863. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70864. */
  70865. maxEmitBox: Vector3;
  70866. /**
  70867. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70868. */
  70869. color1: Color4;
  70870. /**
  70871. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70872. */
  70873. color2: Color4;
  70874. /**
  70875. * Color the particle will have at the end of its lifetime
  70876. */
  70877. colorDead: Color4;
  70878. /**
  70879. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  70880. */
  70881. textureMask: Color4;
  70882. /**
  70883. * The particle emitter type defines the emitter used by the particle system.
  70884. * It can be for example box, sphere, or cone...
  70885. */
  70886. particleEmitterType: IParticleEmitterType;
  70887. /** @hidden */
  70888. _isSubEmitter: boolean;
  70889. /**
  70890. * Gets or sets the billboard mode to use when isBillboardBased = true.
  70891. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  70892. */
  70893. billboardMode: number;
  70894. protected _isBillboardBased: boolean;
  70895. /**
  70896. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  70897. */
  70898. isBillboardBased: boolean;
  70899. /**
  70900. * The scene the particle system belongs to.
  70901. */
  70902. protected _scene: Scene;
  70903. /**
  70904. * Local cache of defines for image processing.
  70905. */
  70906. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  70907. /**
  70908. * Default configuration related to image processing available in the standard Material.
  70909. */
  70910. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  70911. /**
  70912. * Gets the image processing configuration used either in this material.
  70913. */
  70914. /**
  70915. * Sets the Default image processing configuration used either in the this material.
  70916. *
  70917. * If sets to null, the scene one is in use.
  70918. */
  70919. imageProcessingConfiguration: ImageProcessingConfiguration;
  70920. /**
  70921. * Attaches a new image processing configuration to the Standard Material.
  70922. * @param configuration
  70923. */
  70924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  70925. /** @hidden */
  70926. protected _reset(): void;
  70927. /** @hidden */
  70928. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  70929. /**
  70930. * Instantiates a particle system.
  70931. * 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.
  70932. * @param name The name of the particle system
  70933. */
  70934. constructor(name: string);
  70935. /**
  70936. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  70937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  70938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  70939. * @returns the emitter
  70940. */
  70941. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  70942. /**
  70943. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  70944. * @param radius The radius of the hemisphere to emit from
  70945. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70946. * @returns the emitter
  70947. */
  70948. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  70949. /**
  70950. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  70951. * @param radius The radius of the sphere to emit from
  70952. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70953. * @returns the emitter
  70954. */
  70955. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  70956. /**
  70957. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  70958. * @param radius The radius of the sphere to emit from
  70959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  70960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  70961. * @returns the emitter
  70962. */
  70963. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  70964. /**
  70965. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  70966. * @param radius The radius of the emission cylinder
  70967. * @param height The height of the emission cylinder
  70968. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  70969. * @param directionRandomizer How much to randomize the particle direction [0-1]
  70970. * @returns the emitter
  70971. */
  70972. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  70973. /**
  70974. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  70975. * @param radius The radius of the cylinder to emit from
  70976. * @param height The height of the emission cylinder
  70977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  70979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  70980. * @returns the emitter
  70981. */
  70982. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  70983. /**
  70984. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  70985. * @param radius The radius of the cone to emit from
  70986. * @param angle The base angle of the cone
  70987. * @returns the emitter
  70988. */
  70989. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  70990. /**
  70991. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  70992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  70993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  70994. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  70995. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  70996. * @returns the emitter
  70997. */
  70998. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * Type of sub emitter
  71004. */
  71005. export enum SubEmitterType {
  71006. /**
  71007. * Attached to the particle over it's lifetime
  71008. */
  71009. ATTACHED = 0,
  71010. /**
  71011. * Created when the particle dies
  71012. */
  71013. END = 1
  71014. }
  71015. /**
  71016. * Sub emitter class used to emit particles from an existing particle
  71017. */
  71018. export class SubEmitter {
  71019. /**
  71020. * the particle system to be used by the sub emitter
  71021. */
  71022. particleSystem: ParticleSystem;
  71023. /**
  71024. * Type of the submitter (Default: END)
  71025. */
  71026. type: SubEmitterType;
  71027. /**
  71028. * 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)
  71029. * Note: This only is supported when using an emitter of type Mesh
  71030. */
  71031. inheritDirection: boolean;
  71032. /**
  71033. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71034. */
  71035. inheritedVelocityAmount: number;
  71036. /**
  71037. * Creates a sub emitter
  71038. * @param particleSystem the particle system to be used by the sub emitter
  71039. */
  71040. constructor(
  71041. /**
  71042. * the particle system to be used by the sub emitter
  71043. */
  71044. particleSystem: ParticleSystem);
  71045. /**
  71046. * Clones the sub emitter
  71047. * @returns the cloned sub emitter
  71048. */
  71049. clone(): SubEmitter;
  71050. /**
  71051. * Serialize current object to a JSON object
  71052. * @returns the serialized object
  71053. */
  71054. serialize(): any;
  71055. /** @hidden */
  71056. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71057. /**
  71058. * Creates a new SubEmitter from a serialized JSON version
  71059. * @param serializationObject defines the JSON object to read from
  71060. * @param scene defines the hosting scene
  71061. * @param rootUrl defines the rootUrl for data loading
  71062. * @returns a new SubEmitter
  71063. */
  71064. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71065. /** Release associated resources */
  71066. dispose(): void;
  71067. }
  71068. }
  71069. declare module BABYLON {
  71070. /** @hidden */
  71071. export var clipPlaneFragmentDeclaration: {
  71072. name: string;
  71073. shader: string;
  71074. };
  71075. }
  71076. declare module BABYLON {
  71077. /** @hidden */
  71078. export var imageProcessingDeclaration: {
  71079. name: string;
  71080. shader: string;
  71081. };
  71082. }
  71083. declare module BABYLON {
  71084. /** @hidden */
  71085. export var imageProcessingFunctions: {
  71086. name: string;
  71087. shader: string;
  71088. };
  71089. }
  71090. declare module BABYLON {
  71091. /** @hidden */
  71092. export var clipPlaneFragment: {
  71093. name: string;
  71094. shader: string;
  71095. };
  71096. }
  71097. declare module BABYLON {
  71098. /** @hidden */
  71099. export var particlesPixelShader: {
  71100. name: string;
  71101. shader: string;
  71102. };
  71103. }
  71104. declare module BABYLON {
  71105. /** @hidden */
  71106. export var clipPlaneVertexDeclaration: {
  71107. name: string;
  71108. shader: string;
  71109. };
  71110. }
  71111. declare module BABYLON {
  71112. /** @hidden */
  71113. export var clipPlaneVertex: {
  71114. name: string;
  71115. shader: string;
  71116. };
  71117. }
  71118. declare module BABYLON {
  71119. /** @hidden */
  71120. export var particlesVertexShader: {
  71121. name: string;
  71122. shader: string;
  71123. };
  71124. }
  71125. declare module BABYLON {
  71126. /**
  71127. * This represents a particle system in Babylon.
  71128. * 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.
  71129. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71130. * @example https://doc.babylonjs.com/babylon101/particles
  71131. */
  71132. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71133. /**
  71134. * Billboard mode will only apply to Y axis
  71135. */
  71136. static readonly BILLBOARDMODE_Y: number;
  71137. /**
  71138. * Billboard mode will apply to all axes
  71139. */
  71140. static readonly BILLBOARDMODE_ALL: number;
  71141. /**
  71142. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71143. */
  71144. static readonly BILLBOARDMODE_STRETCHED: number;
  71145. /**
  71146. * This function can be defined to provide custom update for active particles.
  71147. * This function will be called instead of regular update (age, position, color, etc.).
  71148. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71149. */
  71150. updateFunction: (particles: Particle[]) => void;
  71151. private _emitterWorldMatrix;
  71152. /**
  71153. * This function can be defined to specify initial direction for every new particle.
  71154. * It by default use the emitterType defined function
  71155. */
  71156. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71157. /**
  71158. * This function can be defined to specify initial position for every new particle.
  71159. * It by default use the emitterType defined function
  71160. */
  71161. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71162. /**
  71163. * @hidden
  71164. */
  71165. _inheritedVelocityOffset: Vector3;
  71166. /**
  71167. * An event triggered when the system is disposed
  71168. */
  71169. onDisposeObservable: Observable<ParticleSystem>;
  71170. private _onDisposeObserver;
  71171. /**
  71172. * Sets a callback that will be triggered when the system is disposed
  71173. */
  71174. onDispose: () => void;
  71175. private _particles;
  71176. private _epsilon;
  71177. private _capacity;
  71178. private _stockParticles;
  71179. private _newPartsExcess;
  71180. private _vertexData;
  71181. private _vertexBuffer;
  71182. private _vertexBuffers;
  71183. private _spriteBuffer;
  71184. private _indexBuffer;
  71185. private _effect;
  71186. private _customEffect;
  71187. private _cachedDefines;
  71188. private _scaledColorStep;
  71189. private _colorDiff;
  71190. private _scaledDirection;
  71191. private _scaledGravity;
  71192. private _currentRenderId;
  71193. private _alive;
  71194. private _useInstancing;
  71195. private _started;
  71196. private _stopped;
  71197. private _actualFrame;
  71198. private _scaledUpdateSpeed;
  71199. private _vertexBufferSize;
  71200. /** @hidden */
  71201. _currentEmitRateGradient: Nullable<FactorGradient>;
  71202. /** @hidden */
  71203. _currentEmitRate1: number;
  71204. /** @hidden */
  71205. _currentEmitRate2: number;
  71206. /** @hidden */
  71207. _currentStartSizeGradient: Nullable<FactorGradient>;
  71208. /** @hidden */
  71209. _currentStartSize1: number;
  71210. /** @hidden */
  71211. _currentStartSize2: number;
  71212. private readonly _rawTextureWidth;
  71213. private _rampGradientsTexture;
  71214. private _useRampGradients;
  71215. /** Gets or sets a boolean indicating that ramp gradients must be used
  71216. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71217. */
  71218. useRampGradients: boolean;
  71219. /**
  71220. * 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.
  71221. * 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: [])
  71222. */
  71223. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71224. private _subEmitters;
  71225. /**
  71226. * @hidden
  71227. * If the particle systems emitter should be disposed when the particle system is disposed
  71228. */
  71229. _disposeEmitterOnDispose: boolean;
  71230. /**
  71231. * The current active Sub-systems, this property is used by the root particle system only.
  71232. */
  71233. activeSubSystems: Array<ParticleSystem>;
  71234. private _rootParticleSystem;
  71235. /**
  71236. * Gets the current list of active particles
  71237. */
  71238. readonly particles: Particle[];
  71239. /**
  71240. * Returns the string "ParticleSystem"
  71241. * @returns a string containing the class name
  71242. */
  71243. getClassName(): string;
  71244. /**
  71245. * Instantiates a particle system.
  71246. * 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.
  71247. * @param name The name of the particle system
  71248. * @param capacity The max number of particles alive at the same time
  71249. * @param scene The scene the particle system belongs to
  71250. * @param customEffect a custom effect used to change the way particles are rendered by default
  71251. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71252. * @param epsilon Offset used to render the particles
  71253. */
  71254. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71255. private _addFactorGradient;
  71256. private _removeFactorGradient;
  71257. /**
  71258. * Adds a new life time gradient
  71259. * @param gradient defines the gradient to use (between 0 and 1)
  71260. * @param factor defines the life time factor to affect to the specified gradient
  71261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71262. * @returns the current particle system
  71263. */
  71264. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71265. /**
  71266. * Remove a specific life time gradient
  71267. * @param gradient defines the gradient to remove
  71268. * @returns the current particle system
  71269. */
  71270. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71271. /**
  71272. * Adds a new size gradient
  71273. * @param gradient defines the gradient to use (between 0 and 1)
  71274. * @param factor defines the size factor to affect to the specified gradient
  71275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71276. * @returns the current particle system
  71277. */
  71278. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71279. /**
  71280. * Remove a specific size gradient
  71281. * @param gradient defines the gradient to remove
  71282. * @returns the current particle system
  71283. */
  71284. removeSizeGradient(gradient: number): IParticleSystem;
  71285. /**
  71286. * Adds a new color remap gradient
  71287. * @param gradient defines the gradient to use (between 0 and 1)
  71288. * @param min defines the color remap minimal range
  71289. * @param max defines the color remap maximal range
  71290. * @returns the current particle system
  71291. */
  71292. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71293. /**
  71294. * Remove a specific color remap gradient
  71295. * @param gradient defines the gradient to remove
  71296. * @returns the current particle system
  71297. */
  71298. removeColorRemapGradient(gradient: number): IParticleSystem;
  71299. /**
  71300. * Adds a new alpha remap gradient
  71301. * @param gradient defines the gradient to use (between 0 and 1)
  71302. * @param min defines the alpha remap minimal range
  71303. * @param max defines the alpha remap maximal range
  71304. * @returns the current particle system
  71305. */
  71306. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71307. /**
  71308. * Remove a specific alpha remap gradient
  71309. * @param gradient defines the gradient to remove
  71310. * @returns the current particle system
  71311. */
  71312. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71313. /**
  71314. * Adds a new angular speed gradient
  71315. * @param gradient defines the gradient to use (between 0 and 1)
  71316. * @param factor defines the angular speed to affect to the specified gradient
  71317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71318. * @returns the current particle system
  71319. */
  71320. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71321. /**
  71322. * Remove a specific angular speed gradient
  71323. * @param gradient defines the gradient to remove
  71324. * @returns the current particle system
  71325. */
  71326. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71327. /**
  71328. * Adds a new velocity gradient
  71329. * @param gradient defines the gradient to use (between 0 and 1)
  71330. * @param factor defines the velocity to affect to the specified gradient
  71331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71332. * @returns the current particle system
  71333. */
  71334. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71335. /**
  71336. * Remove a specific velocity gradient
  71337. * @param gradient defines the gradient to remove
  71338. * @returns the current particle system
  71339. */
  71340. removeVelocityGradient(gradient: number): IParticleSystem;
  71341. /**
  71342. * Adds a new limit velocity gradient
  71343. * @param gradient defines the gradient to use (between 0 and 1)
  71344. * @param factor defines the limit velocity value to affect to the specified gradient
  71345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71346. * @returns the current particle system
  71347. */
  71348. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71349. /**
  71350. * Remove a specific limit velocity gradient
  71351. * @param gradient defines the gradient to remove
  71352. * @returns the current particle system
  71353. */
  71354. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71355. /**
  71356. * Adds a new drag gradient
  71357. * @param gradient defines the gradient to use (between 0 and 1)
  71358. * @param factor defines the drag value to affect to the specified gradient
  71359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71360. * @returns the current particle system
  71361. */
  71362. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71363. /**
  71364. * Remove a specific drag gradient
  71365. * @param gradient defines the gradient to remove
  71366. * @returns the current particle system
  71367. */
  71368. removeDragGradient(gradient: number): IParticleSystem;
  71369. /**
  71370. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71371. * @param gradient defines the gradient to use (between 0 and 1)
  71372. * @param factor defines the emit rate value to affect to the specified gradient
  71373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71374. * @returns the current particle system
  71375. */
  71376. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71377. /**
  71378. * Remove a specific emit rate gradient
  71379. * @param gradient defines the gradient to remove
  71380. * @returns the current particle system
  71381. */
  71382. removeEmitRateGradient(gradient: number): IParticleSystem;
  71383. /**
  71384. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71385. * @param gradient defines the gradient to use (between 0 and 1)
  71386. * @param factor defines the start size value to affect to the specified gradient
  71387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71388. * @returns the current particle system
  71389. */
  71390. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71391. /**
  71392. * Remove a specific start size gradient
  71393. * @param gradient defines the gradient to remove
  71394. * @returns the current particle system
  71395. */
  71396. removeStartSizeGradient(gradient: number): IParticleSystem;
  71397. private _createRampGradientTexture;
  71398. /**
  71399. * Gets the current list of ramp gradients.
  71400. * You must use addRampGradient and removeRampGradient to udpate this list
  71401. * @returns the list of ramp gradients
  71402. */
  71403. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71404. /**
  71405. * Adds a new ramp gradient used to remap particle colors
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param color defines the color to affect to the specified gradient
  71408. * @returns the current particle system
  71409. */
  71410. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71411. /**
  71412. * Remove a specific ramp gradient
  71413. * @param gradient defines the gradient to remove
  71414. * @returns the current particle system
  71415. */
  71416. removeRampGradient(gradient: number): ParticleSystem;
  71417. /**
  71418. * Adds a new color gradient
  71419. * @param gradient defines the gradient to use (between 0 and 1)
  71420. * @param color1 defines the color to affect to the specified gradient
  71421. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71422. * @returns this particle system
  71423. */
  71424. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71425. /**
  71426. * Remove a specific color gradient
  71427. * @param gradient defines the gradient to remove
  71428. * @returns this particle system
  71429. */
  71430. removeColorGradient(gradient: number): IParticleSystem;
  71431. private _fetchR;
  71432. protected _reset(): void;
  71433. private _resetEffect;
  71434. private _createVertexBuffers;
  71435. private _createIndexBuffer;
  71436. /**
  71437. * Gets the maximum number of particles active at the same time.
  71438. * @returns The max number of active particles.
  71439. */
  71440. getCapacity(): number;
  71441. /**
  71442. * Gets whether there are still active particles in the system.
  71443. * @returns True if it is alive, otherwise false.
  71444. */
  71445. isAlive(): boolean;
  71446. /**
  71447. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71448. * @returns True if it has been started, otherwise false.
  71449. */
  71450. isStarted(): boolean;
  71451. private _prepareSubEmitterInternalArray;
  71452. /**
  71453. * Starts the particle system and begins to emit
  71454. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71455. */
  71456. start(delay?: number): void;
  71457. /**
  71458. * Stops the particle system.
  71459. * @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.
  71460. */
  71461. stop(stopSubEmitters?: boolean): void;
  71462. /**
  71463. * Remove all active particles
  71464. */
  71465. reset(): void;
  71466. /**
  71467. * @hidden (for internal use only)
  71468. */
  71469. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71470. /**
  71471. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71472. * Its lifetime will start back at 0.
  71473. */
  71474. recycleParticle: (particle: Particle) => void;
  71475. private _stopSubEmitters;
  71476. private _createParticle;
  71477. private _removeFromRoot;
  71478. private _emitFromParticle;
  71479. private _update;
  71480. /** @hidden */
  71481. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71482. /** @hidden */
  71483. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71484. /** @hidden */
  71485. private _getEffect;
  71486. /**
  71487. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71488. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71489. */
  71490. animate(preWarmOnly?: boolean): void;
  71491. private _appendParticleVertices;
  71492. /**
  71493. * Rebuilds the particle system.
  71494. */
  71495. rebuild(): void;
  71496. /**
  71497. * Is this system ready to be used/rendered
  71498. * @return true if the system is ready
  71499. */
  71500. isReady(): boolean;
  71501. private _render;
  71502. /**
  71503. * Renders the particle system in its current state.
  71504. * @returns the current number of particles
  71505. */
  71506. render(): number;
  71507. /**
  71508. * Disposes the particle system and free the associated resources
  71509. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71510. */
  71511. dispose(disposeTexture?: boolean): void;
  71512. /**
  71513. * Clones the particle system.
  71514. * @param name The name of the cloned object
  71515. * @param newEmitter The new emitter to use
  71516. * @returns the cloned particle system
  71517. */
  71518. clone(name: string, newEmitter: any): ParticleSystem;
  71519. /**
  71520. * Serializes the particle system to a JSON object.
  71521. * @returns the JSON object
  71522. */
  71523. serialize(): any;
  71524. /** @hidden */
  71525. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71526. /** @hidden */
  71527. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71528. /**
  71529. * Parses a JSON object to create a particle system.
  71530. * @param parsedParticleSystem The JSON object to parse
  71531. * @param scene The scene to create the particle system in
  71532. * @param rootUrl The root url to use to load external dependencies like texture
  71533. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71534. * @returns the Parsed particle system
  71535. */
  71536. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71537. }
  71538. }
  71539. declare module BABYLON {
  71540. /**
  71541. * A particle represents one of the element emitted by a particle system.
  71542. * This is mainly define by its coordinates, direction, velocity and age.
  71543. */
  71544. export class Particle {
  71545. /**
  71546. * The particle system the particle belongs to.
  71547. */
  71548. particleSystem: ParticleSystem;
  71549. private static _Count;
  71550. /**
  71551. * Unique ID of the particle
  71552. */
  71553. id: number;
  71554. /**
  71555. * The world position of the particle in the scene.
  71556. */
  71557. position: Vector3;
  71558. /**
  71559. * The world direction of the particle in the scene.
  71560. */
  71561. direction: Vector3;
  71562. /**
  71563. * The color of the particle.
  71564. */
  71565. color: Color4;
  71566. /**
  71567. * The color change of the particle per step.
  71568. */
  71569. colorStep: Color4;
  71570. /**
  71571. * Defines how long will the life of the particle be.
  71572. */
  71573. lifeTime: number;
  71574. /**
  71575. * The current age of the particle.
  71576. */
  71577. age: number;
  71578. /**
  71579. * The current size of the particle.
  71580. */
  71581. size: number;
  71582. /**
  71583. * The current scale of the particle.
  71584. */
  71585. scale: Vector2;
  71586. /**
  71587. * The current angle of the particle.
  71588. */
  71589. angle: number;
  71590. /**
  71591. * Defines how fast is the angle changing.
  71592. */
  71593. angularSpeed: number;
  71594. /**
  71595. * Defines the cell index used by the particle to be rendered from a sprite.
  71596. */
  71597. cellIndex: number;
  71598. /**
  71599. * The information required to support color remapping
  71600. */
  71601. remapData: Vector4;
  71602. /** @hidden */
  71603. _randomCellOffset?: number;
  71604. /** @hidden */
  71605. _initialDirection: Nullable<Vector3>;
  71606. /** @hidden */
  71607. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71608. /** @hidden */
  71609. _initialStartSpriteCellID: number;
  71610. /** @hidden */
  71611. _initialEndSpriteCellID: number;
  71612. /** @hidden */
  71613. _currentColorGradient: Nullable<ColorGradient>;
  71614. /** @hidden */
  71615. _currentColor1: Color4;
  71616. /** @hidden */
  71617. _currentColor2: Color4;
  71618. /** @hidden */
  71619. _currentSizeGradient: Nullable<FactorGradient>;
  71620. /** @hidden */
  71621. _currentSize1: number;
  71622. /** @hidden */
  71623. _currentSize2: number;
  71624. /** @hidden */
  71625. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71626. /** @hidden */
  71627. _currentAngularSpeed1: number;
  71628. /** @hidden */
  71629. _currentAngularSpeed2: number;
  71630. /** @hidden */
  71631. _currentVelocityGradient: Nullable<FactorGradient>;
  71632. /** @hidden */
  71633. _currentVelocity1: number;
  71634. /** @hidden */
  71635. _currentVelocity2: number;
  71636. /** @hidden */
  71637. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71638. /** @hidden */
  71639. _currentLimitVelocity1: number;
  71640. /** @hidden */
  71641. _currentLimitVelocity2: number;
  71642. /** @hidden */
  71643. _currentDragGradient: Nullable<FactorGradient>;
  71644. /** @hidden */
  71645. _currentDrag1: number;
  71646. /** @hidden */
  71647. _currentDrag2: number;
  71648. /** @hidden */
  71649. _randomNoiseCoordinates1: Vector3;
  71650. /** @hidden */
  71651. _randomNoiseCoordinates2: Vector3;
  71652. /**
  71653. * Creates a new instance Particle
  71654. * @param particleSystem the particle system the particle belongs to
  71655. */
  71656. constructor(
  71657. /**
  71658. * The particle system the particle belongs to.
  71659. */
  71660. particleSystem: ParticleSystem);
  71661. private updateCellInfoFromSystem;
  71662. /**
  71663. * Defines how the sprite cell index is updated for the particle
  71664. */
  71665. updateCellIndex(): void;
  71666. /** @hidden */
  71667. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71668. /** @hidden */
  71669. _inheritParticleInfoToSubEmitters(): void;
  71670. /** @hidden */
  71671. _reset(): void;
  71672. /**
  71673. * Copy the properties of particle to another one.
  71674. * @param other the particle to copy the information to.
  71675. */
  71676. copyTo(other: Particle): void;
  71677. }
  71678. }
  71679. declare module BABYLON {
  71680. /**
  71681. * Particle emitter represents a volume emitting particles.
  71682. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71683. */
  71684. export interface IParticleEmitterType {
  71685. /**
  71686. * Called by the particle System when the direction is computed for the created particle.
  71687. * @param worldMatrix is the world matrix of the particle system
  71688. * @param directionToUpdate is the direction vector to update with the result
  71689. * @param particle is the particle we are computed the direction for
  71690. */
  71691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71692. /**
  71693. * Called by the particle System when the position is computed for the created particle.
  71694. * @param worldMatrix is the world matrix of the particle system
  71695. * @param positionToUpdate is the position vector to update with the result
  71696. * @param particle is the particle we are computed the position for
  71697. */
  71698. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71699. /**
  71700. * Clones the current emitter and returns a copy of it
  71701. * @returns the new emitter
  71702. */
  71703. clone(): IParticleEmitterType;
  71704. /**
  71705. * Called by the GPUParticleSystem to setup the update shader
  71706. * @param effect defines the update shader
  71707. */
  71708. applyToShader(effect: Effect): void;
  71709. /**
  71710. * Returns a string to use to update the GPU particles update shader
  71711. * @returns the effect defines string
  71712. */
  71713. getEffectDefines(): string;
  71714. /**
  71715. * Returns a string representing the class name
  71716. * @returns a string containing the class name
  71717. */
  71718. getClassName(): string;
  71719. /**
  71720. * Serializes the particle system to a JSON object.
  71721. * @returns the JSON object
  71722. */
  71723. serialize(): any;
  71724. /**
  71725. * Parse properties from a JSON object
  71726. * @param serializationObject defines the JSON object
  71727. */
  71728. parse(serializationObject: any): void;
  71729. }
  71730. }
  71731. declare module BABYLON {
  71732. /**
  71733. * Particle emitter emitting particles from the inside of a box.
  71734. * It emits the particles randomly between 2 given directions.
  71735. */
  71736. export class BoxParticleEmitter implements IParticleEmitterType {
  71737. /**
  71738. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71739. */
  71740. direction1: Vector3;
  71741. /**
  71742. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71743. */
  71744. direction2: Vector3;
  71745. /**
  71746. * 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.
  71747. */
  71748. minEmitBox: Vector3;
  71749. /**
  71750. * 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.
  71751. */
  71752. maxEmitBox: Vector3;
  71753. /**
  71754. * Creates a new instance BoxParticleEmitter
  71755. */
  71756. constructor();
  71757. /**
  71758. * Called by the particle System when the direction is computed for the created particle.
  71759. * @param worldMatrix is the world matrix of the particle system
  71760. * @param directionToUpdate is the direction vector to update with the result
  71761. * @param particle is the particle we are computed the direction for
  71762. */
  71763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71764. /**
  71765. * Called by the particle System when the position is computed for the created particle.
  71766. * @param worldMatrix is the world matrix of the particle system
  71767. * @param positionToUpdate is the position vector to update with the result
  71768. * @param particle is the particle we are computed the position for
  71769. */
  71770. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71771. /**
  71772. * Clones the current emitter and returns a copy of it
  71773. * @returns the new emitter
  71774. */
  71775. clone(): BoxParticleEmitter;
  71776. /**
  71777. * Called by the GPUParticleSystem to setup the update shader
  71778. * @param effect defines the update shader
  71779. */
  71780. applyToShader(effect: Effect): void;
  71781. /**
  71782. * Returns a string to use to update the GPU particles update shader
  71783. * @returns a string containng the defines string
  71784. */
  71785. getEffectDefines(): string;
  71786. /**
  71787. * Returns the string "BoxParticleEmitter"
  71788. * @returns a string containing the class name
  71789. */
  71790. getClassName(): string;
  71791. /**
  71792. * Serializes the particle system to a JSON object.
  71793. * @returns the JSON object
  71794. */
  71795. serialize(): any;
  71796. /**
  71797. * Parse properties from a JSON object
  71798. * @param serializationObject defines the JSON object
  71799. */
  71800. parse(serializationObject: any): void;
  71801. }
  71802. }
  71803. declare module BABYLON {
  71804. /**
  71805. * Particle emitter emitting particles from the inside of a cone.
  71806. * It emits the particles alongside the cone volume from the base to the particle.
  71807. * The emission direction might be randomized.
  71808. */
  71809. export class ConeParticleEmitter implements IParticleEmitterType {
  71810. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71811. directionRandomizer: number;
  71812. private _radius;
  71813. private _angle;
  71814. private _height;
  71815. /**
  71816. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71817. */
  71818. radiusRange: number;
  71819. /**
  71820. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71821. */
  71822. heightRange: number;
  71823. /**
  71824. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71825. */
  71826. emitFromSpawnPointOnly: boolean;
  71827. /**
  71828. * Gets or sets the radius of the emission cone
  71829. */
  71830. radius: number;
  71831. /**
  71832. * Gets or sets the angle of the emission cone
  71833. */
  71834. angle: number;
  71835. private _buildHeight;
  71836. /**
  71837. * Creates a new instance ConeParticleEmitter
  71838. * @param radius the radius of the emission cone (1 by default)
  71839. * @param angle the cone base angle (PI by default)
  71840. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71841. */
  71842. constructor(radius?: number, angle?: number,
  71843. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71844. directionRandomizer?: number);
  71845. /**
  71846. * Called by the particle System when the direction is computed for the created particle.
  71847. * @param worldMatrix is the world matrix of the particle system
  71848. * @param directionToUpdate is the direction vector to update with the result
  71849. * @param particle is the particle we are computed the direction for
  71850. */
  71851. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71852. /**
  71853. * Called by the particle System when the position is computed for the created particle.
  71854. * @param worldMatrix is the world matrix of the particle system
  71855. * @param positionToUpdate is the position vector to update with the result
  71856. * @param particle is the particle we are computed the position for
  71857. */
  71858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71859. /**
  71860. * Clones the current emitter and returns a copy of it
  71861. * @returns the new emitter
  71862. */
  71863. clone(): ConeParticleEmitter;
  71864. /**
  71865. * Called by the GPUParticleSystem to setup the update shader
  71866. * @param effect defines the update shader
  71867. */
  71868. applyToShader(effect: Effect): void;
  71869. /**
  71870. * Returns a string to use to update the GPU particles update shader
  71871. * @returns a string containng the defines string
  71872. */
  71873. getEffectDefines(): string;
  71874. /**
  71875. * Returns the string "ConeParticleEmitter"
  71876. * @returns a string containing the class name
  71877. */
  71878. getClassName(): string;
  71879. /**
  71880. * Serializes the particle system to a JSON object.
  71881. * @returns the JSON object
  71882. */
  71883. serialize(): any;
  71884. /**
  71885. * Parse properties from a JSON object
  71886. * @param serializationObject defines the JSON object
  71887. */
  71888. parse(serializationObject: any): void;
  71889. }
  71890. }
  71891. declare module BABYLON {
  71892. /**
  71893. * Particle emitter emitting particles from the inside of a cylinder.
  71894. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  71895. */
  71896. export class CylinderParticleEmitter implements IParticleEmitterType {
  71897. /**
  71898. * The radius of the emission cylinder.
  71899. */
  71900. radius: number;
  71901. /**
  71902. * The height of the emission cylinder.
  71903. */
  71904. height: number;
  71905. /**
  71906. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71907. */
  71908. radiusRange: number;
  71909. /**
  71910. * How much to randomize the particle direction [0-1].
  71911. */
  71912. directionRandomizer: number;
  71913. /**
  71914. * Creates a new instance CylinderParticleEmitter
  71915. * @param radius the radius of the emission cylinder (1 by default)
  71916. * @param height the height of the emission cylinder (1 by default)
  71917. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71918. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71919. */
  71920. constructor(
  71921. /**
  71922. * The radius of the emission cylinder.
  71923. */
  71924. radius?: number,
  71925. /**
  71926. * The height of the emission cylinder.
  71927. */
  71928. height?: number,
  71929. /**
  71930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71931. */
  71932. radiusRange?: number,
  71933. /**
  71934. * How much to randomize the particle direction [0-1].
  71935. */
  71936. directionRandomizer?: number);
  71937. /**
  71938. * Called by the particle System when the direction is computed for the created particle.
  71939. * @param worldMatrix is the world matrix of the particle system
  71940. * @param directionToUpdate is the direction vector to update with the result
  71941. * @param particle is the particle we are computed the direction for
  71942. */
  71943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71944. /**
  71945. * Called by the particle System when the position is computed for the created particle.
  71946. * @param worldMatrix is the world matrix of the particle system
  71947. * @param positionToUpdate is the position vector to update with the result
  71948. * @param particle is the particle we are computed the position for
  71949. */
  71950. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71951. /**
  71952. * Clones the current emitter and returns a copy of it
  71953. * @returns the new emitter
  71954. */
  71955. clone(): CylinderParticleEmitter;
  71956. /**
  71957. * Called by the GPUParticleSystem to setup the update shader
  71958. * @param effect defines the update shader
  71959. */
  71960. applyToShader(effect: Effect): void;
  71961. /**
  71962. * Returns a string to use to update the GPU particles update shader
  71963. * @returns a string containng the defines string
  71964. */
  71965. getEffectDefines(): string;
  71966. /**
  71967. * Returns the string "CylinderParticleEmitter"
  71968. * @returns a string containing the class name
  71969. */
  71970. getClassName(): string;
  71971. /**
  71972. * Serializes the particle system to a JSON object.
  71973. * @returns the JSON object
  71974. */
  71975. serialize(): any;
  71976. /**
  71977. * Parse properties from a JSON object
  71978. * @param serializationObject defines the JSON object
  71979. */
  71980. parse(serializationObject: any): void;
  71981. }
  71982. /**
  71983. * Particle emitter emitting particles from the inside of a cylinder.
  71984. * It emits the particles randomly between two vectors.
  71985. */
  71986. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  71987. /**
  71988. * The min limit of the emission direction.
  71989. */
  71990. direction1: Vector3;
  71991. /**
  71992. * The max limit of the emission direction.
  71993. */
  71994. direction2: Vector3;
  71995. /**
  71996. * Creates a new instance CylinderDirectedParticleEmitter
  71997. * @param radius the radius of the emission cylinder (1 by default)
  71998. * @param height the height of the emission cylinder (1 by default)
  71999. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72000. * @param direction1 the min limit of the emission direction (up vector by default)
  72001. * @param direction2 the max limit of the emission direction (up vector by default)
  72002. */
  72003. constructor(radius?: number, height?: number, radiusRange?: number,
  72004. /**
  72005. * The min limit of the emission direction.
  72006. */
  72007. direction1?: Vector3,
  72008. /**
  72009. * The max limit of the emission direction.
  72010. */
  72011. direction2?: Vector3);
  72012. /**
  72013. * Called by the particle System when the direction is computed for the created particle.
  72014. * @param worldMatrix is the world matrix of the particle system
  72015. * @param directionToUpdate is the direction vector to update with the result
  72016. * @param particle is the particle we are computed the direction for
  72017. */
  72018. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72019. /**
  72020. * Clones the current emitter and returns a copy of it
  72021. * @returns the new emitter
  72022. */
  72023. clone(): CylinderDirectedParticleEmitter;
  72024. /**
  72025. * Called by the GPUParticleSystem to setup the update shader
  72026. * @param effect defines the update shader
  72027. */
  72028. applyToShader(effect: Effect): void;
  72029. /**
  72030. * Returns a string to use to update the GPU particles update shader
  72031. * @returns a string containng the defines string
  72032. */
  72033. getEffectDefines(): string;
  72034. /**
  72035. * Returns the string "CylinderDirectedParticleEmitter"
  72036. * @returns a string containing the class name
  72037. */
  72038. getClassName(): string;
  72039. /**
  72040. * Serializes the particle system to a JSON object.
  72041. * @returns the JSON object
  72042. */
  72043. serialize(): any;
  72044. /**
  72045. * Parse properties from a JSON object
  72046. * @param serializationObject defines the JSON object
  72047. */
  72048. parse(serializationObject: any): void;
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /**
  72053. * Particle emitter emitting particles from the inside of a hemisphere.
  72054. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72055. */
  72056. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72057. /**
  72058. * The radius of the emission hemisphere.
  72059. */
  72060. radius: number;
  72061. /**
  72062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72063. */
  72064. radiusRange: number;
  72065. /**
  72066. * How much to randomize the particle direction [0-1].
  72067. */
  72068. directionRandomizer: number;
  72069. /**
  72070. * Creates a new instance HemisphericParticleEmitter
  72071. * @param radius the radius of the emission hemisphere (1 by default)
  72072. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72073. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72074. */
  72075. constructor(
  72076. /**
  72077. * The radius of the emission hemisphere.
  72078. */
  72079. radius?: number,
  72080. /**
  72081. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72082. */
  72083. radiusRange?: number,
  72084. /**
  72085. * How much to randomize the particle direction [0-1].
  72086. */
  72087. directionRandomizer?: number);
  72088. /**
  72089. * Called by the particle System when the direction is computed for the created particle.
  72090. * @param worldMatrix is the world matrix of the particle system
  72091. * @param directionToUpdate is the direction vector to update with the result
  72092. * @param particle is the particle we are computed the direction for
  72093. */
  72094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72095. /**
  72096. * Called by the particle System when the position is computed for the created particle.
  72097. * @param worldMatrix is the world matrix of the particle system
  72098. * @param positionToUpdate is the position vector to update with the result
  72099. * @param particle is the particle we are computed the position for
  72100. */
  72101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72102. /**
  72103. * Clones the current emitter and returns a copy of it
  72104. * @returns the new emitter
  72105. */
  72106. clone(): HemisphericParticleEmitter;
  72107. /**
  72108. * Called by the GPUParticleSystem to setup the update shader
  72109. * @param effect defines the update shader
  72110. */
  72111. applyToShader(effect: Effect): void;
  72112. /**
  72113. * Returns a string to use to update the GPU particles update shader
  72114. * @returns a string containng the defines string
  72115. */
  72116. getEffectDefines(): string;
  72117. /**
  72118. * Returns the string "HemisphericParticleEmitter"
  72119. * @returns a string containing the class name
  72120. */
  72121. getClassName(): string;
  72122. /**
  72123. * Serializes the particle system to a JSON object.
  72124. * @returns the JSON object
  72125. */
  72126. serialize(): any;
  72127. /**
  72128. * Parse properties from a JSON object
  72129. * @param serializationObject defines the JSON object
  72130. */
  72131. parse(serializationObject: any): void;
  72132. }
  72133. }
  72134. declare module BABYLON {
  72135. /**
  72136. * Particle emitter emitting particles from a point.
  72137. * It emits the particles randomly between 2 given directions.
  72138. */
  72139. export class PointParticleEmitter implements IParticleEmitterType {
  72140. /**
  72141. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72142. */
  72143. direction1: Vector3;
  72144. /**
  72145. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72146. */
  72147. direction2: Vector3;
  72148. /**
  72149. * Creates a new instance PointParticleEmitter
  72150. */
  72151. constructor();
  72152. /**
  72153. * Called by the particle System when the direction is computed for the created particle.
  72154. * @param worldMatrix is the world matrix of the particle system
  72155. * @param directionToUpdate is the direction vector to update with the result
  72156. * @param particle is the particle we are computed the direction for
  72157. */
  72158. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72159. /**
  72160. * Called by the particle System when the position is computed for the created particle.
  72161. * @param worldMatrix is the world matrix of the particle system
  72162. * @param positionToUpdate is the position vector to update with the result
  72163. * @param particle is the particle we are computed the position for
  72164. */
  72165. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72166. /**
  72167. * Clones the current emitter and returns a copy of it
  72168. * @returns the new emitter
  72169. */
  72170. clone(): PointParticleEmitter;
  72171. /**
  72172. * Called by the GPUParticleSystem to setup the update shader
  72173. * @param effect defines the update shader
  72174. */
  72175. applyToShader(effect: Effect): void;
  72176. /**
  72177. * Returns a string to use to update the GPU particles update shader
  72178. * @returns a string containng the defines string
  72179. */
  72180. getEffectDefines(): string;
  72181. /**
  72182. * Returns the string "PointParticleEmitter"
  72183. * @returns a string containing the class name
  72184. */
  72185. getClassName(): string;
  72186. /**
  72187. * Serializes the particle system to a JSON object.
  72188. * @returns the JSON object
  72189. */
  72190. serialize(): any;
  72191. /**
  72192. * Parse properties from a JSON object
  72193. * @param serializationObject defines the JSON object
  72194. */
  72195. parse(serializationObject: any): void;
  72196. }
  72197. }
  72198. declare module BABYLON {
  72199. /**
  72200. * Particle emitter emitting particles from the inside of a sphere.
  72201. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72202. */
  72203. export class SphereParticleEmitter implements IParticleEmitterType {
  72204. /**
  72205. * The radius of the emission sphere.
  72206. */
  72207. radius: number;
  72208. /**
  72209. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72210. */
  72211. radiusRange: number;
  72212. /**
  72213. * How much to randomize the particle direction [0-1].
  72214. */
  72215. directionRandomizer: number;
  72216. /**
  72217. * Creates a new instance SphereParticleEmitter
  72218. * @param radius the radius of the emission sphere (1 by default)
  72219. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72220. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72221. */
  72222. constructor(
  72223. /**
  72224. * The radius of the emission sphere.
  72225. */
  72226. radius?: number,
  72227. /**
  72228. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72229. */
  72230. radiusRange?: number,
  72231. /**
  72232. * How much to randomize the particle direction [0-1].
  72233. */
  72234. directionRandomizer?: number);
  72235. /**
  72236. * Called by the particle System when the direction is computed for the created particle.
  72237. * @param worldMatrix is the world matrix of the particle system
  72238. * @param directionToUpdate is the direction vector to update with the result
  72239. * @param particle is the particle we are computed the direction for
  72240. */
  72241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72242. /**
  72243. * Called by the particle System when the position is computed for the created particle.
  72244. * @param worldMatrix is the world matrix of the particle system
  72245. * @param positionToUpdate is the position vector to update with the result
  72246. * @param particle is the particle we are computed the position for
  72247. */
  72248. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72249. /**
  72250. * Clones the current emitter and returns a copy of it
  72251. * @returns the new emitter
  72252. */
  72253. clone(): SphereParticleEmitter;
  72254. /**
  72255. * Called by the GPUParticleSystem to setup the update shader
  72256. * @param effect defines the update shader
  72257. */
  72258. applyToShader(effect: Effect): void;
  72259. /**
  72260. * Returns a string to use to update the GPU particles update shader
  72261. * @returns a string containng the defines string
  72262. */
  72263. getEffectDefines(): string;
  72264. /**
  72265. * Returns the string "SphereParticleEmitter"
  72266. * @returns a string containing the class name
  72267. */
  72268. getClassName(): string;
  72269. /**
  72270. * Serializes the particle system to a JSON object.
  72271. * @returns the JSON object
  72272. */
  72273. serialize(): any;
  72274. /**
  72275. * Parse properties from a JSON object
  72276. * @param serializationObject defines the JSON object
  72277. */
  72278. parse(serializationObject: any): void;
  72279. }
  72280. /**
  72281. * Particle emitter emitting particles from the inside of a sphere.
  72282. * It emits the particles randomly between two vectors.
  72283. */
  72284. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72285. /**
  72286. * The min limit of the emission direction.
  72287. */
  72288. direction1: Vector3;
  72289. /**
  72290. * The max limit of the emission direction.
  72291. */
  72292. direction2: Vector3;
  72293. /**
  72294. * Creates a new instance SphereDirectedParticleEmitter
  72295. * @param radius the radius of the emission sphere (1 by default)
  72296. * @param direction1 the min limit of the emission direction (up vector by default)
  72297. * @param direction2 the max limit of the emission direction (up vector by default)
  72298. */
  72299. constructor(radius?: number,
  72300. /**
  72301. * The min limit of the emission direction.
  72302. */
  72303. direction1?: Vector3,
  72304. /**
  72305. * The max limit of the emission direction.
  72306. */
  72307. direction2?: Vector3);
  72308. /**
  72309. * Called by the particle System when the direction is computed for the created particle.
  72310. * @param worldMatrix is the world matrix of the particle system
  72311. * @param directionToUpdate is the direction vector to update with the result
  72312. * @param particle is the particle we are computed the direction for
  72313. */
  72314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72315. /**
  72316. * Clones the current emitter and returns a copy of it
  72317. * @returns the new emitter
  72318. */
  72319. clone(): SphereDirectedParticleEmitter;
  72320. /**
  72321. * Called by the GPUParticleSystem to setup the update shader
  72322. * @param effect defines the update shader
  72323. */
  72324. applyToShader(effect: Effect): void;
  72325. /**
  72326. * Returns a string to use to update the GPU particles update shader
  72327. * @returns a string containng the defines string
  72328. */
  72329. getEffectDefines(): string;
  72330. /**
  72331. * Returns the string "SphereDirectedParticleEmitter"
  72332. * @returns a string containing the class name
  72333. */
  72334. getClassName(): string;
  72335. /**
  72336. * Serializes the particle system to a JSON object.
  72337. * @returns the JSON object
  72338. */
  72339. serialize(): any;
  72340. /**
  72341. * Parse properties from a JSON object
  72342. * @param serializationObject defines the JSON object
  72343. */
  72344. parse(serializationObject: any): void;
  72345. }
  72346. }
  72347. declare module BABYLON {
  72348. /**
  72349. * Interface representing a particle system in Babylon.js.
  72350. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72351. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72352. */
  72353. export interface IParticleSystem {
  72354. /**
  72355. * List of animations used by the particle system.
  72356. */
  72357. animations: Animation[];
  72358. /**
  72359. * The id of the Particle system.
  72360. */
  72361. id: string;
  72362. /**
  72363. * The name of the Particle system.
  72364. */
  72365. name: string;
  72366. /**
  72367. * The emitter represents the Mesh or position we are attaching the particle system to.
  72368. */
  72369. emitter: Nullable<AbstractMesh | Vector3>;
  72370. /**
  72371. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72372. */
  72373. isBillboardBased: boolean;
  72374. /**
  72375. * The rendering group used by the Particle system to chose when to render.
  72376. */
  72377. renderingGroupId: number;
  72378. /**
  72379. * The layer mask we are rendering the particles through.
  72380. */
  72381. layerMask: number;
  72382. /**
  72383. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72384. */
  72385. updateSpeed: number;
  72386. /**
  72387. * The amount of time the particle system is running (depends of the overall update speed).
  72388. */
  72389. targetStopDuration: number;
  72390. /**
  72391. * The texture used to render each particle. (this can be a spritesheet)
  72392. */
  72393. particleTexture: Nullable<Texture>;
  72394. /**
  72395. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72396. */
  72397. blendMode: number;
  72398. /**
  72399. * Minimum life time of emitting particles.
  72400. */
  72401. minLifeTime: number;
  72402. /**
  72403. * Maximum life time of emitting particles.
  72404. */
  72405. maxLifeTime: number;
  72406. /**
  72407. * Minimum Size of emitting particles.
  72408. */
  72409. minSize: number;
  72410. /**
  72411. * Maximum Size of emitting particles.
  72412. */
  72413. maxSize: number;
  72414. /**
  72415. * Minimum scale of emitting particles on X axis.
  72416. */
  72417. minScaleX: number;
  72418. /**
  72419. * Maximum scale of emitting particles on X axis.
  72420. */
  72421. maxScaleX: number;
  72422. /**
  72423. * Minimum scale of emitting particles on Y axis.
  72424. */
  72425. minScaleY: number;
  72426. /**
  72427. * Maximum scale of emitting particles on Y axis.
  72428. */
  72429. maxScaleY: number;
  72430. /**
  72431. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72432. */
  72433. color1: Color4;
  72434. /**
  72435. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72436. */
  72437. color2: Color4;
  72438. /**
  72439. * Color the particle will have at the end of its lifetime.
  72440. */
  72441. colorDead: Color4;
  72442. /**
  72443. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72444. */
  72445. emitRate: number;
  72446. /**
  72447. * You can use gravity if you want to give an orientation to your particles.
  72448. */
  72449. gravity: Vector3;
  72450. /**
  72451. * Minimum power of emitting particles.
  72452. */
  72453. minEmitPower: number;
  72454. /**
  72455. * Maximum power of emitting particles.
  72456. */
  72457. maxEmitPower: number;
  72458. /**
  72459. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72460. */
  72461. minAngularSpeed: number;
  72462. /**
  72463. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72464. */
  72465. maxAngularSpeed: number;
  72466. /**
  72467. * Gets or sets the minimal initial rotation in radians.
  72468. */
  72469. minInitialRotation: number;
  72470. /**
  72471. * Gets or sets the maximal initial rotation in radians.
  72472. */
  72473. maxInitialRotation: number;
  72474. /**
  72475. * The particle emitter type defines the emitter used by the particle system.
  72476. * It can be for example box, sphere, or cone...
  72477. */
  72478. particleEmitterType: Nullable<IParticleEmitterType>;
  72479. /**
  72480. * Defines the delay in milliseconds before starting the system (0 by default)
  72481. */
  72482. startDelay: number;
  72483. /**
  72484. * 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
  72485. */
  72486. preWarmCycles: number;
  72487. /**
  72488. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72489. */
  72490. preWarmStepOffset: number;
  72491. /**
  72492. * 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)
  72493. */
  72494. spriteCellChangeSpeed: number;
  72495. /**
  72496. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72497. */
  72498. startSpriteCellID: number;
  72499. /**
  72500. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72501. */
  72502. endSpriteCellID: number;
  72503. /**
  72504. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72505. */
  72506. spriteCellWidth: number;
  72507. /**
  72508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72509. */
  72510. spriteCellHeight: number;
  72511. /**
  72512. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72513. */
  72514. spriteRandomStartCell: boolean;
  72515. /**
  72516. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72517. */
  72518. isAnimationSheetEnabled: boolean;
  72519. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72520. translationPivot: Vector2;
  72521. /**
  72522. * Gets or sets a texture used to add random noise to particle positions
  72523. */
  72524. noiseTexture: Nullable<BaseTexture>;
  72525. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72526. noiseStrength: Vector3;
  72527. /**
  72528. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72529. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72530. */
  72531. billboardMode: number;
  72532. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72533. limitVelocityDamping: number;
  72534. /**
  72535. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72536. */
  72537. beginAnimationOnStart: boolean;
  72538. /**
  72539. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72540. */
  72541. beginAnimationFrom: number;
  72542. /**
  72543. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72544. */
  72545. beginAnimationTo: number;
  72546. /**
  72547. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72548. */
  72549. beginAnimationLoop: boolean;
  72550. /**
  72551. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72552. */
  72553. disposeOnStop: boolean;
  72554. /**
  72555. * Gets the maximum number of particles active at the same time.
  72556. * @returns The max number of active particles.
  72557. */
  72558. getCapacity(): number;
  72559. /**
  72560. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72561. * @returns True if it has been started, otherwise false.
  72562. */
  72563. isStarted(): boolean;
  72564. /**
  72565. * Animates the particle system for this frame.
  72566. */
  72567. animate(): void;
  72568. /**
  72569. * Renders the particle system in its current state.
  72570. * @returns the current number of particles
  72571. */
  72572. render(): number;
  72573. /**
  72574. * Dispose the particle system and frees its associated resources.
  72575. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72576. */
  72577. dispose(disposeTexture?: boolean): void;
  72578. /**
  72579. * Clones the particle system.
  72580. * @param name The name of the cloned object
  72581. * @param newEmitter The new emitter to use
  72582. * @returns the cloned particle system
  72583. */
  72584. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72585. /**
  72586. * Serializes the particle system to a JSON object.
  72587. * @returns the JSON object
  72588. */
  72589. serialize(): any;
  72590. /**
  72591. * Rebuild the particle system
  72592. */
  72593. rebuild(): void;
  72594. /**
  72595. * Starts the particle system and begins to emit
  72596. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72597. */
  72598. start(delay?: number): void;
  72599. /**
  72600. * Stops the particle system.
  72601. */
  72602. stop(): void;
  72603. /**
  72604. * Remove all active particles
  72605. */
  72606. reset(): void;
  72607. /**
  72608. * Is this system ready to be used/rendered
  72609. * @return true if the system is ready
  72610. */
  72611. isReady(): boolean;
  72612. /**
  72613. * Adds a new color gradient
  72614. * @param gradient defines the gradient to use (between 0 and 1)
  72615. * @param color1 defines the color to affect to the specified gradient
  72616. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72617. * @returns the current particle system
  72618. */
  72619. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72620. /**
  72621. * Remove a specific color gradient
  72622. * @param gradient defines the gradient to remove
  72623. * @returns the current particle system
  72624. */
  72625. removeColorGradient(gradient: number): IParticleSystem;
  72626. /**
  72627. * Adds a new size gradient
  72628. * @param gradient defines the gradient to use (between 0 and 1)
  72629. * @param factor defines the size factor to affect to the specified gradient
  72630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72631. * @returns the current particle system
  72632. */
  72633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72634. /**
  72635. * Remove a specific size gradient
  72636. * @param gradient defines the gradient to remove
  72637. * @returns the current particle system
  72638. */
  72639. removeSizeGradient(gradient: number): IParticleSystem;
  72640. /**
  72641. * Gets the current list of color gradients.
  72642. * You must use addColorGradient and removeColorGradient to udpate this list
  72643. * @returns the list of color gradients
  72644. */
  72645. getColorGradients(): Nullable<Array<ColorGradient>>;
  72646. /**
  72647. * Gets the current list of size gradients.
  72648. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72649. * @returns the list of size gradients
  72650. */
  72651. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72652. /**
  72653. * Gets the current list of angular speed gradients.
  72654. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72655. * @returns the list of angular speed gradients
  72656. */
  72657. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72658. /**
  72659. * Adds a new angular speed gradient
  72660. * @param gradient defines the gradient to use (between 0 and 1)
  72661. * @param factor defines the angular speed to affect to the specified gradient
  72662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72663. * @returns the current particle system
  72664. */
  72665. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72666. /**
  72667. * Remove a specific angular speed gradient
  72668. * @param gradient defines the gradient to remove
  72669. * @returns the current particle system
  72670. */
  72671. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72672. /**
  72673. * Gets the current list of velocity gradients.
  72674. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72675. * @returns the list of velocity gradients
  72676. */
  72677. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72678. /**
  72679. * Adds a new velocity gradient
  72680. * @param gradient defines the gradient to use (between 0 and 1)
  72681. * @param factor defines the velocity to affect to the specified gradient
  72682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72683. * @returns the current particle system
  72684. */
  72685. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72686. /**
  72687. * Remove a specific velocity gradient
  72688. * @param gradient defines the gradient to remove
  72689. * @returns the current particle system
  72690. */
  72691. removeVelocityGradient(gradient: number): IParticleSystem;
  72692. /**
  72693. * Gets the current list of limit velocity gradients.
  72694. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72695. * @returns the list of limit velocity gradients
  72696. */
  72697. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72698. /**
  72699. * Adds a new limit velocity gradient
  72700. * @param gradient defines the gradient to use (between 0 and 1)
  72701. * @param factor defines the limit velocity to affect to the specified gradient
  72702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72703. * @returns the current particle system
  72704. */
  72705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72706. /**
  72707. * Remove a specific limit velocity gradient
  72708. * @param gradient defines the gradient to remove
  72709. * @returns the current particle system
  72710. */
  72711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72712. /**
  72713. * Adds a new drag gradient
  72714. * @param gradient defines the gradient to use (between 0 and 1)
  72715. * @param factor defines the drag to affect to the specified gradient
  72716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72717. * @returns the current particle system
  72718. */
  72719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72720. /**
  72721. * Remove a specific drag gradient
  72722. * @param gradient defines the gradient to remove
  72723. * @returns the current particle system
  72724. */
  72725. removeDragGradient(gradient: number): IParticleSystem;
  72726. /**
  72727. * Gets the current list of drag gradients.
  72728. * You must use addDragGradient and removeDragGradient to udpate this list
  72729. * @returns the list of drag gradients
  72730. */
  72731. getDragGradients(): Nullable<Array<FactorGradient>>;
  72732. /**
  72733. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72734. * @param gradient defines the gradient to use (between 0 and 1)
  72735. * @param factor defines the emit rate to affect to the specified gradient
  72736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72737. * @returns the current particle system
  72738. */
  72739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72740. /**
  72741. * Remove a specific emit rate gradient
  72742. * @param gradient defines the gradient to remove
  72743. * @returns the current particle system
  72744. */
  72745. removeEmitRateGradient(gradient: number): IParticleSystem;
  72746. /**
  72747. * Gets the current list of emit rate gradients.
  72748. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72749. * @returns the list of emit rate gradients
  72750. */
  72751. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72752. /**
  72753. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72754. * @param gradient defines the gradient to use (between 0 and 1)
  72755. * @param factor defines the start size to affect to the specified gradient
  72756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72757. * @returns the current particle system
  72758. */
  72759. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72760. /**
  72761. * Remove a specific start size gradient
  72762. * @param gradient defines the gradient to remove
  72763. * @returns the current particle system
  72764. */
  72765. removeStartSizeGradient(gradient: number): IParticleSystem;
  72766. /**
  72767. * Gets the current list of start size gradients.
  72768. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72769. * @returns the list of start size gradients
  72770. */
  72771. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72772. /**
  72773. * Adds a new life time gradient
  72774. * @param gradient defines the gradient to use (between 0 and 1)
  72775. * @param factor defines the life time factor to affect to the specified gradient
  72776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72777. * @returns the current particle system
  72778. */
  72779. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72780. /**
  72781. * Remove a specific life time gradient
  72782. * @param gradient defines the gradient to remove
  72783. * @returns the current particle system
  72784. */
  72785. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72786. /**
  72787. * Gets the current list of life time gradients.
  72788. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72789. * @returns the list of life time gradients
  72790. */
  72791. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72792. /**
  72793. * Gets the current list of color gradients.
  72794. * You must use addColorGradient and removeColorGradient to udpate this list
  72795. * @returns the list of color gradients
  72796. */
  72797. getColorGradients(): Nullable<Array<ColorGradient>>;
  72798. /**
  72799. * Adds a new ramp gradient used to remap particle colors
  72800. * @param gradient defines the gradient to use (between 0 and 1)
  72801. * @param color defines the color to affect to the specified gradient
  72802. * @returns the current particle system
  72803. */
  72804. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72805. /**
  72806. * Gets the current list of ramp gradients.
  72807. * You must use addRampGradient and removeRampGradient to udpate this list
  72808. * @returns the list of ramp gradients
  72809. */
  72810. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72811. /** Gets or sets a boolean indicating that ramp gradients must be used
  72812. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72813. */
  72814. useRampGradients: boolean;
  72815. /**
  72816. * Adds a new color remap gradient
  72817. * @param gradient defines the gradient to use (between 0 and 1)
  72818. * @param min defines the color remap minimal range
  72819. * @param max defines the color remap maximal range
  72820. * @returns the current particle system
  72821. */
  72822. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72823. /**
  72824. * Gets the current list of color remap gradients.
  72825. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72826. * @returns the list of color remap gradients
  72827. */
  72828. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72829. /**
  72830. * Adds a new alpha remap gradient
  72831. * @param gradient defines the gradient to use (between 0 and 1)
  72832. * @param min defines the alpha remap minimal range
  72833. * @param max defines the alpha remap maximal range
  72834. * @returns the current particle system
  72835. */
  72836. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72837. /**
  72838. * Gets the current list of alpha remap gradients.
  72839. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72840. * @returns the list of alpha remap gradients
  72841. */
  72842. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72843. /**
  72844. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72847. * @returns the emitter
  72848. */
  72849. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72850. /**
  72851. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72852. * @param radius The radius of the hemisphere to emit from
  72853. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72854. * @returns the emitter
  72855. */
  72856. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  72857. /**
  72858. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72859. * @param radius The radius of the sphere to emit from
  72860. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72861. * @returns the emitter
  72862. */
  72863. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  72864. /**
  72865. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72866. * @param radius The radius of the sphere to emit from
  72867. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72868. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72869. * @returns the emitter
  72870. */
  72871. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72872. /**
  72873. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72874. * @param radius The radius of the emission cylinder
  72875. * @param height The height of the emission cylinder
  72876. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72877. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72878. * @returns the emitter
  72879. */
  72880. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  72881. /**
  72882. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72883. * @param radius The radius of the cylinder to emit from
  72884. * @param height The height of the emission cylinder
  72885. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72886. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72887. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72888. * @returns the emitter
  72889. */
  72890. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72891. /**
  72892. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72893. * @param radius The radius of the cone to emit from
  72894. * @param angle The base angle of the cone
  72895. * @returns the emitter
  72896. */
  72897. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  72898. /**
  72899. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72902. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72903. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72904. * @returns the emitter
  72905. */
  72906. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72907. /**
  72908. * Get hosting scene
  72909. * @returns the scene
  72910. */
  72911. getScene(): Scene;
  72912. }
  72913. }
  72914. declare module BABYLON {
  72915. /**
  72916. * Creates an instance based on a source mesh.
  72917. */
  72918. export class InstancedMesh extends AbstractMesh {
  72919. private _sourceMesh;
  72920. private _currentLOD;
  72921. /** @hidden */
  72922. _indexInSourceMeshInstanceArray: number;
  72923. constructor(name: string, source: Mesh);
  72924. /**
  72925. * Returns the string "InstancedMesh".
  72926. */
  72927. getClassName(): string;
  72928. /**
  72929. * If the source mesh receives shadows
  72930. */
  72931. readonly receiveShadows: boolean;
  72932. /**
  72933. * The material of the source mesh
  72934. */
  72935. readonly material: Nullable<Material>;
  72936. /**
  72937. * Visibility of the source mesh
  72938. */
  72939. readonly visibility: number;
  72940. /**
  72941. * Skeleton of the source mesh
  72942. */
  72943. readonly skeleton: Nullable<Skeleton>;
  72944. /**
  72945. * Rendering ground id of the source mesh
  72946. */
  72947. renderingGroupId: number;
  72948. /**
  72949. * Returns the total number of vertices (integer).
  72950. */
  72951. getTotalVertices(): number;
  72952. /**
  72953. * Returns a positive integer : the total number of indices in this mesh geometry.
  72954. * @returns the numner of indices or zero if the mesh has no geometry.
  72955. */
  72956. getTotalIndices(): number;
  72957. /**
  72958. * The source mesh of the instance
  72959. */
  72960. readonly sourceMesh: Mesh;
  72961. /**
  72962. * Is this node ready to be used/rendered
  72963. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  72964. * @return {boolean} is it ready
  72965. */
  72966. isReady(completeCheck?: boolean): boolean;
  72967. /**
  72968. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  72969. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  72970. * @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.
  72971. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  72972. */
  72973. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  72974. /**
  72975. * Sets the vertex data of the mesh geometry for the requested `kind`.
  72976. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  72977. * The `data` are either a numeric array either a Float32Array.
  72978. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  72979. * 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).
  72980. * Note that a new underlying VertexBuffer object is created each call.
  72981. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  72982. *
  72983. * Possible `kind` values :
  72984. * - VertexBuffer.PositionKind
  72985. * - VertexBuffer.UVKind
  72986. * - VertexBuffer.UV2Kind
  72987. * - VertexBuffer.UV3Kind
  72988. * - VertexBuffer.UV4Kind
  72989. * - VertexBuffer.UV5Kind
  72990. * - VertexBuffer.UV6Kind
  72991. * - VertexBuffer.ColorKind
  72992. * - VertexBuffer.MatricesIndicesKind
  72993. * - VertexBuffer.MatricesIndicesExtraKind
  72994. * - VertexBuffer.MatricesWeightsKind
  72995. * - VertexBuffer.MatricesWeightsExtraKind
  72996. *
  72997. * Returns the Mesh.
  72998. */
  72999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73000. /**
  73001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73002. * If the mesh has no geometry, it is simply returned as it is.
  73003. * The `data` are either a numeric array either a Float32Array.
  73004. * No new underlying VertexBuffer object is created.
  73005. * 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.
  73006. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73007. *
  73008. * Possible `kind` values :
  73009. * - VertexBuffer.PositionKind
  73010. * - VertexBuffer.UVKind
  73011. * - VertexBuffer.UV2Kind
  73012. * - VertexBuffer.UV3Kind
  73013. * - VertexBuffer.UV4Kind
  73014. * - VertexBuffer.UV5Kind
  73015. * - VertexBuffer.UV6Kind
  73016. * - VertexBuffer.ColorKind
  73017. * - VertexBuffer.MatricesIndicesKind
  73018. * - VertexBuffer.MatricesIndicesExtraKind
  73019. * - VertexBuffer.MatricesWeightsKind
  73020. * - VertexBuffer.MatricesWeightsExtraKind
  73021. *
  73022. * Returns the Mesh.
  73023. */
  73024. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73025. /**
  73026. * Sets the mesh indices.
  73027. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73028. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73029. * This method creates a new index buffer each call.
  73030. * Returns the Mesh.
  73031. */
  73032. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73033. /**
  73034. * Boolean : True if the mesh owns the requested kind of data.
  73035. */
  73036. isVerticesDataPresent(kind: string): boolean;
  73037. /**
  73038. * Returns an array of indices (IndicesArray).
  73039. */
  73040. getIndices(): Nullable<IndicesArray>;
  73041. readonly _positions: Nullable<Vector3[]>;
  73042. /**
  73043. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73044. * This means the mesh underlying bounding box and sphere are recomputed.
  73045. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73046. * @returns the current mesh
  73047. */
  73048. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73049. /** @hidden */
  73050. _preActivate(): InstancedMesh;
  73051. /** @hidden */
  73052. _activate(renderId: number): InstancedMesh;
  73053. /**
  73054. * Returns the current associated LOD AbstractMesh.
  73055. */
  73056. getLOD(camera: Camera): AbstractMesh;
  73057. /** @hidden */
  73058. _syncSubMeshes(): InstancedMesh;
  73059. /** @hidden */
  73060. _generatePointsArray(): boolean;
  73061. /**
  73062. * Creates a new InstancedMesh from the current mesh.
  73063. * - name (string) : the cloned mesh name
  73064. * - newParent (optional Node) : the optional Node to parent the clone to.
  73065. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73066. *
  73067. * Returns the clone.
  73068. */
  73069. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73070. /**
  73071. * Disposes the InstancedMesh.
  73072. * Returns nothing.
  73073. */
  73074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73075. }
  73076. }
  73077. declare module BABYLON {
  73078. /**
  73079. * Defines the options associated with the creation of a shader material.
  73080. */
  73081. export interface IShaderMaterialOptions {
  73082. /**
  73083. * Does the material work in alpha blend mode
  73084. */
  73085. needAlphaBlending: boolean;
  73086. /**
  73087. * Does the material work in alpha test mode
  73088. */
  73089. needAlphaTesting: boolean;
  73090. /**
  73091. * The list of attribute names used in the shader
  73092. */
  73093. attributes: string[];
  73094. /**
  73095. * The list of unifrom names used in the shader
  73096. */
  73097. uniforms: string[];
  73098. /**
  73099. * The list of UBO names used in the shader
  73100. */
  73101. uniformBuffers: string[];
  73102. /**
  73103. * The list of sampler names used in the shader
  73104. */
  73105. samplers: string[];
  73106. /**
  73107. * The list of defines used in the shader
  73108. */
  73109. defines: string[];
  73110. }
  73111. /**
  73112. * 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.
  73113. *
  73114. * This returned material effects how the mesh will look based on the code in the shaders.
  73115. *
  73116. * @see http://doc.babylonjs.com/how_to/shader_material
  73117. */
  73118. export class ShaderMaterial extends Material {
  73119. private _shaderPath;
  73120. private _options;
  73121. private _textures;
  73122. private _textureArrays;
  73123. private _floats;
  73124. private _ints;
  73125. private _floatsArrays;
  73126. private _colors3;
  73127. private _colors3Arrays;
  73128. private _colors4;
  73129. private _vectors2;
  73130. private _vectors3;
  73131. private _vectors4;
  73132. private _matrices;
  73133. private _matrices3x3;
  73134. private _matrices2x2;
  73135. private _vectors2Arrays;
  73136. private _vectors3Arrays;
  73137. private _cachedWorldViewMatrix;
  73138. private _renderId;
  73139. /**
  73140. * Instantiate a new shader material.
  73141. * 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.
  73142. * This returned material effects how the mesh will look based on the code in the shaders.
  73143. * @see http://doc.babylonjs.com/how_to/shader_material
  73144. * @param name Define the name of the material in the scene
  73145. * @param scene Define the scene the material belongs to
  73146. * @param shaderPath Defines the route to the shader code in one of three ways:
  73147. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73148. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73149. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73150. * @param options Define the options used to create the shader
  73151. */
  73152. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73153. /**
  73154. * Gets the current class name of the material e.g. "ShaderMaterial"
  73155. * Mainly use in serialization.
  73156. * @returns the class name
  73157. */
  73158. getClassName(): string;
  73159. /**
  73160. * Specifies if the material will require alpha blending
  73161. * @returns a boolean specifying if alpha blending is needed
  73162. */
  73163. needAlphaBlending(): boolean;
  73164. /**
  73165. * Specifies if this material should be rendered in alpha test mode
  73166. * @returns a boolean specifying if an alpha test is needed.
  73167. */
  73168. needAlphaTesting(): boolean;
  73169. private _checkUniform;
  73170. /**
  73171. * Set a texture in the shader.
  73172. * @param name Define the name of the uniform samplers as defined in the shader
  73173. * @param texture Define the texture to bind to this sampler
  73174. * @return the material itself allowing "fluent" like uniform updates
  73175. */
  73176. setTexture(name: string, texture: Texture): ShaderMaterial;
  73177. /**
  73178. * Set a texture array in the shader.
  73179. * @param name Define the name of the uniform sampler array as defined in the shader
  73180. * @param textures Define the list of textures to bind to this sampler
  73181. * @return the material itself allowing "fluent" like uniform updates
  73182. */
  73183. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73184. /**
  73185. * Set a float in the shader.
  73186. * @param name Define the name of the uniform as defined in the shader
  73187. * @param value Define the value to give to the uniform
  73188. * @return the material itself allowing "fluent" like uniform updates
  73189. */
  73190. setFloat(name: string, value: number): ShaderMaterial;
  73191. /**
  73192. * Set a int in the shader.
  73193. * @param name Define the name of the uniform as defined in the shader
  73194. * @param value Define the value to give to the uniform
  73195. * @return the material itself allowing "fluent" like uniform updates
  73196. */
  73197. setInt(name: string, value: number): ShaderMaterial;
  73198. /**
  73199. * Set an array of floats in the shader.
  73200. * @param name Define the name of the uniform as defined in the shader
  73201. * @param value Define the value to give to the uniform
  73202. * @return the material itself allowing "fluent" like uniform updates
  73203. */
  73204. setFloats(name: string, value: number[]): ShaderMaterial;
  73205. /**
  73206. * Set a vec3 in the shader from a Color3.
  73207. * @param name Define the name of the uniform as defined in the shader
  73208. * @param value Define the value to give to the uniform
  73209. * @return the material itself allowing "fluent" like uniform updates
  73210. */
  73211. setColor3(name: string, value: Color3): ShaderMaterial;
  73212. /**
  73213. * Set a vec3 array in the shader from a Color3 array.
  73214. * @param name Define the name of the uniform as defined in the shader
  73215. * @param value Define the value to give to the uniform
  73216. * @return the material itself allowing "fluent" like uniform updates
  73217. */
  73218. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73219. /**
  73220. * Set a vec4 in the shader from a Color4.
  73221. * @param name Define the name of the uniform as defined in the shader
  73222. * @param value Define the value to give to the uniform
  73223. * @return the material itself allowing "fluent" like uniform updates
  73224. */
  73225. setColor4(name: string, value: Color4): ShaderMaterial;
  73226. /**
  73227. * Set a vec2 in the shader from a Vector2.
  73228. * @param name Define the name of the uniform as defined in the shader
  73229. * @param value Define the value to give to the uniform
  73230. * @return the material itself allowing "fluent" like uniform updates
  73231. */
  73232. setVector2(name: string, value: Vector2): ShaderMaterial;
  73233. /**
  73234. * Set a vec3 in the shader from a Vector3.
  73235. * @param name Define the name of the uniform as defined in the shader
  73236. * @param value Define the value to give to the uniform
  73237. * @return the material itself allowing "fluent" like uniform updates
  73238. */
  73239. setVector3(name: string, value: Vector3): ShaderMaterial;
  73240. /**
  73241. * Set a vec4 in the shader from a Vector4.
  73242. * @param name Define the name of the uniform as defined in the shader
  73243. * @param value Define the value to give to the uniform
  73244. * @return the material itself allowing "fluent" like uniform updates
  73245. */
  73246. setVector4(name: string, value: Vector4): ShaderMaterial;
  73247. /**
  73248. * Set a mat4 in the shader from a Matrix.
  73249. * @param name Define the name of the uniform as defined in the shader
  73250. * @param value Define the value to give to the uniform
  73251. * @return the material itself allowing "fluent" like uniform updates
  73252. */
  73253. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73254. /**
  73255. * Set a mat3 in the shader from a Float32Array.
  73256. * @param name Define the name of the uniform as defined in the shader
  73257. * @param value Define the value to give to the uniform
  73258. * @return the material itself allowing "fluent" like uniform updates
  73259. */
  73260. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73261. /**
  73262. * Set a mat2 in the shader from a Float32Array.
  73263. * @param name Define the name of the uniform as defined in the shader
  73264. * @param value Define the value to give to the uniform
  73265. * @return the material itself allowing "fluent" like uniform updates
  73266. */
  73267. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73268. /**
  73269. * Set a vec2 array in the shader from a number array.
  73270. * @param name Define the name of the uniform as defined in the shader
  73271. * @param value Define the value to give to the uniform
  73272. * @return the material itself allowing "fluent" like uniform updates
  73273. */
  73274. setArray2(name: string, value: number[]): ShaderMaterial;
  73275. /**
  73276. * Set a vec3 array in the shader from a number array.
  73277. * @param name Define the name of the uniform as defined in the shader
  73278. * @param value Define the value to give to the uniform
  73279. * @return the material itself allowing "fluent" like uniform updates
  73280. */
  73281. setArray3(name: string, value: number[]): ShaderMaterial;
  73282. private _checkCache;
  73283. /**
  73284. * Checks if the material is ready to render the requested mesh
  73285. * @param mesh Define the mesh to render
  73286. * @param useInstances Define whether or not the material is used with instances
  73287. * @returns true if ready, otherwise false
  73288. */
  73289. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73290. /**
  73291. * Binds the world matrix to the material
  73292. * @param world defines the world transformation matrix
  73293. */
  73294. bindOnlyWorldMatrix(world: Matrix): void;
  73295. /**
  73296. * Binds the material to the mesh
  73297. * @param world defines the world transformation matrix
  73298. * @param mesh defines the mesh to bind the material to
  73299. */
  73300. bind(world: Matrix, mesh?: Mesh): void;
  73301. /**
  73302. * Gets the active textures from the material
  73303. * @returns an array of textures
  73304. */
  73305. getActiveTextures(): BaseTexture[];
  73306. /**
  73307. * Specifies if the material uses a texture
  73308. * @param texture defines the texture to check against the material
  73309. * @returns a boolean specifying if the material uses the texture
  73310. */
  73311. hasTexture(texture: BaseTexture): boolean;
  73312. /**
  73313. * Makes a duplicate of the material, and gives it a new name
  73314. * @param name defines the new name for the duplicated material
  73315. * @returns the cloned material
  73316. */
  73317. clone(name: string): ShaderMaterial;
  73318. /**
  73319. * Disposes the material
  73320. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73321. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73322. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73323. */
  73324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73325. /**
  73326. * Serializes this material in a JSON representation
  73327. * @returns the serialized material object
  73328. */
  73329. serialize(): any;
  73330. /**
  73331. * Creates a shader material from parsed shader material data
  73332. * @param source defines the JSON represnetation of the material
  73333. * @param scene defines the hosting scene
  73334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73335. * @returns a new material
  73336. */
  73337. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73338. }
  73339. }
  73340. declare module BABYLON {
  73341. /** @hidden */
  73342. export var colorPixelShader: {
  73343. name: string;
  73344. shader: string;
  73345. };
  73346. }
  73347. declare module BABYLON {
  73348. /** @hidden */
  73349. export var colorVertexShader: {
  73350. name: string;
  73351. shader: string;
  73352. };
  73353. }
  73354. declare module BABYLON {
  73355. /**
  73356. * Line mesh
  73357. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  73358. */
  73359. export class LinesMesh extends Mesh {
  73360. /**
  73361. * If vertex color should be applied to the mesh
  73362. */
  73363. useVertexColor?: boolean | undefined;
  73364. /**
  73365. * If vertex alpha should be applied to the mesh
  73366. */
  73367. useVertexAlpha?: boolean | undefined;
  73368. /**
  73369. * Color of the line (Default: White)
  73370. */
  73371. color: Color3;
  73372. /**
  73373. * Alpha of the line (Default: 1)
  73374. */
  73375. alpha: number;
  73376. /**
  73377. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73378. * This margin is expressed in world space coordinates, so its value may vary.
  73379. * Default value is 0.1
  73380. */
  73381. intersectionThreshold: number;
  73382. private _colorShader;
  73383. /**
  73384. * Creates a new LinesMesh
  73385. * @param name defines the name
  73386. * @param scene defines the hosting scene
  73387. * @param parent defines the parent mesh if any
  73388. * @param source defines the optional source LinesMesh used to clone data from
  73389. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  73390. * When false, achieved by calling a clone(), also passing False.
  73391. * This will make creation of children, recursive.
  73392. * @param useVertexColor defines if this LinesMesh supports vertex color
  73393. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  73394. */
  73395. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  73396. /**
  73397. * If vertex color should be applied to the mesh
  73398. */
  73399. useVertexColor?: boolean | undefined,
  73400. /**
  73401. * If vertex alpha should be applied to the mesh
  73402. */
  73403. useVertexAlpha?: boolean | undefined);
  73404. /**
  73405. * Returns the string "LineMesh"
  73406. */
  73407. getClassName(): string;
  73408. /**
  73409. * @hidden
  73410. */
  73411. /**
  73412. * @hidden
  73413. */
  73414. material: Material;
  73415. /**
  73416. * @hidden
  73417. */
  73418. readonly checkCollisions: boolean;
  73419. /** @hidden */
  73420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  73421. /** @hidden */
  73422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  73423. /**
  73424. * Disposes of the line mesh
  73425. * @param doNotRecurse If children should be disposed
  73426. */
  73427. dispose(doNotRecurse?: boolean): void;
  73428. /**
  73429. * Returns a new LineMesh object cloned from the current one.
  73430. */
  73431. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  73432. /**
  73433. * Creates a new InstancedLinesMesh object from the mesh model.
  73434. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  73435. * @param name defines the name of the new instance
  73436. * @returns a new InstancedLinesMesh
  73437. */
  73438. createInstance(name: string): InstancedLinesMesh;
  73439. }
  73440. /**
  73441. * Creates an instance based on a source LinesMesh
  73442. */
  73443. export class InstancedLinesMesh extends InstancedMesh {
  73444. /**
  73445. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73446. * This margin is expressed in world space coordinates, so its value may vary.
  73447. * Initilized with the intersectionThreshold value of the source LinesMesh
  73448. */
  73449. intersectionThreshold: number;
  73450. constructor(name: string, source: LinesMesh);
  73451. /**
  73452. * Returns the string "InstancedLinesMesh".
  73453. */
  73454. getClassName(): string;
  73455. }
  73456. }
  73457. declare module BABYLON {
  73458. /** @hidden */
  73459. export var linePixelShader: {
  73460. name: string;
  73461. shader: string;
  73462. };
  73463. }
  73464. declare module BABYLON {
  73465. /** @hidden */
  73466. export var lineVertexShader: {
  73467. name: string;
  73468. shader: string;
  73469. };
  73470. }
  73471. declare module BABYLON {
  73472. interface AbstractMesh {
  73473. /**
  73474. * Disables the mesh edge rendering mode
  73475. * @returns the currentAbstractMesh
  73476. */
  73477. disableEdgesRendering(): AbstractMesh;
  73478. /**
  73479. * Enables the edge rendering mode on the mesh.
  73480. * This mode makes the mesh edges visible
  73481. * @param epsilon defines the maximal distance between two angles to detect a face
  73482. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73483. * @returns the currentAbstractMesh
  73484. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73485. */
  73486. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73487. /**
  73488. * Gets the edgesRenderer associated with the mesh
  73489. */
  73490. edgesRenderer: Nullable<EdgesRenderer>;
  73491. }
  73492. interface LinesMesh {
  73493. /**
  73494. * Enables the edge rendering mode on the mesh.
  73495. * This mode makes the mesh edges visible
  73496. * @param epsilon defines the maximal distance between two angles to detect a face
  73497. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73498. * @returns the currentAbstractMesh
  73499. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73500. */
  73501. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73502. }
  73503. interface InstancedLinesMesh {
  73504. /**
  73505. * Enables the edge rendering mode on the mesh.
  73506. * This mode makes the mesh edges visible
  73507. * @param epsilon defines the maximal distance between two angles to detect a face
  73508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73509. * @returns the current InstancedLinesMesh
  73510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73511. */
  73512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73513. }
  73514. /**
  73515. * Defines the minimum contract an Edges renderer should follow.
  73516. */
  73517. export interface IEdgesRenderer extends IDisposable {
  73518. /**
  73519. * Gets or sets a boolean indicating if the edgesRenderer is active
  73520. */
  73521. isEnabled: boolean;
  73522. /**
  73523. * Renders the edges of the attached mesh,
  73524. */
  73525. render(): void;
  73526. /**
  73527. * Checks wether or not the edges renderer is ready to render.
  73528. * @return true if ready, otherwise false.
  73529. */
  73530. isReady(): boolean;
  73531. }
  73532. /**
  73533. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73534. */
  73535. export class EdgesRenderer implements IEdgesRenderer {
  73536. /**
  73537. * Define the size of the edges with an orthographic camera
  73538. */
  73539. edgesWidthScalerForOrthographic: number;
  73540. /**
  73541. * Define the size of the edges with a perspective camera
  73542. */
  73543. edgesWidthScalerForPerspective: number;
  73544. protected _source: AbstractMesh;
  73545. protected _linesPositions: number[];
  73546. protected _linesNormals: number[];
  73547. protected _linesIndices: number[];
  73548. protected _epsilon: number;
  73549. protected _indicesCount: number;
  73550. protected _lineShader: ShaderMaterial;
  73551. protected _ib: WebGLBuffer;
  73552. protected _buffers: {
  73553. [key: string]: Nullable<VertexBuffer>;
  73554. };
  73555. protected _checkVerticesInsteadOfIndices: boolean;
  73556. private _meshRebuildObserver;
  73557. private _meshDisposeObserver;
  73558. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73559. isEnabled: boolean;
  73560. /**
  73561. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73562. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73563. * @param source Mesh used to create edges
  73564. * @param epsilon sum of angles in adjacency to check for edge
  73565. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73566. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73567. */
  73568. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73569. protected _prepareRessources(): void;
  73570. /** @hidden */
  73571. _rebuild(): void;
  73572. /**
  73573. * Releases the required resources for the edges renderer
  73574. */
  73575. dispose(): void;
  73576. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73577. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73578. /**
  73579. * Checks if the pair of p0 and p1 is en edge
  73580. * @param faceIndex
  73581. * @param edge
  73582. * @param faceNormals
  73583. * @param p0
  73584. * @param p1
  73585. * @private
  73586. */
  73587. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73588. /**
  73589. * push line into the position, normal and index buffer
  73590. * @protected
  73591. */
  73592. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73593. /**
  73594. * Generates lines edges from adjacencjes
  73595. * @private
  73596. */
  73597. _generateEdgesLines(): void;
  73598. /**
  73599. * Checks wether or not the edges renderer is ready to render.
  73600. * @return true if ready, otherwise false.
  73601. */
  73602. isReady(): boolean;
  73603. /**
  73604. * Renders the edges of the attached mesh,
  73605. */
  73606. render(): void;
  73607. }
  73608. /**
  73609. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73610. */
  73611. export class LineEdgesRenderer extends EdgesRenderer {
  73612. /**
  73613. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73614. * @param source LineMesh used to generate edges
  73615. * @param epsilon not important (specified angle for edge detection)
  73616. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73617. */
  73618. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73619. /**
  73620. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73621. */
  73622. _generateEdgesLines(): void;
  73623. }
  73624. }
  73625. declare module BABYLON {
  73626. /**
  73627. * This represents the object necessary to create a rendering group.
  73628. * This is exclusively used and created by the rendering manager.
  73629. * To modify the behavior, you use the available helpers in your scene or meshes.
  73630. * @hidden
  73631. */
  73632. export class RenderingGroup {
  73633. index: number;
  73634. private _scene;
  73635. private _opaqueSubMeshes;
  73636. private _transparentSubMeshes;
  73637. private _alphaTestSubMeshes;
  73638. private _depthOnlySubMeshes;
  73639. private _particleSystems;
  73640. private _spriteManagers;
  73641. private _opaqueSortCompareFn;
  73642. private _alphaTestSortCompareFn;
  73643. private _transparentSortCompareFn;
  73644. private _renderOpaque;
  73645. private _renderAlphaTest;
  73646. private _renderTransparent;
  73647. private _edgesRenderers;
  73648. onBeforeTransparentRendering: () => void;
  73649. /**
  73650. * Set the opaque sort comparison function.
  73651. * If null the sub meshes will be render in the order they were created
  73652. */
  73653. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73654. /**
  73655. * Set the alpha test sort comparison function.
  73656. * If null the sub meshes will be render in the order they were created
  73657. */
  73658. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73659. /**
  73660. * Set the transparent sort comparison function.
  73661. * If null the sub meshes will be render in the order they were created
  73662. */
  73663. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73664. /**
  73665. * Creates a new rendering group.
  73666. * @param index The rendering group index
  73667. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73668. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73669. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73670. */
  73671. 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>);
  73672. /**
  73673. * Render all the sub meshes contained in the group.
  73674. * @param customRenderFunction Used to override the default render behaviour of the group.
  73675. * @returns true if rendered some submeshes.
  73676. */
  73677. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73678. /**
  73679. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73680. * @param subMeshes The submeshes to render
  73681. */
  73682. private renderOpaqueSorted;
  73683. /**
  73684. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73685. * @param subMeshes The submeshes to render
  73686. */
  73687. private renderAlphaTestSorted;
  73688. /**
  73689. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73690. * @param subMeshes The submeshes to render
  73691. */
  73692. private renderTransparentSorted;
  73693. /**
  73694. * Renders the submeshes in a specified order.
  73695. * @param subMeshes The submeshes to sort before render
  73696. * @param sortCompareFn The comparison function use to sort
  73697. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73698. * @param transparent Specifies to activate blending if true
  73699. */
  73700. private static renderSorted;
  73701. /**
  73702. * Renders the submeshes in the order they were dispatched (no sort applied).
  73703. * @param subMeshes The submeshes to render
  73704. */
  73705. private static renderUnsorted;
  73706. /**
  73707. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73708. * are rendered back to front if in the same alpha index.
  73709. *
  73710. * @param a The first submesh
  73711. * @param b The second submesh
  73712. * @returns The result of the comparison
  73713. */
  73714. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73715. /**
  73716. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73717. * are rendered back to front.
  73718. *
  73719. * @param a The first submesh
  73720. * @param b The second submesh
  73721. * @returns The result of the comparison
  73722. */
  73723. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73724. /**
  73725. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73726. * are rendered front to back (prevent overdraw).
  73727. *
  73728. * @param a The first submesh
  73729. * @param b The second submesh
  73730. * @returns The result of the comparison
  73731. */
  73732. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73733. /**
  73734. * Resets the different lists of submeshes to prepare a new frame.
  73735. */
  73736. prepare(): void;
  73737. dispose(): void;
  73738. /**
  73739. * Inserts the submesh in its correct queue depending on its material.
  73740. * @param subMesh The submesh to dispatch
  73741. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73742. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73743. */
  73744. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73745. dispatchSprites(spriteManager: ISpriteManager): void;
  73746. dispatchParticles(particleSystem: IParticleSystem): void;
  73747. private _renderParticles;
  73748. private _renderSprites;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Interface describing the different options available in the rendering manager
  73754. * regarding Auto Clear between groups.
  73755. */
  73756. export interface IRenderingManagerAutoClearSetup {
  73757. /**
  73758. * Defines whether or not autoclear is enable.
  73759. */
  73760. autoClear: boolean;
  73761. /**
  73762. * Defines whether or not to autoclear the depth buffer.
  73763. */
  73764. depth: boolean;
  73765. /**
  73766. * Defines whether or not to autoclear the stencil buffer.
  73767. */
  73768. stencil: boolean;
  73769. }
  73770. /**
  73771. * This class is used by the onRenderingGroupObservable
  73772. */
  73773. export class RenderingGroupInfo {
  73774. /**
  73775. * The Scene that being rendered
  73776. */
  73777. scene: Scene;
  73778. /**
  73779. * The camera currently used for the rendering pass
  73780. */
  73781. camera: Nullable<Camera>;
  73782. /**
  73783. * The ID of the renderingGroup being processed
  73784. */
  73785. renderingGroupId: number;
  73786. }
  73787. /**
  73788. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73789. * It is enable to manage the different groups as well as the different necessary sort functions.
  73790. * This should not be used directly aside of the few static configurations
  73791. */
  73792. export class RenderingManager {
  73793. /**
  73794. * The max id used for rendering groups (not included)
  73795. */
  73796. static MAX_RENDERINGGROUPS: number;
  73797. /**
  73798. * The min id used for rendering groups (included)
  73799. */
  73800. static MIN_RENDERINGGROUPS: number;
  73801. /**
  73802. * Used to globally prevent autoclearing scenes.
  73803. */
  73804. static AUTOCLEAR: boolean;
  73805. /**
  73806. * @hidden
  73807. */
  73808. _useSceneAutoClearSetup: boolean;
  73809. private _scene;
  73810. private _renderingGroups;
  73811. private _depthStencilBufferAlreadyCleaned;
  73812. private _autoClearDepthStencil;
  73813. private _customOpaqueSortCompareFn;
  73814. private _customAlphaTestSortCompareFn;
  73815. private _customTransparentSortCompareFn;
  73816. private _renderingGroupInfo;
  73817. /**
  73818. * Instantiates a new rendering group for a particular scene
  73819. * @param scene Defines the scene the groups belongs to
  73820. */
  73821. constructor(scene: Scene);
  73822. private _clearDepthStencilBuffer;
  73823. /**
  73824. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73825. * @hidden
  73826. */
  73827. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73828. /**
  73829. * Resets the different information of the group to prepare a new frame
  73830. * @hidden
  73831. */
  73832. reset(): void;
  73833. /**
  73834. * Dispose and release the group and its associated resources.
  73835. * @hidden
  73836. */
  73837. dispose(): void;
  73838. /**
  73839. * Clear the info related to rendering groups preventing retention points during dispose.
  73840. */
  73841. freeRenderingGroups(): void;
  73842. private _prepareRenderingGroup;
  73843. /**
  73844. * Add a sprite manager to the rendering manager in order to render it this frame.
  73845. * @param spriteManager Define the sprite manager to render
  73846. */
  73847. dispatchSprites(spriteManager: ISpriteManager): void;
  73848. /**
  73849. * Add a particle system to the rendering manager in order to render it this frame.
  73850. * @param particleSystem Define the particle system to render
  73851. */
  73852. dispatchParticles(particleSystem: IParticleSystem): void;
  73853. /**
  73854. * Add a submesh to the manager in order to render it this frame
  73855. * @param subMesh The submesh to dispatch
  73856. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73857. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73858. */
  73859. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73860. /**
  73861. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73862. * This allowed control for front to back rendering or reversly depending of the special needs.
  73863. *
  73864. * @param renderingGroupId The rendering group id corresponding to its index
  73865. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73866. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73867. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73868. */
  73869. 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;
  73870. /**
  73871. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73872. *
  73873. * @param renderingGroupId The rendering group id corresponding to its index
  73874. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73875. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73876. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73877. */
  73878. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73879. /**
  73880. * Gets the current auto clear configuration for one rendering group of the rendering
  73881. * manager.
  73882. * @param index the rendering group index to get the information for
  73883. * @returns The auto clear setup for the requested rendering group
  73884. */
  73885. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73886. }
  73887. }
  73888. declare module BABYLON {
  73889. /**
  73890. * This Helps creating a texture that will be created from a camera in your scene.
  73891. * It is basically a dynamic texture that could be used to create special effects for instance.
  73892. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73893. */
  73894. export class RenderTargetTexture extends Texture {
  73895. isCube: boolean;
  73896. /**
  73897. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73898. */
  73899. static readonly REFRESHRATE_RENDER_ONCE: number;
  73900. /**
  73901. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73902. */
  73903. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73904. /**
  73905. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73906. * the central point of your effect and can save a lot of performances.
  73907. */
  73908. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73909. /**
  73910. * Use this predicate to dynamically define the list of mesh you want to render.
  73911. * If set, the renderList property will be overwritten.
  73912. */
  73913. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73914. private _renderList;
  73915. /**
  73916. * Use this list to define the list of mesh you want to render.
  73917. */
  73918. renderList: Nullable<Array<AbstractMesh>>;
  73919. private _hookArray;
  73920. /**
  73921. * Define if particles should be rendered in your texture.
  73922. */
  73923. renderParticles: boolean;
  73924. /**
  73925. * Define if sprites should be rendered in your texture.
  73926. */
  73927. renderSprites: boolean;
  73928. /**
  73929. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73930. */
  73931. coordinatesMode: number;
  73932. /**
  73933. * Define the camera used to render the texture.
  73934. */
  73935. activeCamera: Nullable<Camera>;
  73936. /**
  73937. * Override the render function of the texture with your own one.
  73938. */
  73939. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73940. /**
  73941. * Define if camera post processes should be use while rendering the texture.
  73942. */
  73943. useCameraPostProcesses: boolean;
  73944. /**
  73945. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73946. */
  73947. ignoreCameraViewport: boolean;
  73948. private _postProcessManager;
  73949. private _postProcesses;
  73950. private _resizeObserver;
  73951. /**
  73952. * An event triggered when the texture is unbind.
  73953. */
  73954. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73955. /**
  73956. * An event triggered when the texture is unbind.
  73957. */
  73958. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73959. private _onAfterUnbindObserver;
  73960. /**
  73961. * Set a after unbind callback in the texture.
  73962. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73963. */
  73964. onAfterUnbind: () => void;
  73965. /**
  73966. * An event triggered before rendering the texture
  73967. */
  73968. onBeforeRenderObservable: Observable<number>;
  73969. private _onBeforeRenderObserver;
  73970. /**
  73971. * Set a before render callback in the texture.
  73972. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73973. */
  73974. onBeforeRender: (faceIndex: number) => void;
  73975. /**
  73976. * An event triggered after rendering the texture
  73977. */
  73978. onAfterRenderObservable: Observable<number>;
  73979. private _onAfterRenderObserver;
  73980. /**
  73981. * Set a after render callback in the texture.
  73982. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73983. */
  73984. onAfterRender: (faceIndex: number) => void;
  73985. /**
  73986. * An event triggered after the texture clear
  73987. */
  73988. onClearObservable: Observable<Engine>;
  73989. private _onClearObserver;
  73990. /**
  73991. * Set a clear callback in the texture.
  73992. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73993. */
  73994. onClear: (Engine: Engine) => void;
  73995. /**
  73996. * Define the clear color of the Render Target if it should be different from the scene.
  73997. */
  73998. clearColor: Color4;
  73999. protected _size: number | {
  74000. width: number;
  74001. height: number;
  74002. };
  74003. protected _initialSizeParameter: number | {
  74004. width: number;
  74005. height: number;
  74006. } | {
  74007. ratio: number;
  74008. };
  74009. protected _sizeRatio: Nullable<number>;
  74010. /** @hidden */
  74011. _generateMipMaps: boolean;
  74012. protected _renderingManager: RenderingManager;
  74013. /** @hidden */
  74014. _waitingRenderList: string[];
  74015. protected _doNotChangeAspectRatio: boolean;
  74016. protected _currentRefreshId: number;
  74017. protected _refreshRate: number;
  74018. protected _textureMatrix: Matrix;
  74019. protected _samples: number;
  74020. protected _renderTargetOptions: RenderTargetCreationOptions;
  74021. /**
  74022. * Gets render target creation options that were used.
  74023. */
  74024. readonly renderTargetOptions: RenderTargetCreationOptions;
  74025. protected _engine: Engine;
  74026. protected _onRatioRescale(): void;
  74027. /**
  74028. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74029. * It must define where the camera used to render the texture is set
  74030. */
  74031. boundingBoxPosition: Vector3;
  74032. private _boundingBoxSize;
  74033. /**
  74034. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74035. * When defined, the cubemap will switch to local mode
  74036. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74037. * @example https://www.babylonjs-playground.com/#RNASML
  74038. */
  74039. boundingBoxSize: Vector3;
  74040. /**
  74041. * In case the RTT has been created with a depth texture, get the associated
  74042. * depth texture.
  74043. * Otherwise, return null.
  74044. */
  74045. depthStencilTexture: Nullable<InternalTexture>;
  74046. /**
  74047. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74048. * or used a shadow, depth texture...
  74049. * @param name The friendly name of the texture
  74050. * @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)
  74051. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74052. * @param generateMipMaps True if mip maps need to be generated after render.
  74053. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74054. * @param type The type of the buffer in the RTT (int, half float, float...)
  74055. * @param isCube True if a cube texture needs to be created
  74056. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74057. * @param generateDepthBuffer True to generate a depth buffer
  74058. * @param generateStencilBuffer True to generate a stencil buffer
  74059. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74060. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74061. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74062. */
  74063. constructor(name: string, size: number | {
  74064. width: number;
  74065. height: number;
  74066. } | {
  74067. ratio: number;
  74068. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74069. /**
  74070. * Creates a depth stencil texture.
  74071. * This is only available in WebGL 2 or with the depth texture extension available.
  74072. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74073. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74074. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74075. */
  74076. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74077. private _processSizeParameter;
  74078. /**
  74079. * Define the number of samples to use in case of MSAA.
  74080. * It defaults to one meaning no MSAA has been enabled.
  74081. */
  74082. samples: number;
  74083. /**
  74084. * Resets the refresh counter of the texture and start bak from scratch.
  74085. * Could be useful to regenerate the texture if it is setup to render only once.
  74086. */
  74087. resetRefreshCounter(): void;
  74088. /**
  74089. * Define the refresh rate of the texture or the rendering frequency.
  74090. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74091. */
  74092. refreshRate: number;
  74093. /**
  74094. * Adds a post process to the render target rendering passes.
  74095. * @param postProcess define the post process to add
  74096. */
  74097. addPostProcess(postProcess: PostProcess): void;
  74098. /**
  74099. * Clear all the post processes attached to the render target
  74100. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74101. */
  74102. clearPostProcesses(dispose?: boolean): void;
  74103. /**
  74104. * Remove one of the post process from the list of attached post processes to the texture
  74105. * @param postProcess define the post process to remove from the list
  74106. */
  74107. removePostProcess(postProcess: PostProcess): void;
  74108. /** @hidden */
  74109. _shouldRender(): boolean;
  74110. /**
  74111. * Gets the actual render size of the texture.
  74112. * @returns the width of the render size
  74113. */
  74114. getRenderSize(): number;
  74115. /**
  74116. * Gets the actual render width of the texture.
  74117. * @returns the width of the render size
  74118. */
  74119. getRenderWidth(): number;
  74120. /**
  74121. * Gets the actual render height of the texture.
  74122. * @returns the height of the render size
  74123. */
  74124. getRenderHeight(): number;
  74125. /**
  74126. * Get if the texture can be rescaled or not.
  74127. */
  74128. readonly canRescale: boolean;
  74129. /**
  74130. * Resize the texture using a ratio.
  74131. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74132. */
  74133. scale(ratio: number): void;
  74134. /**
  74135. * Get the texture reflection matrix used to rotate/transform the reflection.
  74136. * @returns the reflection matrix
  74137. */
  74138. getReflectionTextureMatrix(): Matrix;
  74139. /**
  74140. * Resize the texture to a new desired size.
  74141. * Be carrefull as it will recreate all the data in the new texture.
  74142. * @param size Define the new size. It can be:
  74143. * - a number for squared texture,
  74144. * - an object containing { width: number, height: number }
  74145. * - or an object containing a ratio { ratio: number }
  74146. */
  74147. resize(size: number | {
  74148. width: number;
  74149. height: number;
  74150. } | {
  74151. ratio: number;
  74152. }): void;
  74153. /**
  74154. * Renders all the objects from the render list into the texture.
  74155. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74156. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74157. */
  74158. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74159. private _bestReflectionRenderTargetDimension;
  74160. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74161. private renderToTarget;
  74162. /**
  74163. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74164. * This allowed control for front to back rendering or reversly depending of the special needs.
  74165. *
  74166. * @param renderingGroupId The rendering group id corresponding to its index
  74167. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74168. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74169. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74170. */
  74171. 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;
  74172. /**
  74173. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74174. *
  74175. * @param renderingGroupId The rendering group id corresponding to its index
  74176. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74177. */
  74178. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74179. /**
  74180. * Clones the texture.
  74181. * @returns the cloned texture
  74182. */
  74183. clone(): RenderTargetTexture;
  74184. /**
  74185. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74186. * @returns The JSON representation of the texture
  74187. */
  74188. serialize(): any;
  74189. /**
  74190. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74191. */
  74192. disposeFramebufferObjects(): void;
  74193. /**
  74194. * Dispose the texture and release its associated resources.
  74195. */
  74196. dispose(): void;
  74197. /** @hidden */
  74198. _rebuild(): void;
  74199. /**
  74200. * Clear the info related to rendering groups preventing retention point in material dispose.
  74201. */
  74202. freeRenderingGroups(): void;
  74203. }
  74204. }
  74205. declare module BABYLON {
  74206. /**
  74207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74209. * You can then easily use it as a reflectionTexture on a flat surface.
  74210. * In case the surface is not a plane, please consider relying on reflection probes.
  74211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74212. */
  74213. export class MirrorTexture extends RenderTargetTexture {
  74214. private scene;
  74215. /**
  74216. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74217. * 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.
  74218. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74219. */
  74220. mirrorPlane: Plane;
  74221. /**
  74222. * Define the blur ratio used to blur the reflection if needed.
  74223. */
  74224. blurRatio: number;
  74225. /**
  74226. * Define the adaptive blur kernel used to blur the reflection if needed.
  74227. * This will autocompute the closest best match for the `blurKernel`
  74228. */
  74229. adaptiveBlurKernel: number;
  74230. /**
  74231. * Define the blur kernel used to blur the reflection if needed.
  74232. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74233. */
  74234. blurKernel: number;
  74235. /**
  74236. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74237. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74238. */
  74239. blurKernelX: number;
  74240. /**
  74241. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74242. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74243. */
  74244. blurKernelY: number;
  74245. private _autoComputeBlurKernel;
  74246. protected _onRatioRescale(): void;
  74247. private _updateGammaSpace;
  74248. private _imageProcessingConfigChangeObserver;
  74249. private _transformMatrix;
  74250. private _mirrorMatrix;
  74251. private _savedViewMatrix;
  74252. private _blurX;
  74253. private _blurY;
  74254. private _adaptiveBlurKernel;
  74255. private _blurKernelX;
  74256. private _blurKernelY;
  74257. private _blurRatio;
  74258. /**
  74259. * Instantiates a Mirror Texture.
  74260. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74261. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74262. * You can then easily use it as a reflectionTexture on a flat surface.
  74263. * In case the surface is not a plane, please consider relying on reflection probes.
  74264. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74265. * @param name
  74266. * @param size
  74267. * @param scene
  74268. * @param generateMipMaps
  74269. * @param type
  74270. * @param samplingMode
  74271. * @param generateDepthBuffer
  74272. */
  74273. constructor(name: string, size: number | {
  74274. width: number;
  74275. height: number;
  74276. } | {
  74277. ratio: number;
  74278. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74279. private _preparePostProcesses;
  74280. /**
  74281. * Clone the mirror texture.
  74282. * @returns the cloned texture
  74283. */
  74284. clone(): MirrorTexture;
  74285. /**
  74286. * Serialize the texture to a JSON representation you could use in Parse later on
  74287. * @returns the serialized JSON representation
  74288. */
  74289. serialize(): any;
  74290. /**
  74291. * Dispose the texture and release its associated resources.
  74292. */
  74293. dispose(): void;
  74294. }
  74295. }
  74296. declare module BABYLON {
  74297. /**
  74298. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74299. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74300. */
  74301. export class Texture extends BaseTexture {
  74302. /** @hidden */
  74303. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74304. /** @hidden */
  74305. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74306. /** @hidden */
  74307. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74308. /** nearest is mag = nearest and min = nearest and mip = linear */
  74309. static readonly NEAREST_SAMPLINGMODE: number;
  74310. /** nearest is mag = nearest and min = nearest and mip = linear */
  74311. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74312. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74313. static readonly BILINEAR_SAMPLINGMODE: number;
  74314. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74315. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74316. /** Trilinear is mag = linear and min = linear and mip = linear */
  74317. static readonly TRILINEAR_SAMPLINGMODE: number;
  74318. /** Trilinear is mag = linear and min = linear and mip = linear */
  74319. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74320. /** mag = nearest and min = nearest and mip = nearest */
  74321. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74322. /** mag = nearest and min = linear and mip = nearest */
  74323. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74324. /** mag = nearest and min = linear and mip = linear */
  74325. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74326. /** mag = nearest and min = linear and mip = none */
  74327. static readonly NEAREST_LINEAR: number;
  74328. /** mag = nearest and min = nearest and mip = none */
  74329. static readonly NEAREST_NEAREST: number;
  74330. /** mag = linear and min = nearest and mip = nearest */
  74331. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74332. /** mag = linear and min = nearest and mip = linear */
  74333. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74334. /** mag = linear and min = linear and mip = none */
  74335. static readonly LINEAR_LINEAR: number;
  74336. /** mag = linear and min = nearest and mip = none */
  74337. static readonly LINEAR_NEAREST: number;
  74338. /** Explicit coordinates mode */
  74339. static readonly EXPLICIT_MODE: number;
  74340. /** Spherical coordinates mode */
  74341. static readonly SPHERICAL_MODE: number;
  74342. /** Planar coordinates mode */
  74343. static readonly PLANAR_MODE: number;
  74344. /** Cubic coordinates mode */
  74345. static readonly CUBIC_MODE: number;
  74346. /** Projection coordinates mode */
  74347. static readonly PROJECTION_MODE: number;
  74348. /** Inverse Cubic coordinates mode */
  74349. static readonly SKYBOX_MODE: number;
  74350. /** Inverse Cubic coordinates mode */
  74351. static readonly INVCUBIC_MODE: number;
  74352. /** Equirectangular coordinates mode */
  74353. static readonly EQUIRECTANGULAR_MODE: number;
  74354. /** Equirectangular Fixed coordinates mode */
  74355. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74356. /** Equirectangular Fixed Mirrored coordinates mode */
  74357. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74358. /** Texture is not repeating outside of 0..1 UVs */
  74359. static readonly CLAMP_ADDRESSMODE: number;
  74360. /** Texture is repeating outside of 0..1 UVs */
  74361. static readonly WRAP_ADDRESSMODE: number;
  74362. /** Texture is repeating and mirrored */
  74363. static readonly MIRROR_ADDRESSMODE: number;
  74364. /**
  74365. * 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
  74366. */
  74367. static UseSerializedUrlIfAny: boolean;
  74368. /**
  74369. * Define the url of the texture.
  74370. */
  74371. url: Nullable<string>;
  74372. /**
  74373. * Define an offset on the texture to offset the u coordinates of the UVs
  74374. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74375. */
  74376. uOffset: number;
  74377. /**
  74378. * Define an offset on the texture to offset the v coordinates of the UVs
  74379. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74380. */
  74381. vOffset: number;
  74382. /**
  74383. * Define an offset on the texture to scale the u coordinates of the UVs
  74384. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74385. */
  74386. uScale: number;
  74387. /**
  74388. * Define an offset on the texture to scale the v coordinates of the UVs
  74389. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74390. */
  74391. vScale: number;
  74392. /**
  74393. * Define an offset on the texture to rotate around the u coordinates of the UVs
  74394. * @see http://doc.babylonjs.com/how_to/more_materials
  74395. */
  74396. uAng: number;
  74397. /**
  74398. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74399. * @see http://doc.babylonjs.com/how_to/more_materials
  74400. */
  74401. vAng: number;
  74402. /**
  74403. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74404. * @see http://doc.babylonjs.com/how_to/more_materials
  74405. */
  74406. wAng: number;
  74407. /**
  74408. * Defines the center of rotation (U)
  74409. */
  74410. uRotationCenter: number;
  74411. /**
  74412. * Defines the center of rotation (V)
  74413. */
  74414. vRotationCenter: number;
  74415. /**
  74416. * Defines the center of rotation (W)
  74417. */
  74418. wRotationCenter: number;
  74419. /**
  74420. * Are mip maps generated for this texture or not.
  74421. */
  74422. readonly noMipmap: boolean;
  74423. private _noMipmap;
  74424. /** @hidden */
  74425. _invertY: boolean;
  74426. private _rowGenerationMatrix;
  74427. private _cachedTextureMatrix;
  74428. private _projectionModeMatrix;
  74429. private _t0;
  74430. private _t1;
  74431. private _t2;
  74432. private _cachedUOffset;
  74433. private _cachedVOffset;
  74434. private _cachedUScale;
  74435. private _cachedVScale;
  74436. private _cachedUAng;
  74437. private _cachedVAng;
  74438. private _cachedWAng;
  74439. private _cachedProjectionMatrixId;
  74440. private _cachedCoordinatesMode;
  74441. /** @hidden */
  74442. protected _initialSamplingMode: number;
  74443. /** @hidden */
  74444. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74445. private _deleteBuffer;
  74446. protected _format: Nullable<number>;
  74447. private _delayedOnLoad;
  74448. private _delayedOnError;
  74449. /**
  74450. * Observable triggered once the texture has been loaded.
  74451. */
  74452. onLoadObservable: Observable<Texture>;
  74453. protected _isBlocking: boolean;
  74454. /**
  74455. * Is the texture preventing material to render while loading.
  74456. * If false, a default texture will be used instead of the loading one during the preparation step.
  74457. */
  74458. isBlocking: boolean;
  74459. /**
  74460. * Get the current sampling mode associated with the texture.
  74461. */
  74462. readonly samplingMode: number;
  74463. /**
  74464. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74465. */
  74466. readonly invertY: boolean;
  74467. /**
  74468. * Instantiates a new texture.
  74469. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74470. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74471. * @param url define the url of the picture to load as a texture
  74472. * @param scene define the scene the texture will belong to
  74473. * @param noMipmap define if the texture will require mip maps or not
  74474. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74475. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74476. * @param onLoad define a callback triggered when the texture has been loaded
  74477. * @param onError define a callback triggered when an error occurred during the loading session
  74478. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74479. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74480. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74481. */
  74482. 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);
  74483. /**
  74484. * Update the url (and optional buffer) of this texture if url was null during construction.
  74485. * @param url the url of the texture
  74486. * @param buffer the buffer of the texture (defaults to null)
  74487. * @param onLoad callback called when the texture is loaded (defaults to null)
  74488. */
  74489. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74490. /**
  74491. * Finish the loading sequence of a texture flagged as delayed load.
  74492. * @hidden
  74493. */
  74494. delayLoad(): void;
  74495. private _prepareRowForTextureGeneration;
  74496. /**
  74497. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74498. * @returns the transform matrix of the texture.
  74499. */
  74500. getTextureMatrix(): Matrix;
  74501. /**
  74502. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74503. * @returns The reflection texture transform
  74504. */
  74505. getReflectionTextureMatrix(): Matrix;
  74506. /**
  74507. * Clones the texture.
  74508. * @returns the cloned texture
  74509. */
  74510. clone(): Texture;
  74511. /**
  74512. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74513. * @returns The JSON representation of the texture
  74514. */
  74515. serialize(): any;
  74516. /**
  74517. * Get the current class name of the texture useful for serialization or dynamic coding.
  74518. * @returns "Texture"
  74519. */
  74520. getClassName(): string;
  74521. /**
  74522. * Dispose the texture and release its associated resources.
  74523. */
  74524. dispose(): void;
  74525. /**
  74526. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74527. * @param parsedTexture Define the JSON representation of the texture
  74528. * @param scene Define the scene the parsed texture should be instantiated in
  74529. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74530. * @returns The parsed texture if successful
  74531. */
  74532. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74533. /**
  74534. * Creates a texture from its base 64 representation.
  74535. * @param data Define the base64 payload without the data: prefix
  74536. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74537. * @param scene Define the scene the texture should belong to
  74538. * @param noMipmap Forces the texture to not create mip map information if true
  74539. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74540. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74541. * @param onLoad define a callback triggered when the texture has been loaded
  74542. * @param onError define a callback triggered when an error occurred during the loading session
  74543. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74544. * @returns the created texture
  74545. */
  74546. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74547. /**
  74548. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74549. * @param data Define the base64 payload without the data: prefix
  74550. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74551. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74552. * @param scene Define the scene the texture should belong to
  74553. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74554. * @param noMipmap Forces the texture to not create mip map information if true
  74555. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74556. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74557. * @param onLoad define a callback triggered when the texture has been loaded
  74558. * @param onError define a callback triggered when an error occurred during the loading session
  74559. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74560. * @returns the created texture
  74561. */
  74562. 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;
  74563. }
  74564. }
  74565. declare module BABYLON {
  74566. /**
  74567. * Raw texture can help creating a texture directly from an array of data.
  74568. * This can be super useful if you either get the data from an uncompressed source or
  74569. * if you wish to create your texture pixel by pixel.
  74570. */
  74571. export class RawTexture extends Texture {
  74572. /**
  74573. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74574. */
  74575. format: number;
  74576. private _engine;
  74577. /**
  74578. * Instantiates a new RawTexture.
  74579. * Raw texture can help creating a texture directly from an array of data.
  74580. * This can be super useful if you either get the data from an uncompressed source or
  74581. * if you wish to create your texture pixel by pixel.
  74582. * @param data define the array of data to use to create the texture
  74583. * @param width define the width of the texture
  74584. * @param height define the height of the texture
  74585. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74586. * @param scene define the scene the texture belongs to
  74587. * @param generateMipMaps define whether mip maps should be generated or not
  74588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74590. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74591. */
  74592. constructor(data: ArrayBufferView, width: number, height: number,
  74593. /**
  74594. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74595. */
  74596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  74597. /**
  74598. * Updates the texture underlying data.
  74599. * @param data Define the new data of the texture
  74600. */
  74601. update(data: ArrayBufferView): void;
  74602. /**
  74603. * Creates a luminance texture from some data.
  74604. * @param data Define the texture data
  74605. * @param width Define the width of the texture
  74606. * @param height Define the height of the texture
  74607. * @param scene Define the scene the texture belongs to
  74608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74611. * @returns the luminance texture
  74612. */
  74613. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74614. /**
  74615. * Creates a luminance alpha texture from some data.
  74616. * @param data Define the texture data
  74617. * @param width Define the width of the texture
  74618. * @param height Define the height of the texture
  74619. * @param scene Define the scene the texture belongs to
  74620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74623. * @returns the luminance alpha texture
  74624. */
  74625. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74626. /**
  74627. * Creates an alpha texture from some data.
  74628. * @param data Define the texture data
  74629. * @param width Define the width of the texture
  74630. * @param height Define the height of the texture
  74631. * @param scene Define the scene the texture belongs to
  74632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74635. * @returns the alpha texture
  74636. */
  74637. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74638. /**
  74639. * Creates a RGB texture from some data.
  74640. * @param data Define the texture data
  74641. * @param width Define the width of the texture
  74642. * @param height Define the height of the texture
  74643. * @param scene Define the scene the texture belongs to
  74644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74647. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74648. * @returns the RGB alpha texture
  74649. */
  74650. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74651. /**
  74652. * Creates a RGBA texture from some data.
  74653. * @param data Define the texture data
  74654. * @param width Define the width of the texture
  74655. * @param height Define the height of the texture
  74656. * @param scene Define the scene the texture belongs to
  74657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74660. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74661. * @returns the RGBA texture
  74662. */
  74663. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74664. /**
  74665. * Creates a R texture from some data.
  74666. * @param data Define the texture data
  74667. * @param width Define the width of the texture
  74668. * @param height Define the height of the texture
  74669. * @param scene Define the scene the texture belongs to
  74670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74674. * @returns the R texture
  74675. */
  74676. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74677. }
  74678. }
  74679. declare module BABYLON {
  74680. /**
  74681. * Defines a runtime animation
  74682. */
  74683. export class RuntimeAnimation {
  74684. private _events;
  74685. /**
  74686. * The current frame of the runtime animation
  74687. */
  74688. private _currentFrame;
  74689. /**
  74690. * The animation used by the runtime animation
  74691. */
  74692. private _animation;
  74693. /**
  74694. * The target of the runtime animation
  74695. */
  74696. private _target;
  74697. /**
  74698. * The initiating animatable
  74699. */
  74700. private _host;
  74701. /**
  74702. * The original value of the runtime animation
  74703. */
  74704. private _originalValue;
  74705. /**
  74706. * The original blend value of the runtime animation
  74707. */
  74708. private _originalBlendValue;
  74709. /**
  74710. * The offsets cache of the runtime animation
  74711. */
  74712. private _offsetsCache;
  74713. /**
  74714. * The high limits cache of the runtime animation
  74715. */
  74716. private _highLimitsCache;
  74717. /**
  74718. * Specifies if the runtime animation has been stopped
  74719. */
  74720. private _stopped;
  74721. /**
  74722. * The blending factor of the runtime animation
  74723. */
  74724. private _blendingFactor;
  74725. /**
  74726. * The BabylonJS scene
  74727. */
  74728. private _scene;
  74729. /**
  74730. * The current value of the runtime animation
  74731. */
  74732. private _currentValue;
  74733. /** @hidden */
  74734. _workValue: any;
  74735. /**
  74736. * The active target of the runtime animation
  74737. */
  74738. private _activeTarget;
  74739. /**
  74740. * The target path of the runtime animation
  74741. */
  74742. private _targetPath;
  74743. /**
  74744. * The weight of the runtime animation
  74745. */
  74746. private _weight;
  74747. /**
  74748. * The ratio offset of the runtime animation
  74749. */
  74750. private _ratioOffset;
  74751. /**
  74752. * The previous delay of the runtime animation
  74753. */
  74754. private _previousDelay;
  74755. /**
  74756. * The previous ratio of the runtime animation
  74757. */
  74758. private _previousRatio;
  74759. /**
  74760. * Gets the current frame of the runtime animation
  74761. */
  74762. readonly currentFrame: number;
  74763. /**
  74764. * Gets the weight of the runtime animation
  74765. */
  74766. readonly weight: number;
  74767. /**
  74768. * Gets the current value of the runtime animation
  74769. */
  74770. readonly currentValue: any;
  74771. /**
  74772. * Gets the target path of the runtime animation
  74773. */
  74774. readonly targetPath: string;
  74775. /**
  74776. * Gets the actual target of the runtime animation
  74777. */
  74778. readonly target: any;
  74779. /**
  74780. * Create a new RuntimeAnimation object
  74781. * @param target defines the target of the animation
  74782. * @param animation defines the source animation object
  74783. * @param scene defines the hosting scene
  74784. * @param host defines the initiating Animatable
  74785. */
  74786. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  74787. /**
  74788. * Gets the animation from the runtime animation
  74789. */
  74790. readonly animation: Animation;
  74791. /**
  74792. * Resets the runtime animation to the beginning
  74793. * @param restoreOriginal defines whether to restore the target property to the original value
  74794. */
  74795. reset(restoreOriginal?: boolean): void;
  74796. /**
  74797. * Specifies if the runtime animation is stopped
  74798. * @returns Boolean specifying if the runtime animation is stopped
  74799. */
  74800. isStopped(): boolean;
  74801. /**
  74802. * Disposes of the runtime animation
  74803. */
  74804. dispose(): void;
  74805. /**
  74806. * Interpolates the animation from the current frame
  74807. * @param currentFrame The frame to interpolate the animation to
  74808. * @param repeatCount The number of times that the animation should loop
  74809. * @param loopMode The type of looping mode to use
  74810. * @param offsetValue Animation offset value
  74811. * @param highLimitValue The high limit value
  74812. * @returns The interpolated value
  74813. */
  74814. private _interpolate;
  74815. /**
  74816. * Apply the interpolated value to the target
  74817. * @param currentValue defines the value computed by the animation
  74818. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  74819. */
  74820. setValue(currentValue: any, weight?: number): void;
  74821. private _setValue;
  74822. /**
  74823. * Gets the loop pmode of the runtime animation
  74824. * @returns Loop Mode
  74825. */
  74826. private _getCorrectLoopMode;
  74827. /**
  74828. * Move the current animation to a given frame
  74829. * @param frame defines the frame to move to
  74830. */
  74831. goToFrame(frame: number): void;
  74832. /**
  74833. * @hidden Internal use only
  74834. */
  74835. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  74836. /**
  74837. * Execute the current animation
  74838. * @param delay defines the delay to add to the current frame
  74839. * @param from defines the lower bound of the animation range
  74840. * @param to defines the upper bound of the animation range
  74841. * @param loop defines if the current animation must loop
  74842. * @param speedRatio defines the current speed ratio
  74843. * @param weight defines the weight of the animation (default is -1 so no weight)
  74844. * @param onLoop optional callback called when animation loops
  74845. * @returns a boolean indicating if the animation is running
  74846. */
  74847. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  74848. }
  74849. }
  74850. declare module BABYLON {
  74851. /**
  74852. * Class used to store an actual running animation
  74853. */
  74854. export class Animatable {
  74855. /** defines the target object */
  74856. target: any;
  74857. /** defines the starting frame number (default is 0) */
  74858. fromFrame: number;
  74859. /** defines the ending frame number (default is 100) */
  74860. toFrame: number;
  74861. /** defines if the animation must loop (default is false) */
  74862. loopAnimation: boolean;
  74863. /** defines a callback to call when animation ends if it is not looping */
  74864. onAnimationEnd?: (() => void) | null | undefined;
  74865. /** defines a callback to call when animation loops */
  74866. onAnimationLoop?: (() => void) | null | undefined;
  74867. private _localDelayOffset;
  74868. private _pausedDelay;
  74869. private _runtimeAnimations;
  74870. private _paused;
  74871. private _scene;
  74872. private _speedRatio;
  74873. private _weight;
  74874. private _syncRoot;
  74875. /**
  74876. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  74877. * This will only apply for non looping animation (default is true)
  74878. */
  74879. disposeOnEnd: boolean;
  74880. /**
  74881. * Gets a boolean indicating if the animation has started
  74882. */
  74883. animationStarted: boolean;
  74884. /**
  74885. * Observer raised when the animation ends
  74886. */
  74887. onAnimationEndObservable: Observable<Animatable>;
  74888. /**
  74889. * Observer raised when the animation loops
  74890. */
  74891. onAnimationLoopObservable: Observable<Animatable>;
  74892. /**
  74893. * Gets the root Animatable used to synchronize and normalize animations
  74894. */
  74895. readonly syncRoot: Animatable;
  74896. /**
  74897. * Gets the current frame of the first RuntimeAnimation
  74898. * Used to synchronize Animatables
  74899. */
  74900. readonly masterFrame: number;
  74901. /**
  74902. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  74903. */
  74904. weight: number;
  74905. /**
  74906. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  74907. */
  74908. speedRatio: number;
  74909. /**
  74910. * Creates a new Animatable
  74911. * @param scene defines the hosting scene
  74912. * @param target defines the target object
  74913. * @param fromFrame defines the starting frame number (default is 0)
  74914. * @param toFrame defines the ending frame number (default is 100)
  74915. * @param loopAnimation defines if the animation must loop (default is false)
  74916. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  74917. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  74918. * @param animations defines a group of animation to add to the new Animatable
  74919. * @param onAnimationLoop defines a callback to call when animation loops
  74920. */
  74921. constructor(scene: Scene,
  74922. /** defines the target object */
  74923. target: any,
  74924. /** defines the starting frame number (default is 0) */
  74925. fromFrame?: number,
  74926. /** defines the ending frame number (default is 100) */
  74927. toFrame?: number,
  74928. /** defines if the animation must loop (default is false) */
  74929. loopAnimation?: boolean, speedRatio?: number,
  74930. /** defines a callback to call when animation ends if it is not looping */
  74931. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  74932. /** defines a callback to call when animation loops */
  74933. onAnimationLoop?: (() => void) | null | undefined);
  74934. /**
  74935. * Synchronize and normalize current Animatable with a source Animatable
  74936. * This is useful when using animation weights and when animations are not of the same length
  74937. * @param root defines the root Animatable to synchronize with
  74938. * @returns the current Animatable
  74939. */
  74940. syncWith(root: Animatable): Animatable;
  74941. /**
  74942. * Gets the list of runtime animations
  74943. * @returns an array of RuntimeAnimation
  74944. */
  74945. getAnimations(): RuntimeAnimation[];
  74946. /**
  74947. * Adds more animations to the current animatable
  74948. * @param target defines the target of the animations
  74949. * @param animations defines the new animations to add
  74950. */
  74951. appendAnimations(target: any, animations: Animation[]): void;
  74952. /**
  74953. * Gets the source animation for a specific property
  74954. * @param property defines the propertyu to look for
  74955. * @returns null or the source animation for the given property
  74956. */
  74957. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  74958. /**
  74959. * Gets the runtime animation for a specific property
  74960. * @param property defines the propertyu to look for
  74961. * @returns null or the runtime animation for the given property
  74962. */
  74963. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  74964. /**
  74965. * Resets the animatable to its original state
  74966. */
  74967. reset(): void;
  74968. /**
  74969. * Allows the animatable to blend with current running animations
  74970. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  74971. * @param blendingSpeed defines the blending speed to use
  74972. */
  74973. enableBlending(blendingSpeed: number): void;
  74974. /**
  74975. * Disable animation blending
  74976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  74977. */
  74978. disableBlending(): void;
  74979. /**
  74980. * Jump directly to a given frame
  74981. * @param frame defines the frame to jump to
  74982. */
  74983. goToFrame(frame: number): void;
  74984. /**
  74985. * Pause the animation
  74986. */
  74987. pause(): void;
  74988. /**
  74989. * Restart the animation
  74990. */
  74991. restart(): void;
  74992. private _raiseOnAnimationEnd;
  74993. /**
  74994. * Stop and delete the current animation
  74995. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  74996. * @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)
  74997. */
  74998. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  74999. /**
  75000. * Wait asynchronously for the animation to end
  75001. * @returns a promise which will be fullfilled when the animation ends
  75002. */
  75003. waitAsync(): Promise<Animatable>;
  75004. /** @hidden */
  75005. _animate(delay: number): boolean;
  75006. }
  75007. interface Scene {
  75008. /** @hidden */
  75009. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75010. /** @hidden */
  75011. _processLateAnimationBindingsForMatrices(holder: {
  75012. totalWeight: number;
  75013. animations: RuntimeAnimation[];
  75014. originalValue: Matrix;
  75015. }): any;
  75016. /** @hidden */
  75017. _processLateAnimationBindingsForQuaternions(holder: {
  75018. totalWeight: number;
  75019. animations: RuntimeAnimation[];
  75020. originalValue: Quaternion;
  75021. }, refQuaternion: Quaternion): Quaternion;
  75022. /** @hidden */
  75023. _processLateAnimationBindings(): void;
  75024. /**
  75025. * Will start the animation sequence of a given target
  75026. * @param target defines the target
  75027. * @param from defines from which frame should animation start
  75028. * @param to defines until which frame should animation run.
  75029. * @param weight defines the weight to apply to the animation (1.0 by default)
  75030. * @param loop defines if the animation loops
  75031. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75032. * @param onAnimationEnd defines the function to be executed when the animation ends
  75033. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75034. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75035. * @param onAnimationLoop defines the callback to call when an animation loops
  75036. * @returns the animatable object created for this animation
  75037. */
  75038. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75039. /**
  75040. * Will start the animation sequence of a given target
  75041. * @param target defines the target
  75042. * @param from defines from which frame should animation start
  75043. * @param to defines until which frame should animation run.
  75044. * @param loop defines if the animation loops
  75045. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75046. * @param onAnimationEnd defines the function to be executed when the animation ends
  75047. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75048. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75049. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75050. * @param onAnimationLoop defines the callback to call when an animation loops
  75051. * @returns the animatable object created for this animation
  75052. */
  75053. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75054. /**
  75055. * Will start the animation sequence of a given target and its hierarchy
  75056. * @param target defines the target
  75057. * @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.
  75058. * @param from defines from which frame should animation start
  75059. * @param to defines until which frame should animation run.
  75060. * @param loop defines if the animation loops
  75061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75062. * @param onAnimationEnd defines the function to be executed when the animation ends
  75063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75065. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75066. * @param onAnimationLoop defines the callback to call when an animation loops
  75067. * @returns the list of created animatables
  75068. */
  75069. 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[];
  75070. /**
  75071. * Begin a new animation on a given node
  75072. * @param target defines the target where the animation will take place
  75073. * @param animations defines the list of animations to start
  75074. * @param from defines the initial value
  75075. * @param to defines the final value
  75076. * @param loop defines if you want animation to loop (off by default)
  75077. * @param speedRatio defines the speed ratio to apply to all animations
  75078. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75079. * @param onAnimationLoop defines the callback to call when an animation loops
  75080. * @returns the list of created animatables
  75081. */
  75082. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75083. /**
  75084. * Begin a new animation on a given node and its hierarchy
  75085. * @param target defines the root node where the animation will take place
  75086. * @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.
  75087. * @param animations defines the list of animations to start
  75088. * @param from defines the initial value
  75089. * @param to defines the final value
  75090. * @param loop defines if you want animation to loop (off by default)
  75091. * @param speedRatio defines the speed ratio to apply to all animations
  75092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75093. * @param onAnimationLoop defines the callback to call when an animation loops
  75094. * @returns the list of animatables created for all nodes
  75095. */
  75096. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75097. /**
  75098. * Gets the animatable associated with a specific target
  75099. * @param target defines the target of the animatable
  75100. * @returns the required animatable if found
  75101. */
  75102. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75103. /**
  75104. * Gets all animatables associated with a given target
  75105. * @param target defines the target to look animatables for
  75106. * @returns an array of Animatables
  75107. */
  75108. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75109. /**
  75110. * Will stop the animation of the given target
  75111. * @param target - the target
  75112. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75113. * @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)
  75114. */
  75115. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75116. /**
  75117. * Stops and removes all animations that have been applied to the scene
  75118. */
  75119. stopAllAnimations(): void;
  75120. }
  75121. interface Bone {
  75122. /**
  75123. * Copy an animation range from another bone
  75124. * @param source defines the source bone
  75125. * @param rangeName defines the range name to copy
  75126. * @param frameOffset defines the frame offset
  75127. * @param rescaleAsRequired defines if rescaling must be applied if required
  75128. * @param skelDimensionsRatio defines the scaling ratio
  75129. * @returns true if operation was successful
  75130. */
  75131. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75132. }
  75133. }
  75134. declare module BABYLON {
  75135. /**
  75136. * Class used to handle skinning animations
  75137. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75138. */
  75139. export class Skeleton implements IAnimatable {
  75140. /** defines the skeleton name */
  75141. name: string;
  75142. /** defines the skeleton Id */
  75143. id: string;
  75144. /**
  75145. * Defines the list of child bones
  75146. */
  75147. bones: Bone[];
  75148. /**
  75149. * Defines an estimate of the dimension of the skeleton at rest
  75150. */
  75151. dimensionsAtRest: Vector3;
  75152. /**
  75153. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75154. */
  75155. needInitialSkinMatrix: boolean;
  75156. /**
  75157. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75158. */
  75159. overrideMesh: Nullable<AbstractMesh>;
  75160. /**
  75161. * Gets the list of animations attached to this skeleton
  75162. */
  75163. animations: Array<Animation>;
  75164. private _scene;
  75165. private _isDirty;
  75166. private _transformMatrices;
  75167. private _transformMatrixTexture;
  75168. private _meshesWithPoseMatrix;
  75169. private _animatables;
  75170. private _identity;
  75171. private _synchronizedWithMesh;
  75172. private _ranges;
  75173. private _lastAbsoluteTransformsUpdateId;
  75174. private _canUseTextureForBones;
  75175. /** @hidden */
  75176. _numBonesWithLinkedTransformNode: number;
  75177. /**
  75178. * Specifies if the skeleton should be serialized
  75179. */
  75180. doNotSerialize: boolean;
  75181. /**
  75182. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75183. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75184. */
  75185. useTextureToStoreBoneMatrices: boolean;
  75186. private _animationPropertiesOverride;
  75187. /**
  75188. * Gets or sets the animation properties override
  75189. */
  75190. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75191. /**
  75192. * An observable triggered before computing the skeleton's matrices
  75193. */
  75194. onBeforeComputeObservable: Observable<Skeleton>;
  75195. /**
  75196. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75197. */
  75198. readonly isUsingTextureForMatrices: boolean;
  75199. /**
  75200. * Creates a new skeleton
  75201. * @param name defines the skeleton name
  75202. * @param id defines the skeleton Id
  75203. * @param scene defines the hosting scene
  75204. */
  75205. constructor(
  75206. /** defines the skeleton name */
  75207. name: string,
  75208. /** defines the skeleton Id */
  75209. id: string, scene: Scene);
  75210. /**
  75211. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75212. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75213. * @returns a Float32Array containing matrices data
  75214. */
  75215. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75216. /**
  75217. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75218. * @returns a raw texture containing the data
  75219. */
  75220. getTransformMatrixTexture(): Nullable<RawTexture>;
  75221. /**
  75222. * Gets the current hosting scene
  75223. * @returns a scene object
  75224. */
  75225. getScene(): Scene;
  75226. /**
  75227. * Gets a string representing the current skeleton data
  75228. * @param fullDetails defines a boolean indicating if we want a verbose version
  75229. * @returns a string representing the current skeleton data
  75230. */
  75231. toString(fullDetails?: boolean): string;
  75232. /**
  75233. * Get bone's index searching by name
  75234. * @param name defines bone's name to search for
  75235. * @return the indice of the bone. Returns -1 if not found
  75236. */
  75237. getBoneIndexByName(name: string): number;
  75238. /**
  75239. * Creater a new animation range
  75240. * @param name defines the name of the range
  75241. * @param from defines the start key
  75242. * @param to defines the end key
  75243. */
  75244. createAnimationRange(name: string, from: number, to: number): void;
  75245. /**
  75246. * Delete a specific animation range
  75247. * @param name defines the name of the range
  75248. * @param deleteFrames defines if frames must be removed as well
  75249. */
  75250. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75251. /**
  75252. * Gets a specific animation range
  75253. * @param name defines the name of the range to look for
  75254. * @returns the requested animation range or null if not found
  75255. */
  75256. getAnimationRange(name: string): Nullable<AnimationRange>;
  75257. /**
  75258. * Gets the list of all animation ranges defined on this skeleton
  75259. * @returns an array
  75260. */
  75261. getAnimationRanges(): Nullable<AnimationRange>[];
  75262. /**
  75263. * Copy animation range from a source skeleton.
  75264. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75265. * @param source defines the source skeleton
  75266. * @param name defines the name of the range to copy
  75267. * @param rescaleAsRequired defines if rescaling must be applied if required
  75268. * @returns true if operation was successful
  75269. */
  75270. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75271. /**
  75272. * Forces the skeleton to go to rest pose
  75273. */
  75274. returnToRest(): void;
  75275. private _getHighestAnimationFrame;
  75276. /**
  75277. * Begin a specific animation range
  75278. * @param name defines the name of the range to start
  75279. * @param loop defines if looping must be turned on (false by default)
  75280. * @param speedRatio defines the speed ratio to apply (1 by default)
  75281. * @param onAnimationEnd defines a callback which will be called when animation will end
  75282. * @returns a new animatable
  75283. */
  75284. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75285. /** @hidden */
  75286. _markAsDirty(): void;
  75287. /** @hidden */
  75288. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75289. /** @hidden */
  75290. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75291. private _computeTransformMatrices;
  75292. /**
  75293. * Build all resources required to render a skeleton
  75294. */
  75295. prepare(): void;
  75296. /**
  75297. * Gets the list of animatables currently running for this skeleton
  75298. * @returns an array of animatables
  75299. */
  75300. getAnimatables(): IAnimatable[];
  75301. /**
  75302. * Clone the current skeleton
  75303. * @param name defines the name of the new skeleton
  75304. * @param id defines the id of the enw skeleton
  75305. * @returns the new skeleton
  75306. */
  75307. clone(name: string, id: string): Skeleton;
  75308. /**
  75309. * Enable animation blending for this skeleton
  75310. * @param blendingSpeed defines the blending speed to apply
  75311. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75312. */
  75313. enableBlending(blendingSpeed?: number): void;
  75314. /**
  75315. * Releases all resources associated with the current skeleton
  75316. */
  75317. dispose(): void;
  75318. /**
  75319. * Serialize the skeleton in a JSON object
  75320. * @returns a JSON object
  75321. */
  75322. serialize(): any;
  75323. /**
  75324. * Creates a new skeleton from serialized data
  75325. * @param parsedSkeleton defines the serialized data
  75326. * @param scene defines the hosting scene
  75327. * @returns a new skeleton
  75328. */
  75329. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75330. /**
  75331. * Compute all node absolute transforms
  75332. * @param forceUpdate defines if computation must be done even if cache is up to date
  75333. */
  75334. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75335. /**
  75336. * Gets the root pose matrix
  75337. * @returns a matrix
  75338. */
  75339. getPoseMatrix(): Nullable<Matrix>;
  75340. /**
  75341. * Sorts bones per internal index
  75342. */
  75343. sortBones(): void;
  75344. private _sortBones;
  75345. }
  75346. }
  75347. declare module BABYLON {
  75348. /**
  75349. * Defines a target to use with MorphTargetManager
  75350. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75351. */
  75352. export class MorphTarget implements IAnimatable {
  75353. /** defines the name of the target */
  75354. name: string;
  75355. /**
  75356. * Gets or sets the list of animations
  75357. */
  75358. animations: Animation[];
  75359. private _scene;
  75360. private _positions;
  75361. private _normals;
  75362. private _tangents;
  75363. private _influence;
  75364. /**
  75365. * Observable raised when the influence changes
  75366. */
  75367. onInfluenceChanged: Observable<boolean>;
  75368. /** @hidden */
  75369. _onDataLayoutChanged: Observable<void>;
  75370. /**
  75371. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  75372. */
  75373. influence: number;
  75374. /**
  75375. * Gets or sets the id of the morph Target
  75376. */
  75377. id: string;
  75378. private _animationPropertiesOverride;
  75379. /**
  75380. * Gets or sets the animation properties override
  75381. */
  75382. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75383. /**
  75384. * Creates a new MorphTarget
  75385. * @param name defines the name of the target
  75386. * @param influence defines the influence to use
  75387. * @param scene defines the scene the morphtarget belongs to
  75388. */
  75389. constructor(
  75390. /** defines the name of the target */
  75391. name: string, influence?: number, scene?: Nullable<Scene>);
  75392. /**
  75393. * Gets a boolean defining if the target contains position data
  75394. */
  75395. readonly hasPositions: boolean;
  75396. /**
  75397. * Gets a boolean defining if the target contains normal data
  75398. */
  75399. readonly hasNormals: boolean;
  75400. /**
  75401. * Gets a boolean defining if the target contains tangent data
  75402. */
  75403. readonly hasTangents: boolean;
  75404. /**
  75405. * Affects position data to this target
  75406. * @param data defines the position data to use
  75407. */
  75408. setPositions(data: Nullable<FloatArray>): void;
  75409. /**
  75410. * Gets the position data stored in this target
  75411. * @returns a FloatArray containing the position data (or null if not present)
  75412. */
  75413. getPositions(): Nullable<FloatArray>;
  75414. /**
  75415. * Affects normal data to this target
  75416. * @param data defines the normal data to use
  75417. */
  75418. setNormals(data: Nullable<FloatArray>): void;
  75419. /**
  75420. * Gets the normal data stored in this target
  75421. * @returns a FloatArray containing the normal data (or null if not present)
  75422. */
  75423. getNormals(): Nullable<FloatArray>;
  75424. /**
  75425. * Affects tangent data to this target
  75426. * @param data defines the tangent data to use
  75427. */
  75428. setTangents(data: Nullable<FloatArray>): void;
  75429. /**
  75430. * Gets the tangent data stored in this target
  75431. * @returns a FloatArray containing the tangent data (or null if not present)
  75432. */
  75433. getTangents(): Nullable<FloatArray>;
  75434. /**
  75435. * Serializes the current target into a Serialization object
  75436. * @returns the serialized object
  75437. */
  75438. serialize(): any;
  75439. /**
  75440. * Returns the string "MorphTarget"
  75441. * @returns "MorphTarget"
  75442. */
  75443. getClassName(): string;
  75444. /**
  75445. * Creates a new target from serialized data
  75446. * @param serializationObject defines the serialized data to use
  75447. * @returns a new MorphTarget
  75448. */
  75449. static Parse(serializationObject: any): MorphTarget;
  75450. /**
  75451. * Creates a MorphTarget from mesh data
  75452. * @param mesh defines the source mesh
  75453. * @param name defines the name to use for the new target
  75454. * @param influence defines the influence to attach to the target
  75455. * @returns a new MorphTarget
  75456. */
  75457. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  75458. }
  75459. }
  75460. declare module BABYLON {
  75461. /**
  75462. * This class is used to deform meshes using morphing between different targets
  75463. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75464. */
  75465. export class MorphTargetManager {
  75466. private _targets;
  75467. private _targetInfluenceChangedObservers;
  75468. private _targetDataLayoutChangedObservers;
  75469. private _activeTargets;
  75470. private _scene;
  75471. private _influences;
  75472. private _supportsNormals;
  75473. private _supportsTangents;
  75474. private _vertexCount;
  75475. private _uniqueId;
  75476. private _tempInfluences;
  75477. /**
  75478. * Creates a new MorphTargetManager
  75479. * @param scene defines the current scene
  75480. */
  75481. constructor(scene?: Nullable<Scene>);
  75482. /**
  75483. * Gets the unique ID of this manager
  75484. */
  75485. readonly uniqueId: number;
  75486. /**
  75487. * Gets the number of vertices handled by this manager
  75488. */
  75489. readonly vertexCount: number;
  75490. /**
  75491. * Gets a boolean indicating if this manager supports morphing of normals
  75492. */
  75493. readonly supportsNormals: boolean;
  75494. /**
  75495. * Gets a boolean indicating if this manager supports morphing of tangents
  75496. */
  75497. readonly supportsTangents: boolean;
  75498. /**
  75499. * Gets the number of targets stored in this manager
  75500. */
  75501. readonly numTargets: number;
  75502. /**
  75503. * Gets the number of influencers (ie. the number of targets with influences > 0)
  75504. */
  75505. readonly numInfluencers: number;
  75506. /**
  75507. * Gets the list of influences (one per target)
  75508. */
  75509. readonly influences: Float32Array;
  75510. /**
  75511. * Gets the active target at specified index. An active target is a target with an influence > 0
  75512. * @param index defines the index to check
  75513. * @returns the requested target
  75514. */
  75515. getActiveTarget(index: number): MorphTarget;
  75516. /**
  75517. * Gets the target at specified index
  75518. * @param index defines the index to check
  75519. * @returns the requested target
  75520. */
  75521. getTarget(index: number): MorphTarget;
  75522. /**
  75523. * Add a new target to this manager
  75524. * @param target defines the target to add
  75525. */
  75526. addTarget(target: MorphTarget): void;
  75527. /**
  75528. * Removes a target from the manager
  75529. * @param target defines the target to remove
  75530. */
  75531. removeTarget(target: MorphTarget): void;
  75532. /**
  75533. * Serializes the current manager into a Serialization object
  75534. * @returns the serialized object
  75535. */
  75536. serialize(): any;
  75537. private _syncActiveTargets;
  75538. /**
  75539. * Syncrhonize the targets with all the meshes using this morph target manager
  75540. */
  75541. synchronize(): void;
  75542. /**
  75543. * Creates a new MorphTargetManager from serialized data
  75544. * @param serializationObject defines the serialized data
  75545. * @param scene defines the hosting scene
  75546. * @returns the new MorphTargetManager
  75547. */
  75548. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  75549. }
  75550. }
  75551. declare module BABYLON {
  75552. /**
  75553. * Mesh representing the gorund
  75554. */
  75555. export class GroundMesh extends Mesh {
  75556. /** If octree should be generated */
  75557. generateOctree: boolean;
  75558. private _heightQuads;
  75559. /** @hidden */
  75560. _subdivisionsX: number;
  75561. /** @hidden */
  75562. _subdivisionsY: number;
  75563. /** @hidden */
  75564. _width: number;
  75565. /** @hidden */
  75566. _height: number;
  75567. /** @hidden */
  75568. _minX: number;
  75569. /** @hidden */
  75570. _maxX: number;
  75571. /** @hidden */
  75572. _minZ: number;
  75573. /** @hidden */
  75574. _maxZ: number;
  75575. constructor(name: string, scene: Scene);
  75576. /**
  75577. * "GroundMesh"
  75578. * @returns "GroundMesh"
  75579. */
  75580. getClassName(): string;
  75581. /**
  75582. * The minimum of x and y subdivisions
  75583. */
  75584. readonly subdivisions: number;
  75585. /**
  75586. * X subdivisions
  75587. */
  75588. readonly subdivisionsX: number;
  75589. /**
  75590. * Y subdivisions
  75591. */
  75592. readonly subdivisionsY: number;
  75593. /**
  75594. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75595. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75596. * @param chunksCount the number of subdivisions for x and y
  75597. * @param octreeBlocksSize (Default: 32)
  75598. */
  75599. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75600. /**
  75601. * Returns a height (y) value in the Worl system :
  75602. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75603. * @param x x coordinate
  75604. * @param z z coordinate
  75605. * @returns the ground y position if (x, z) are outside the ground surface.
  75606. */
  75607. getHeightAtCoordinates(x: number, z: number): number;
  75608. /**
  75609. * Returns a normalized vector (Vector3) orthogonal to the ground
  75610. * at the ground coordinates (x, z) expressed in the World system.
  75611. * @param x x coordinate
  75612. * @param z z coordinate
  75613. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75614. */
  75615. getNormalAtCoordinates(x: number, z: number): Vector3;
  75616. /**
  75617. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75618. * at the ground coordinates (x, z) expressed in the World system.
  75619. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75620. * @param x x coordinate
  75621. * @param z z coordinate
  75622. * @param ref vector to store the result
  75623. * @returns the GroundMesh.
  75624. */
  75625. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75626. /**
  75627. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75628. * if the ground has been updated.
  75629. * This can be used in the render loop.
  75630. * @returns the GroundMesh.
  75631. */
  75632. updateCoordinateHeights(): GroundMesh;
  75633. private _getFacetAt;
  75634. private _initHeightQuads;
  75635. private _computeHeightQuads;
  75636. /**
  75637. * Serializes this ground mesh
  75638. * @param serializationObject object to write serialization to
  75639. */
  75640. serialize(serializationObject: any): void;
  75641. /**
  75642. * Parses a serialized ground mesh
  75643. * @param parsedMesh the serialized mesh
  75644. * @param scene the scene to create the ground mesh in
  75645. * @returns the created ground mesh
  75646. */
  75647. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75648. }
  75649. }
  75650. declare module BABYLON {
  75651. /**
  75652. * Interface for Physics-Joint data
  75653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75654. */
  75655. export interface PhysicsJointData {
  75656. /**
  75657. * The main pivot of the joint
  75658. */
  75659. mainPivot?: Vector3;
  75660. /**
  75661. * The connected pivot of the joint
  75662. */
  75663. connectedPivot?: Vector3;
  75664. /**
  75665. * The main axis of the joint
  75666. */
  75667. mainAxis?: Vector3;
  75668. /**
  75669. * The connected axis of the joint
  75670. */
  75671. connectedAxis?: Vector3;
  75672. /**
  75673. * The collision of the joint
  75674. */
  75675. collision?: boolean;
  75676. /**
  75677. * Native Oimo/Cannon/Energy data
  75678. */
  75679. nativeParams?: any;
  75680. }
  75681. /**
  75682. * This is a holder class for the physics joint created by the physics plugin
  75683. * It holds a set of functions to control the underlying joint
  75684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75685. */
  75686. export class PhysicsJoint {
  75687. /**
  75688. * The type of the physics joint
  75689. */
  75690. type: number;
  75691. /**
  75692. * The data for the physics joint
  75693. */
  75694. jointData: PhysicsJointData;
  75695. private _physicsJoint;
  75696. protected _physicsPlugin: IPhysicsEnginePlugin;
  75697. /**
  75698. * Initializes the physics joint
  75699. * @param type The type of the physics joint
  75700. * @param jointData The data for the physics joint
  75701. */
  75702. constructor(
  75703. /**
  75704. * The type of the physics joint
  75705. */
  75706. type: number,
  75707. /**
  75708. * The data for the physics joint
  75709. */
  75710. jointData: PhysicsJointData);
  75711. /**
  75712. * Gets the physics joint
  75713. */
  75714. /**
  75715. * Sets the physics joint
  75716. */
  75717. physicsJoint: any;
  75718. /**
  75719. * Sets the physics plugin
  75720. */
  75721. physicsPlugin: IPhysicsEnginePlugin;
  75722. /**
  75723. * Execute a function that is physics-plugin specific.
  75724. * @param {Function} func the function that will be executed.
  75725. * It accepts two parameters: the physics world and the physics joint
  75726. */
  75727. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75728. /**
  75729. * Distance-Joint type
  75730. */
  75731. static DistanceJoint: number;
  75732. /**
  75733. * Hinge-Joint type
  75734. */
  75735. static HingeJoint: number;
  75736. /**
  75737. * Ball-and-Socket joint type
  75738. */
  75739. static BallAndSocketJoint: number;
  75740. /**
  75741. * Wheel-Joint type
  75742. */
  75743. static WheelJoint: number;
  75744. /**
  75745. * Slider-Joint type
  75746. */
  75747. static SliderJoint: number;
  75748. /**
  75749. * Prismatic-Joint type
  75750. */
  75751. static PrismaticJoint: number;
  75752. /**
  75753. * Universal-Joint type
  75754. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75755. */
  75756. static UniversalJoint: number;
  75757. /**
  75758. * Hinge-Joint 2 type
  75759. */
  75760. static Hinge2Joint: number;
  75761. /**
  75762. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75763. */
  75764. static PointToPointJoint: number;
  75765. /**
  75766. * Spring-Joint type
  75767. */
  75768. static SpringJoint: number;
  75769. /**
  75770. * Lock-Joint type
  75771. */
  75772. static LockJoint: number;
  75773. }
  75774. /**
  75775. * A class representing a physics distance joint
  75776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75777. */
  75778. export class DistanceJoint extends PhysicsJoint {
  75779. /**
  75780. *
  75781. * @param jointData The data for the Distance-Joint
  75782. */
  75783. constructor(jointData: DistanceJointData);
  75784. /**
  75785. * Update the predefined distance.
  75786. * @param maxDistance The maximum preferred distance
  75787. * @param minDistance The minimum preferred distance
  75788. */
  75789. updateDistance(maxDistance: number, minDistance?: number): void;
  75790. }
  75791. /**
  75792. * Represents a Motor-Enabled Joint
  75793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75794. */
  75795. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75796. /**
  75797. * Initializes the Motor-Enabled Joint
  75798. * @param type The type of the joint
  75799. * @param jointData The physica joint data for the joint
  75800. */
  75801. constructor(type: number, jointData: PhysicsJointData);
  75802. /**
  75803. * Set the motor values.
  75804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75805. * @param force the force to apply
  75806. * @param maxForce max force for this motor.
  75807. */
  75808. setMotor(force?: number, maxForce?: number): void;
  75809. /**
  75810. * Set the motor's limits.
  75811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75812. * @param upperLimit The upper limit of the motor
  75813. * @param lowerLimit The lower limit of the motor
  75814. */
  75815. setLimit(upperLimit: number, lowerLimit?: number): void;
  75816. }
  75817. /**
  75818. * This class represents a single physics Hinge-Joint
  75819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75820. */
  75821. export class HingeJoint extends MotorEnabledJoint {
  75822. /**
  75823. * Initializes the Hinge-Joint
  75824. * @param jointData The joint data for the Hinge-Joint
  75825. */
  75826. constructor(jointData: PhysicsJointData);
  75827. /**
  75828. * Set the motor values.
  75829. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75830. * @param {number} force the force to apply
  75831. * @param {number} maxForce max force for this motor.
  75832. */
  75833. setMotor(force?: number, maxForce?: number): void;
  75834. /**
  75835. * Set the motor's limits.
  75836. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75837. * @param upperLimit The upper limit of the motor
  75838. * @param lowerLimit The lower limit of the motor
  75839. */
  75840. setLimit(upperLimit: number, lowerLimit?: number): void;
  75841. }
  75842. /**
  75843. * This class represents a dual hinge physics joint (same as wheel joint)
  75844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75845. */
  75846. export class Hinge2Joint extends MotorEnabledJoint {
  75847. /**
  75848. * Initializes the Hinge2-Joint
  75849. * @param jointData The joint data for the Hinge2-Joint
  75850. */
  75851. constructor(jointData: PhysicsJointData);
  75852. /**
  75853. * Set the motor values.
  75854. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75855. * @param {number} targetSpeed the speed the motor is to reach
  75856. * @param {number} maxForce max force for this motor.
  75857. * @param {motorIndex} the motor's index, 0 or 1.
  75858. */
  75859. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75860. /**
  75861. * Set the motor limits.
  75862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75863. * @param {number} upperLimit the upper limit
  75864. * @param {number} lowerLimit lower limit
  75865. * @param {motorIndex} the motor's index, 0 or 1.
  75866. */
  75867. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75868. }
  75869. /**
  75870. * Interface for a motor enabled joint
  75871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75872. */
  75873. export interface IMotorEnabledJoint {
  75874. /**
  75875. * Physics joint
  75876. */
  75877. physicsJoint: any;
  75878. /**
  75879. * Sets the motor of the motor-enabled joint
  75880. * @param force The force of the motor
  75881. * @param maxForce The maximum force of the motor
  75882. * @param motorIndex The index of the motor
  75883. */
  75884. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75885. /**
  75886. * Sets the limit of the motor
  75887. * @param upperLimit The upper limit of the motor
  75888. * @param lowerLimit The lower limit of the motor
  75889. * @param motorIndex The index of the motor
  75890. */
  75891. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75892. }
  75893. /**
  75894. * Joint data for a Distance-Joint
  75895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75896. */
  75897. export interface DistanceJointData extends PhysicsJointData {
  75898. /**
  75899. * Max distance the 2 joint objects can be apart
  75900. */
  75901. maxDistance: number;
  75902. }
  75903. /**
  75904. * Joint data from a spring joint
  75905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75906. */
  75907. export interface SpringJointData extends PhysicsJointData {
  75908. /**
  75909. * Length of the spring
  75910. */
  75911. length: number;
  75912. /**
  75913. * Stiffness of the spring
  75914. */
  75915. stiffness: number;
  75916. /**
  75917. * Damping of the spring
  75918. */
  75919. damping: number;
  75920. /** this callback will be called when applying the force to the impostors. */
  75921. forceApplicationCallback: () => void;
  75922. }
  75923. }
  75924. declare module BABYLON {
  75925. /**
  75926. * Interface used to describe a physics joint
  75927. */
  75928. export interface PhysicsImpostorJoint {
  75929. /** Defines the main impostor to which the joint is linked */
  75930. mainImpostor: PhysicsImpostor;
  75931. /** Defines the impostor that is connected to the main impostor using this joint */
  75932. connectedImpostor: PhysicsImpostor;
  75933. /** Defines the joint itself */
  75934. joint: PhysicsJoint;
  75935. }
  75936. /** @hidden */
  75937. export interface IPhysicsEnginePlugin {
  75938. world: any;
  75939. name: string;
  75940. setGravity(gravity: Vector3): void;
  75941. setTimeStep(timeStep: number): void;
  75942. getTimeStep(): number;
  75943. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75944. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75945. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75946. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75947. removePhysicsBody(impostor: PhysicsImpostor): void;
  75948. generateJoint(joint: PhysicsImpostorJoint): void;
  75949. removeJoint(joint: PhysicsImpostorJoint): void;
  75950. isSupported(): boolean;
  75951. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75952. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75953. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75954. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75955. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75956. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75958. getBodyMass(impostor: PhysicsImpostor): number;
  75959. getBodyFriction(impostor: PhysicsImpostor): number;
  75960. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75961. getBodyRestitution(impostor: PhysicsImpostor): number;
  75962. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75963. sleepBody(impostor: PhysicsImpostor): void;
  75964. wakeUpBody(impostor: PhysicsImpostor): void;
  75965. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75966. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75967. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75968. getRadius(impostor: PhysicsImpostor): number;
  75969. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75970. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75971. dispose(): void;
  75972. }
  75973. /**
  75974. * Interface used to define a physics engine
  75975. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75976. */
  75977. export interface IPhysicsEngine {
  75978. /**
  75979. * Gets the gravity vector used by the simulation
  75980. */
  75981. gravity: Vector3;
  75982. /**
  75983. * Sets the gravity vector used by the simulation
  75984. * @param gravity defines the gravity vector to use
  75985. */
  75986. setGravity(gravity: Vector3): void;
  75987. /**
  75988. * Set the time step of the physics engine.
  75989. * Default is 1/60.
  75990. * To slow it down, enter 1/600 for example.
  75991. * To speed it up, 1/30
  75992. * @param newTimeStep the new timestep to apply to this world.
  75993. */
  75994. setTimeStep(newTimeStep: number): void;
  75995. /**
  75996. * Get the time step of the physics engine.
  75997. * @returns the current time step
  75998. */
  75999. getTimeStep(): number;
  76000. /**
  76001. * Release all resources
  76002. */
  76003. dispose(): void;
  76004. /**
  76005. * Gets the name of the current physics plugin
  76006. * @returns the name of the plugin
  76007. */
  76008. getPhysicsPluginName(): string;
  76009. /**
  76010. * Adding a new impostor for the impostor tracking.
  76011. * This will be done by the impostor itself.
  76012. * @param impostor the impostor to add
  76013. */
  76014. addImpostor(impostor: PhysicsImpostor): void;
  76015. /**
  76016. * Remove an impostor from the engine.
  76017. * This impostor and its mesh will not longer be updated by the physics engine.
  76018. * @param impostor the impostor to remove
  76019. */
  76020. removeImpostor(impostor: PhysicsImpostor): void;
  76021. /**
  76022. * Add a joint to the physics engine
  76023. * @param mainImpostor defines the main impostor to which the joint is added.
  76024. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76025. * @param joint defines the joint that will connect both impostors.
  76026. */
  76027. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76028. /**
  76029. * Removes a joint from the simulation
  76030. * @param mainImpostor defines the impostor used with the joint
  76031. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76032. * @param joint defines the joint to remove
  76033. */
  76034. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76035. /**
  76036. * Gets the current plugin used to run the simulation
  76037. * @returns current plugin
  76038. */
  76039. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76040. /**
  76041. * Gets the list of physic impostors
  76042. * @returns an array of PhysicsImpostor
  76043. */
  76044. getImpostors(): Array<PhysicsImpostor>;
  76045. /**
  76046. * Gets the impostor for a physics enabled object
  76047. * @param object defines the object impersonated by the impostor
  76048. * @returns the PhysicsImpostor or null if not found
  76049. */
  76050. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76051. /**
  76052. * Gets the impostor for a physics body object
  76053. * @param body defines physics body used by the impostor
  76054. * @returns the PhysicsImpostor or null if not found
  76055. */
  76056. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76057. /**
  76058. * Called by the scene. No need to call it.
  76059. * @param delta defines the timespam between frames
  76060. */
  76061. _step(delta: number): void;
  76062. }
  76063. }
  76064. declare module BABYLON {
  76065. /**
  76066. * The interface for the physics imposter parameters
  76067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76068. */
  76069. export interface PhysicsImpostorParameters {
  76070. /**
  76071. * The mass of the physics imposter
  76072. */
  76073. mass: number;
  76074. /**
  76075. * The friction of the physics imposter
  76076. */
  76077. friction?: number;
  76078. /**
  76079. * The coefficient of restitution of the physics imposter
  76080. */
  76081. restitution?: number;
  76082. /**
  76083. * The native options of the physics imposter
  76084. */
  76085. nativeOptions?: any;
  76086. /**
  76087. * Specifies if the parent should be ignored
  76088. */
  76089. ignoreParent?: boolean;
  76090. /**
  76091. * Specifies if bi-directional transformations should be disabled
  76092. */
  76093. disableBidirectionalTransformation?: boolean;
  76094. }
  76095. /**
  76096. * Interface for a physics-enabled object
  76097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76098. */
  76099. export interface IPhysicsEnabledObject {
  76100. /**
  76101. * The position of the physics-enabled object
  76102. */
  76103. position: Vector3;
  76104. /**
  76105. * The rotation of the physics-enabled object
  76106. */
  76107. rotationQuaternion: Nullable<Quaternion>;
  76108. /**
  76109. * The scale of the physics-enabled object
  76110. */
  76111. scaling: Vector3;
  76112. /**
  76113. * The rotation of the physics-enabled object
  76114. */
  76115. rotation?: Vector3;
  76116. /**
  76117. * The parent of the physics-enabled object
  76118. */
  76119. parent?: any;
  76120. /**
  76121. * The bounding info of the physics-enabled object
  76122. * @returns The bounding info of the physics-enabled object
  76123. */
  76124. getBoundingInfo(): BoundingInfo;
  76125. /**
  76126. * Computes the world matrix
  76127. * @param force Specifies if the world matrix should be computed by force
  76128. * @returns A world matrix
  76129. */
  76130. computeWorldMatrix(force: boolean): Matrix;
  76131. /**
  76132. * Gets the world matrix
  76133. * @returns A world matrix
  76134. */
  76135. getWorldMatrix?(): Matrix;
  76136. /**
  76137. * Gets the child meshes
  76138. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76139. * @returns An array of abstract meshes
  76140. */
  76141. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76142. /**
  76143. * Gets the vertex data
  76144. * @param kind The type of vertex data
  76145. * @returns A nullable array of numbers, or a float32 array
  76146. */
  76147. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76148. /**
  76149. * Gets the indices from the mesh
  76150. * @returns A nullable array of index arrays
  76151. */
  76152. getIndices?(): Nullable<IndicesArray>;
  76153. /**
  76154. * Gets the scene from the mesh
  76155. * @returns the indices array or null
  76156. */
  76157. getScene?(): Scene;
  76158. /**
  76159. * Gets the absolute position from the mesh
  76160. * @returns the absolute position
  76161. */
  76162. getAbsolutePosition(): Vector3;
  76163. /**
  76164. * Gets the absolute pivot point from the mesh
  76165. * @returns the absolute pivot point
  76166. */
  76167. getAbsolutePivotPoint(): Vector3;
  76168. /**
  76169. * Rotates the mesh
  76170. * @param axis The axis of rotation
  76171. * @param amount The amount of rotation
  76172. * @param space The space of the rotation
  76173. * @returns The rotation transform node
  76174. */
  76175. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76176. /**
  76177. * Translates the mesh
  76178. * @param axis The axis of translation
  76179. * @param distance The distance of translation
  76180. * @param space The space of the translation
  76181. * @returns The transform node
  76182. */
  76183. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76184. /**
  76185. * Sets the absolute position of the mesh
  76186. * @param absolutePosition The absolute position of the mesh
  76187. * @returns The transform node
  76188. */
  76189. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76190. /**
  76191. * Gets the class name of the mesh
  76192. * @returns The class name
  76193. */
  76194. getClassName(): string;
  76195. }
  76196. /**
  76197. * Represents a physics imposter
  76198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76199. */
  76200. export class PhysicsImpostor {
  76201. /**
  76202. * The physics-enabled object used as the physics imposter
  76203. */
  76204. object: IPhysicsEnabledObject;
  76205. /**
  76206. * The type of the physics imposter
  76207. */
  76208. type: number;
  76209. private _options;
  76210. private _scene?;
  76211. /**
  76212. * The default object size of the imposter
  76213. */
  76214. static DEFAULT_OBJECT_SIZE: Vector3;
  76215. /**
  76216. * The identity quaternion of the imposter
  76217. */
  76218. static IDENTITY_QUATERNION: Quaternion;
  76219. /** @hidden */
  76220. _pluginData: any;
  76221. private _physicsEngine;
  76222. private _physicsBody;
  76223. private _bodyUpdateRequired;
  76224. private _onBeforePhysicsStepCallbacks;
  76225. private _onAfterPhysicsStepCallbacks;
  76226. /** @hidden */
  76227. _onPhysicsCollideCallbacks: Array<{
  76228. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76229. otherImpostors: Array<PhysicsImpostor>;
  76230. }>;
  76231. private _deltaPosition;
  76232. private _deltaRotation;
  76233. private _deltaRotationConjugated;
  76234. private _parent;
  76235. private _isDisposed;
  76236. private static _tmpVecs;
  76237. private static _tmpQuat;
  76238. /**
  76239. * Specifies if the physics imposter is disposed
  76240. */
  76241. readonly isDisposed: boolean;
  76242. /**
  76243. * Gets the mass of the physics imposter
  76244. */
  76245. mass: number;
  76246. /**
  76247. * Gets the coefficient of friction
  76248. */
  76249. /**
  76250. * Sets the coefficient of friction
  76251. */
  76252. friction: number;
  76253. /**
  76254. * Gets the coefficient of restitution
  76255. */
  76256. /**
  76257. * Sets the coefficient of restitution
  76258. */
  76259. restitution: number;
  76260. /**
  76261. * The unique id of the physics imposter
  76262. * set by the physics engine when adding this impostor to the array
  76263. */
  76264. uniqueId: number;
  76265. private _joints;
  76266. /**
  76267. * Initializes the physics imposter
  76268. * @param object The physics-enabled object used as the physics imposter
  76269. * @param type The type of the physics imposter
  76270. * @param _options The options for the physics imposter
  76271. * @param _scene The Babylon scene
  76272. */
  76273. constructor(
  76274. /**
  76275. * The physics-enabled object used as the physics imposter
  76276. */
  76277. object: IPhysicsEnabledObject,
  76278. /**
  76279. * The type of the physics imposter
  76280. */
  76281. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76282. /**
  76283. * This function will completly initialize this impostor.
  76284. * It will create a new body - but only if this mesh has no parent.
  76285. * If it has, this impostor will not be used other than to define the impostor
  76286. * of the child mesh.
  76287. * @hidden
  76288. */
  76289. _init(): void;
  76290. private _getPhysicsParent;
  76291. /**
  76292. * Should a new body be generated.
  76293. * @returns boolean specifying if body initialization is required
  76294. */
  76295. isBodyInitRequired(): boolean;
  76296. /**
  76297. * Sets the updated scaling
  76298. * @param updated Specifies if the scaling is updated
  76299. */
  76300. setScalingUpdated(): void;
  76301. /**
  76302. * Force a regeneration of this or the parent's impostor's body.
  76303. * Use under cautious - This will remove all joints already implemented.
  76304. */
  76305. forceUpdate(): void;
  76306. /**
  76307. * Gets the body that holds this impostor. Either its own, or its parent.
  76308. */
  76309. /**
  76310. * Set the physics body. Used mainly by the physics engine/plugin
  76311. */
  76312. physicsBody: any;
  76313. /**
  76314. * Get the parent of the physics imposter
  76315. * @returns Physics imposter or null
  76316. */
  76317. /**
  76318. * Sets the parent of the physics imposter
  76319. */
  76320. parent: Nullable<PhysicsImpostor>;
  76321. /**
  76322. * Resets the update flags
  76323. */
  76324. resetUpdateFlags(): void;
  76325. /**
  76326. * Gets the object extend size
  76327. * @returns the object extend size
  76328. */
  76329. getObjectExtendSize(): Vector3;
  76330. /**
  76331. * Gets the object center
  76332. * @returns The object center
  76333. */
  76334. getObjectCenter(): Vector3;
  76335. /**
  76336. * Get a specific parametes from the options parameter
  76337. * @param paramName The object parameter name
  76338. * @returns The object parameter
  76339. */
  76340. getParam(paramName: string): any;
  76341. /**
  76342. * Sets a specific parameter in the options given to the physics plugin
  76343. * @param paramName The parameter name
  76344. * @param value The value of the parameter
  76345. */
  76346. setParam(paramName: string, value: number): void;
  76347. /**
  76348. * Specifically change the body's mass option. Won't recreate the physics body object
  76349. * @param mass The mass of the physics imposter
  76350. */
  76351. setMass(mass: number): void;
  76352. /**
  76353. * Gets the linear velocity
  76354. * @returns linear velocity or null
  76355. */
  76356. getLinearVelocity(): Nullable<Vector3>;
  76357. /**
  76358. * Sets the linear velocity
  76359. * @param velocity linear velocity or null
  76360. */
  76361. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76362. /**
  76363. * Gets the angular velocity
  76364. * @returns angular velocity or null
  76365. */
  76366. getAngularVelocity(): Nullable<Vector3>;
  76367. /**
  76368. * Sets the angular velocity
  76369. * @param velocity The velocity or null
  76370. */
  76371. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76372. /**
  76373. * Execute a function with the physics plugin native code
  76374. * Provide a function the will have two variables - the world object and the physics body object
  76375. * @param func The function to execute with the physics plugin native code
  76376. */
  76377. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76378. /**
  76379. * Register a function that will be executed before the physics world is stepping forward
  76380. * @param func The function to execute before the physics world is stepped forward
  76381. */
  76382. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76383. /**
  76384. * Unregister a function that will be executed before the physics world is stepping forward
  76385. * @param func The function to execute before the physics world is stepped forward
  76386. */
  76387. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76388. /**
  76389. * Register a function that will be executed after the physics step
  76390. * @param func The function to execute after physics step
  76391. */
  76392. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76393. /**
  76394. * Unregisters a function that will be executed after the physics step
  76395. * @param func The function to execute after physics step
  76396. */
  76397. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76398. /**
  76399. * register a function that will be executed when this impostor collides against a different body
  76400. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76401. * @param func Callback that is executed on collision
  76402. */
  76403. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76404. /**
  76405. * Unregisters the physics imposter on contact
  76406. * @param collideAgainst The physics object to collide against
  76407. * @param func Callback to execute on collision
  76408. */
  76409. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76410. private _tmpQuat;
  76411. private _tmpQuat2;
  76412. /**
  76413. * Get the parent rotation
  76414. * @returns The parent rotation
  76415. */
  76416. getParentsRotation(): Quaternion;
  76417. /**
  76418. * this function is executed by the physics engine.
  76419. */
  76420. beforeStep: () => void;
  76421. /**
  76422. * this function is executed by the physics engine
  76423. */
  76424. afterStep: () => void;
  76425. /**
  76426. * Legacy collision detection event support
  76427. */
  76428. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76429. /**
  76430. * event and body object due to cannon's event-based architecture.
  76431. */
  76432. onCollide: (e: {
  76433. body: any;
  76434. }) => void;
  76435. /**
  76436. * Apply a force
  76437. * @param force The force to apply
  76438. * @param contactPoint The contact point for the force
  76439. * @returns The physics imposter
  76440. */
  76441. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76442. /**
  76443. * Apply an impulse
  76444. * @param force The impulse force
  76445. * @param contactPoint The contact point for the impulse force
  76446. * @returns The physics imposter
  76447. */
  76448. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76449. /**
  76450. * A help function to create a joint
  76451. * @param otherImpostor A physics imposter used to create a joint
  76452. * @param jointType The type of joint
  76453. * @param jointData The data for the joint
  76454. * @returns The physics imposter
  76455. */
  76456. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76457. /**
  76458. * Add a joint to this impostor with a different impostor
  76459. * @param otherImpostor A physics imposter used to add a joint
  76460. * @param joint The joint to add
  76461. * @returns The physics imposter
  76462. */
  76463. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76464. /**
  76465. * Will keep this body still, in a sleep mode.
  76466. * @returns the physics imposter
  76467. */
  76468. sleep(): PhysicsImpostor;
  76469. /**
  76470. * Wake the body up.
  76471. * @returns The physics imposter
  76472. */
  76473. wakeUp(): PhysicsImpostor;
  76474. /**
  76475. * Clones the physics imposter
  76476. * @param newObject The physics imposter clones to this physics-enabled object
  76477. * @returns A nullable physics imposter
  76478. */
  76479. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76480. /**
  76481. * Disposes the physics imposter
  76482. */
  76483. dispose(): void;
  76484. /**
  76485. * Sets the delta position
  76486. * @param position The delta position amount
  76487. */
  76488. setDeltaPosition(position: Vector3): void;
  76489. /**
  76490. * Sets the delta rotation
  76491. * @param rotation The delta rotation amount
  76492. */
  76493. setDeltaRotation(rotation: Quaternion): void;
  76494. /**
  76495. * Gets the box size of the physics imposter and stores the result in the input parameter
  76496. * @param result Stores the box size
  76497. * @returns The physics imposter
  76498. */
  76499. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76500. /**
  76501. * Gets the radius of the physics imposter
  76502. * @returns Radius of the physics imposter
  76503. */
  76504. getRadius(): number;
  76505. /**
  76506. * Sync a bone with this impostor
  76507. * @param bone The bone to sync to the impostor.
  76508. * @param boneMesh The mesh that the bone is influencing.
  76509. * @param jointPivot The pivot of the joint / bone in local space.
  76510. * @param distToJoint Optional distance from the impostor to the joint.
  76511. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76512. */
  76513. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76514. /**
  76515. * Sync impostor to a bone
  76516. * @param bone The bone that the impostor will be synced to.
  76517. * @param boneMesh The mesh that the bone is influencing.
  76518. * @param jointPivot The pivot of the joint / bone in local space.
  76519. * @param distToJoint Optional distance from the impostor to the joint.
  76520. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76521. * @param boneAxis Optional vector3 axis the bone is aligned with
  76522. */
  76523. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76524. /**
  76525. * No-Imposter type
  76526. */
  76527. static NoImpostor: number;
  76528. /**
  76529. * Sphere-Imposter type
  76530. */
  76531. static SphereImpostor: number;
  76532. /**
  76533. * Box-Imposter type
  76534. */
  76535. static BoxImpostor: number;
  76536. /**
  76537. * Plane-Imposter type
  76538. */
  76539. static PlaneImpostor: number;
  76540. /**
  76541. * Mesh-imposter type
  76542. */
  76543. static MeshImpostor: number;
  76544. /**
  76545. * Cylinder-Imposter type
  76546. */
  76547. static CylinderImpostor: number;
  76548. /**
  76549. * Particle-Imposter type
  76550. */
  76551. static ParticleImpostor: number;
  76552. /**
  76553. * Heightmap-Imposter type
  76554. */
  76555. static HeightmapImpostor: number;
  76556. }
  76557. }
  76558. declare module BABYLON {
  76559. /**
  76560. * Class used to represent a specific level of detail of a mesh
  76561. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76562. */
  76563. export class MeshLODLevel {
  76564. /** Defines the distance where this level should star being displayed */
  76565. distance: number;
  76566. /** Defines the mesh to use to render this level */
  76567. mesh: Nullable<Mesh>;
  76568. /**
  76569. * Creates a new LOD level
  76570. * @param distance defines the distance where this level should star being displayed
  76571. * @param mesh defines the mesh to use to render this level
  76572. */
  76573. constructor(
  76574. /** Defines the distance where this level should star being displayed */
  76575. distance: number,
  76576. /** Defines the mesh to use to render this level */
  76577. mesh: Nullable<Mesh>);
  76578. }
  76579. /**
  76580. * @hidden
  76581. **/
  76582. export class _CreationDataStorage {
  76583. closePath?: boolean;
  76584. closeArray?: boolean;
  76585. idx: number[];
  76586. dashSize: number;
  76587. gapSize: number;
  76588. path3D: Path3D;
  76589. pathArray: Vector3[][];
  76590. arc: number;
  76591. radius: number;
  76592. cap: number;
  76593. tessellation: number;
  76594. }
  76595. /**
  76596. * @hidden
  76597. **/
  76598. class _InstanceDataStorage {
  76599. visibleInstances: any;
  76600. renderIdForInstances: number[];
  76601. batchCache: _InstancesBatch;
  76602. instancesBufferSize: number;
  76603. instancesBuffer: Nullable<Buffer>;
  76604. instancesData: Float32Array;
  76605. overridenInstanceCount: number;
  76606. }
  76607. /**
  76608. * @hidden
  76609. **/
  76610. export class _InstancesBatch {
  76611. mustReturn: boolean;
  76612. visibleInstances: Nullable<InstancedMesh[]>[];
  76613. renderSelf: boolean[];
  76614. }
  76615. /**
  76616. * Class used to represent renderable models
  76617. */
  76618. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76619. /**
  76620. * Mesh side orientation : usually the external or front surface
  76621. */
  76622. static readonly FRONTSIDE: number;
  76623. /**
  76624. * Mesh side orientation : usually the internal or back surface
  76625. */
  76626. static readonly BACKSIDE: number;
  76627. /**
  76628. * Mesh side orientation : both internal and external or front and back surfaces
  76629. */
  76630. static readonly DOUBLESIDE: number;
  76631. /**
  76632. * Mesh side orientation : by default, `FRONTSIDE`
  76633. */
  76634. static readonly DEFAULTSIDE: number;
  76635. /**
  76636. * Mesh cap setting : no cap
  76637. */
  76638. static readonly NO_CAP: number;
  76639. /**
  76640. * Mesh cap setting : one cap at the beginning of the mesh
  76641. */
  76642. static readonly CAP_START: number;
  76643. /**
  76644. * Mesh cap setting : one cap at the end of the mesh
  76645. */
  76646. static readonly CAP_END: number;
  76647. /**
  76648. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76649. */
  76650. static readonly CAP_ALL: number;
  76651. /**
  76652. * Gets the default side orientation.
  76653. * @param orientation the orientation to value to attempt to get
  76654. * @returns the default orientation
  76655. * @hidden
  76656. */
  76657. static _GetDefaultSideOrientation(orientation?: number): number;
  76658. private _onBeforeRenderObservable;
  76659. private _onBeforeBindObservable;
  76660. private _onAfterRenderObservable;
  76661. private _onBeforeDrawObservable;
  76662. /**
  76663. * An event triggered before rendering the mesh
  76664. */
  76665. readonly onBeforeRenderObservable: Observable<Mesh>;
  76666. /**
  76667. * An event triggered before binding the mesh
  76668. */
  76669. readonly onBeforeBindObservable: Observable<Mesh>;
  76670. /**
  76671. * An event triggered after rendering the mesh
  76672. */
  76673. readonly onAfterRenderObservable: Observable<Mesh>;
  76674. /**
  76675. * An event triggered before drawing the mesh
  76676. */
  76677. readonly onBeforeDrawObservable: Observable<Mesh>;
  76678. private _onBeforeDrawObserver;
  76679. /**
  76680. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76681. */
  76682. onBeforeDraw: () => void;
  76683. /**
  76684. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76685. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76686. */
  76687. delayLoadState: number;
  76688. /**
  76689. * Gets the list of instances created from this mesh
  76690. * it is not supposed to be modified manually.
  76691. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76692. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76693. */
  76694. instances: InstancedMesh[];
  76695. /**
  76696. * Gets the file containing delay loading data for this mesh
  76697. */
  76698. delayLoadingFile: string;
  76699. /** @hidden */
  76700. _binaryInfo: any;
  76701. private _LODLevels;
  76702. /**
  76703. * User defined function used to change how LOD level selection is done
  76704. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76705. */
  76706. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76707. private _morphTargetManager;
  76708. /**
  76709. * Gets or sets the morph target manager
  76710. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76711. */
  76712. morphTargetManager: Nullable<MorphTargetManager>;
  76713. /** @hidden */
  76714. _creationDataStorage: Nullable<_CreationDataStorage>;
  76715. /** @hidden */
  76716. _geometry: Nullable<Geometry>;
  76717. /** @hidden */
  76718. _delayInfo: Array<string>;
  76719. /** @hidden */
  76720. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76721. /** @hidden */
  76722. _instanceDataStorage: _InstanceDataStorage;
  76723. private _effectiveMaterial;
  76724. /** @hidden */
  76725. _shouldGenerateFlatShading: boolean;
  76726. private _preActivateId;
  76727. /** @hidden */
  76728. _originalBuilderSideOrientation: number;
  76729. /**
  76730. * Use this property to change the original side orientation defined at construction time
  76731. */
  76732. overrideMaterialSideOrientation: Nullable<number>;
  76733. private _areNormalsFrozen;
  76734. private _sourcePositions;
  76735. private _sourceNormals;
  76736. private _source;
  76737. private meshMap;
  76738. /**
  76739. * Gets the source mesh (the one used to clone this one from)
  76740. */
  76741. readonly source: Nullable<Mesh>;
  76742. /**
  76743. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76744. */
  76745. isUnIndexed: boolean;
  76746. /**
  76747. * @constructor
  76748. * @param name The value used by scene.getMeshByName() to do a lookup.
  76749. * @param scene The scene to add this mesh to.
  76750. * @param parent The parent of this mesh, if it has one
  76751. * @param source An optional Mesh from which geometry is shared, cloned.
  76752. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76753. * When false, achieved by calling a clone(), also passing False.
  76754. * This will make creation of children, recursive.
  76755. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76756. */
  76757. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76758. /**
  76759. * Gets the class name
  76760. * @returns the string "Mesh".
  76761. */
  76762. getClassName(): string;
  76763. /** @hidden */
  76764. readonly _isMesh: boolean;
  76765. /**
  76766. * Returns a description of this mesh
  76767. * @param fullDetails define if full details about this mesh must be used
  76768. * @returns a descriptive string representing this mesh
  76769. */
  76770. toString(fullDetails?: boolean): string;
  76771. /** @hidden */
  76772. _unBindEffect(): void;
  76773. /**
  76774. * Gets a boolean indicating if this mesh has LOD
  76775. */
  76776. readonly hasLODLevels: boolean;
  76777. /**
  76778. * Gets the list of MeshLODLevel associated with the current mesh
  76779. * @returns an array of MeshLODLevel
  76780. */
  76781. getLODLevels(): MeshLODLevel[];
  76782. private _sortLODLevels;
  76783. /**
  76784. * Add a mesh as LOD level triggered at the given distance.
  76785. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76786. * @param distance The distance from the center of the object to show this level
  76787. * @param mesh The mesh to be added as LOD level (can be null)
  76788. * @return This mesh (for chaining)
  76789. */
  76790. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76791. /**
  76792. * Returns the LOD level mesh at the passed distance or null if not found.
  76793. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76794. * @param distance The distance from the center of the object to show this level
  76795. * @returns a Mesh or `null`
  76796. */
  76797. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76798. /**
  76799. * Remove a mesh from the LOD array
  76800. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76801. * @param mesh defines the mesh to be removed
  76802. * @return This mesh (for chaining)
  76803. */
  76804. removeLODLevel(mesh: Mesh): Mesh;
  76805. /**
  76806. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76807. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76808. * @param camera defines the camera to use to compute distance
  76809. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76810. * @return This mesh (for chaining)
  76811. */
  76812. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76813. /**
  76814. * Gets the mesh internal Geometry object
  76815. */
  76816. readonly geometry: Nullable<Geometry>;
  76817. /**
  76818. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76819. * @returns the total number of vertices
  76820. */
  76821. getTotalVertices(): number;
  76822. /**
  76823. * Returns the content of an associated vertex buffer
  76824. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76825. * - VertexBuffer.PositionKind
  76826. * - VertexBuffer.UVKind
  76827. * - VertexBuffer.UV2Kind
  76828. * - VertexBuffer.UV3Kind
  76829. * - VertexBuffer.UV4Kind
  76830. * - VertexBuffer.UV5Kind
  76831. * - VertexBuffer.UV6Kind
  76832. * - VertexBuffer.ColorKind
  76833. * - VertexBuffer.MatricesIndicesKind
  76834. * - VertexBuffer.MatricesIndicesExtraKind
  76835. * - VertexBuffer.MatricesWeightsKind
  76836. * - VertexBuffer.MatricesWeightsExtraKind
  76837. * @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
  76838. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76839. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76840. */
  76841. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76842. /**
  76843. * Returns the mesh VertexBuffer object from the requested `kind`
  76844. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76845. * - VertexBuffer.PositionKind
  76846. * - VertexBuffer.UVKind
  76847. * - VertexBuffer.UV2Kind
  76848. * - VertexBuffer.UV3Kind
  76849. * - VertexBuffer.UV4Kind
  76850. * - VertexBuffer.UV5Kind
  76851. * - VertexBuffer.UV6Kind
  76852. * - VertexBuffer.ColorKind
  76853. * - VertexBuffer.MatricesIndicesKind
  76854. * - VertexBuffer.MatricesIndicesExtraKind
  76855. * - VertexBuffer.MatricesWeightsKind
  76856. * - VertexBuffer.MatricesWeightsExtraKind
  76857. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76858. */
  76859. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76860. /**
  76861. * Tests if a specific vertex buffer is associated with this mesh
  76862. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76863. * - VertexBuffer.PositionKind
  76864. * - VertexBuffer.UVKind
  76865. * - VertexBuffer.UV2Kind
  76866. * - VertexBuffer.UV3Kind
  76867. * - VertexBuffer.UV4Kind
  76868. * - VertexBuffer.UV5Kind
  76869. * - VertexBuffer.UV6Kind
  76870. * - VertexBuffer.ColorKind
  76871. * - VertexBuffer.MatricesIndicesKind
  76872. * - VertexBuffer.MatricesIndicesExtraKind
  76873. * - VertexBuffer.MatricesWeightsKind
  76874. * - VertexBuffer.MatricesWeightsExtraKind
  76875. * @returns a boolean
  76876. */
  76877. isVerticesDataPresent(kind: string): boolean;
  76878. /**
  76879. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76880. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76881. * - VertexBuffer.PositionKind
  76882. * - VertexBuffer.UVKind
  76883. * - VertexBuffer.UV2Kind
  76884. * - VertexBuffer.UV3Kind
  76885. * - VertexBuffer.UV4Kind
  76886. * - VertexBuffer.UV5Kind
  76887. * - VertexBuffer.UV6Kind
  76888. * - VertexBuffer.ColorKind
  76889. * - VertexBuffer.MatricesIndicesKind
  76890. * - VertexBuffer.MatricesIndicesExtraKind
  76891. * - VertexBuffer.MatricesWeightsKind
  76892. * - VertexBuffer.MatricesWeightsExtraKind
  76893. * @returns a boolean
  76894. */
  76895. isVertexBufferUpdatable(kind: string): boolean;
  76896. /**
  76897. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76898. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76899. * - VertexBuffer.PositionKind
  76900. * - VertexBuffer.UVKind
  76901. * - VertexBuffer.UV2Kind
  76902. * - VertexBuffer.UV3Kind
  76903. * - VertexBuffer.UV4Kind
  76904. * - VertexBuffer.UV5Kind
  76905. * - VertexBuffer.UV6Kind
  76906. * - VertexBuffer.ColorKind
  76907. * - VertexBuffer.MatricesIndicesKind
  76908. * - VertexBuffer.MatricesIndicesExtraKind
  76909. * - VertexBuffer.MatricesWeightsKind
  76910. * - VertexBuffer.MatricesWeightsExtraKind
  76911. * @returns an array of strings
  76912. */
  76913. getVerticesDataKinds(): string[];
  76914. /**
  76915. * Returns a positive integer : the total number of indices in this mesh geometry.
  76916. * @returns the numner of indices or zero if the mesh has no geometry.
  76917. */
  76918. getTotalIndices(): number;
  76919. /**
  76920. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76921. * @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.
  76922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76923. * @returns the indices array or an empty array if the mesh has no geometry
  76924. */
  76925. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76926. readonly isBlocked: boolean;
  76927. /**
  76928. * Determine if the current mesh is ready to be rendered
  76929. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76930. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76931. * @returns true if all associated assets are ready (material, textures, shaders)
  76932. */
  76933. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76934. /**
  76935. * 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.
  76936. */
  76937. readonly areNormalsFrozen: boolean;
  76938. /**
  76939. * 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.
  76940. * @returns the current mesh
  76941. */
  76942. freezeNormals(): Mesh;
  76943. /**
  76944. * 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
  76945. * @returns the current mesh
  76946. */
  76947. unfreezeNormals(): Mesh;
  76948. /**
  76949. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76950. */
  76951. overridenInstanceCount: number;
  76952. /** @hidden */
  76953. _preActivate(): Mesh;
  76954. /** @hidden */
  76955. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76956. /** @hidden */
  76957. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76958. /**
  76959. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76960. * This means the mesh underlying bounding box and sphere are recomputed.
  76961. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76962. * @returns the current mesh
  76963. */
  76964. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76965. /** @hidden */
  76966. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76967. /**
  76968. * This function will subdivide the mesh into multiple submeshes
  76969. * @param count defines the expected number of submeshes
  76970. */
  76971. subdivide(count: number): void;
  76972. /**
  76973. * Copy a FloatArray into a specific associated vertex buffer
  76974. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76975. * - VertexBuffer.PositionKind
  76976. * - VertexBuffer.UVKind
  76977. * - VertexBuffer.UV2Kind
  76978. * - VertexBuffer.UV3Kind
  76979. * - VertexBuffer.UV4Kind
  76980. * - VertexBuffer.UV5Kind
  76981. * - VertexBuffer.UV6Kind
  76982. * - VertexBuffer.ColorKind
  76983. * - VertexBuffer.MatricesIndicesKind
  76984. * - VertexBuffer.MatricesIndicesExtraKind
  76985. * - VertexBuffer.MatricesWeightsKind
  76986. * - VertexBuffer.MatricesWeightsExtraKind
  76987. * @param data defines the data source
  76988. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76989. * @param stride defines the data stride size (can be null)
  76990. * @returns the current mesh
  76991. */
  76992. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76993. /**
  76994. * Flags an associated vertex buffer as updatable
  76995. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76996. * - VertexBuffer.PositionKind
  76997. * - VertexBuffer.UVKind
  76998. * - VertexBuffer.UV2Kind
  76999. * - VertexBuffer.UV3Kind
  77000. * - VertexBuffer.UV4Kind
  77001. * - VertexBuffer.UV5Kind
  77002. * - VertexBuffer.UV6Kind
  77003. * - VertexBuffer.ColorKind
  77004. * - VertexBuffer.MatricesIndicesKind
  77005. * - VertexBuffer.MatricesIndicesExtraKind
  77006. * - VertexBuffer.MatricesWeightsKind
  77007. * - VertexBuffer.MatricesWeightsExtraKind
  77008. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77009. */
  77010. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77011. /**
  77012. * Sets the mesh global Vertex Buffer
  77013. * @param buffer defines the buffer to use
  77014. * @returns the current mesh
  77015. */
  77016. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77017. /**
  77018. * Update a specific associated vertex buffer
  77019. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77020. * - VertexBuffer.PositionKind
  77021. * - VertexBuffer.UVKind
  77022. * - VertexBuffer.UV2Kind
  77023. * - VertexBuffer.UV3Kind
  77024. * - VertexBuffer.UV4Kind
  77025. * - VertexBuffer.UV5Kind
  77026. * - VertexBuffer.UV6Kind
  77027. * - VertexBuffer.ColorKind
  77028. * - VertexBuffer.MatricesIndicesKind
  77029. * - VertexBuffer.MatricesIndicesExtraKind
  77030. * - VertexBuffer.MatricesWeightsKind
  77031. * - VertexBuffer.MatricesWeightsExtraKind
  77032. * @param data defines the data source
  77033. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77034. * @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)
  77035. * @returns the current mesh
  77036. */
  77037. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77038. /**
  77039. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77040. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77041. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77042. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77043. * @returns the current mesh
  77044. */
  77045. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77046. /**
  77047. * Creates a un-shared specific occurence of the geometry for the mesh.
  77048. * @returns the current mesh
  77049. */
  77050. makeGeometryUnique(): Mesh;
  77051. /**
  77052. * Set the index buffer of this mesh
  77053. * @param indices defines the source data
  77054. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77055. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77056. * @returns the current mesh
  77057. */
  77058. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77059. /**
  77060. * Update the current index buffer
  77061. * @param indices defines the source data
  77062. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77063. * @returns the current mesh
  77064. */
  77065. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77066. /**
  77067. * Invert the geometry to move from a right handed system to a left handed one.
  77068. * @returns the current mesh
  77069. */
  77070. toLeftHanded(): Mesh;
  77071. /** @hidden */
  77072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77073. /** @hidden */
  77074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77075. /**
  77076. * Registers for this mesh a javascript function called just before the rendering process
  77077. * @param func defines the function to call before rendering this mesh
  77078. * @returns the current mesh
  77079. */
  77080. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77081. /**
  77082. * Disposes a previously registered javascript function called before the rendering
  77083. * @param func defines the function to remove
  77084. * @returns the current mesh
  77085. */
  77086. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77087. /**
  77088. * Registers for this mesh a javascript function called just after the rendering is complete
  77089. * @param func defines the function to call after rendering this mesh
  77090. * @returns the current mesh
  77091. */
  77092. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77093. /**
  77094. * Disposes a previously registered javascript function called after the rendering.
  77095. * @param func defines the function to remove
  77096. * @returns the current mesh
  77097. */
  77098. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77099. /** @hidden */
  77100. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77101. /** @hidden */
  77102. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77103. /** @hidden */
  77104. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77105. /**
  77106. * 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
  77107. * @param subMesh defines the subMesh to render
  77108. * @param enableAlphaMode defines if alpha mode can be changed
  77109. * @returns the current mesh
  77110. */
  77111. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77112. private _onBeforeDraw;
  77113. /**
  77114. * Renormalize the mesh and patch it up if there are no weights
  77115. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77116. * However in the case of zero weights then we set just a single influence to 1.
  77117. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77118. */
  77119. cleanMatrixWeights(): void;
  77120. private normalizeSkinFourWeights;
  77121. private normalizeSkinWeightsAndExtra;
  77122. /**
  77123. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77124. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77125. * the user know there was an issue with importing the mesh
  77126. * @returns a validation object with skinned, valid and report string
  77127. */
  77128. validateSkinning(): {
  77129. skinned: boolean;
  77130. valid: boolean;
  77131. report: string;
  77132. };
  77133. /** @hidden */
  77134. _checkDelayState(): Mesh;
  77135. private _queueLoad;
  77136. /**
  77137. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77138. * A mesh is in the frustum if its bounding box intersects the frustum
  77139. * @param frustumPlanes defines the frustum to test
  77140. * @returns true if the mesh is in the frustum planes
  77141. */
  77142. isInFrustum(frustumPlanes: Plane[]): boolean;
  77143. /**
  77144. * Sets the mesh material by the material or multiMaterial `id` property
  77145. * @param id is a string identifying the material or the multiMaterial
  77146. * @returns the current mesh
  77147. */
  77148. setMaterialByID(id: string): Mesh;
  77149. /**
  77150. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77151. * @returns an array of IAnimatable
  77152. */
  77153. getAnimatables(): IAnimatable[];
  77154. /**
  77155. * Modifies the mesh geometry according to the passed transformation matrix.
  77156. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77157. * The mesh normals are modified using the same transformation.
  77158. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77159. * @param transform defines the transform matrix to use
  77160. * @see http://doc.babylonjs.com/resources/baking_transformations
  77161. * @returns the current mesh
  77162. */
  77163. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77164. /**
  77165. * Modifies the mesh geometry according to its own current World Matrix.
  77166. * The mesh World Matrix is then reset.
  77167. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77169. * @see http://doc.babylonjs.com/resources/baking_transformations
  77170. * @returns the current mesh
  77171. */
  77172. bakeCurrentTransformIntoVertices(): Mesh;
  77173. /** @hidden */
  77174. readonly _positions: Nullable<Vector3[]>;
  77175. /** @hidden */
  77176. _resetPointsArrayCache(): Mesh;
  77177. /** @hidden */
  77178. _generatePointsArray(): boolean;
  77179. /**
  77180. * Returns a new Mesh object generated from the current mesh properties.
  77181. * This method must not get confused with createInstance()
  77182. * @param name is a string, the name given to the new mesh
  77183. * @param newParent can be any Node object (default `null`)
  77184. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77185. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77186. * @returns a new mesh
  77187. */
  77188. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77189. /**
  77190. * Releases resources associated with this mesh.
  77191. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77192. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77193. */
  77194. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77195. /**
  77196. * Modifies the mesh geometry according to a displacement map.
  77197. * 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.
  77198. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77199. * @param url is a string, the URL from the image file is to be downloaded.
  77200. * @param minHeight is the lower limit of the displacement.
  77201. * @param maxHeight is the upper limit of the displacement.
  77202. * @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.
  77203. * @param uvOffset is an optional vector2 used to offset UV.
  77204. * @param uvScale is an optional vector2 used to scale UV.
  77205. * @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.
  77206. * @returns the Mesh.
  77207. */
  77208. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77209. /**
  77210. * Modifies the mesh geometry according to a displacementMap buffer.
  77211. * 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.
  77212. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77213. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77214. * @param heightMapWidth is the width of the buffer image.
  77215. * @param heightMapHeight is the height of the buffer image.
  77216. * @param minHeight is the lower limit of the displacement.
  77217. * @param maxHeight is the upper limit of the displacement.
  77218. * @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.
  77219. * @param uvOffset is an optional vector2 used to offset UV.
  77220. * @param uvScale is an optional vector2 used to scale UV.
  77221. * @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.
  77222. * @returns the Mesh.
  77223. */
  77224. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77225. /**
  77226. * Modify the mesh to get a flat shading rendering.
  77227. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77228. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77229. * @returns current mesh
  77230. */
  77231. convertToFlatShadedMesh(): Mesh;
  77232. /**
  77233. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77234. * In other words, more vertices, no more indices and a single bigger VBO.
  77235. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77236. * @returns current mesh
  77237. */
  77238. convertToUnIndexedMesh(): Mesh;
  77239. /**
  77240. * Inverses facet orientations.
  77241. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77242. * @param flipNormals will also inverts the normals
  77243. * @returns current mesh
  77244. */
  77245. flipFaces(flipNormals?: boolean): Mesh;
  77246. /** @hidden */
  77247. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77248. /** @hidden */
  77249. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77250. /**
  77251. * Creates a new InstancedMesh object from the mesh model.
  77252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77253. * @param name defines the name of the new instance
  77254. * @returns a new InstancedMesh
  77255. */
  77256. createInstance(name: string): InstancedMesh;
  77257. /**
  77258. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77259. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77260. * @returns the current mesh
  77261. */
  77262. synchronizeInstances(): Mesh;
  77263. /**
  77264. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77265. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77266. * This should be used together with the simplification to avoid disappearing triangles.
  77267. * @param successCallback an optional success callback to be called after the optimization finished.
  77268. * @returns the current mesh
  77269. */
  77270. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77271. /**
  77272. * Serialize current mesh
  77273. * @param serializationObject defines the object which will receive the serialization data
  77274. */
  77275. serialize(serializationObject: any): void;
  77276. /** @hidden */
  77277. _syncGeometryWithMorphTargetManager(): void;
  77278. /** @hidden */
  77279. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77280. /**
  77281. * Returns a new Mesh object parsed from the source provided.
  77282. * @param parsedMesh is the source
  77283. * @param scene defines the hosting scene
  77284. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77285. * @returns a new Mesh
  77286. */
  77287. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77288. /**
  77289. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77290. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77291. * @param name defines the name of the mesh to create
  77292. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77293. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77294. * @param closePath creates a seam between the first and the last points of each path of the path array
  77295. * @param offset is taken in account only if the `pathArray` is containing a single path
  77296. * @param scene defines the hosting scene
  77297. * @param updatable defines if the mesh must be flagged as updatable
  77298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77299. * @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)
  77300. * @returns a new Mesh
  77301. */
  77302. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77303. /**
  77304. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77305. * @param name defines the name of the mesh to create
  77306. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77307. * @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
  77308. * @param scene defines the hosting scene
  77309. * @param updatable defines if the mesh must be flagged as updatable
  77310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77311. * @returns a new Mesh
  77312. */
  77313. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77314. /**
  77315. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77316. * @param name defines the name of the mesh to create
  77317. * @param size sets the size (float) of each box side (default 1)
  77318. * @param scene defines the hosting scene
  77319. * @param updatable defines if the mesh must be flagged as updatable
  77320. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77321. * @returns a new Mesh
  77322. */
  77323. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77324. /**
  77325. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77326. * @param name defines the name of the mesh to create
  77327. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77328. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77329. * @param scene defines the hosting scene
  77330. * @param updatable defines if the mesh must be flagged as updatable
  77331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77332. * @returns a new Mesh
  77333. */
  77334. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77335. /**
  77336. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77337. * @param name defines the name of the mesh to create
  77338. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77339. * @param diameterTop set the top cap diameter (floats, default 1)
  77340. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77341. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77342. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77343. * @param scene defines the hosting scene
  77344. * @param updatable defines if the mesh must be flagged as updatable
  77345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77346. * @returns a new Mesh
  77347. */
  77348. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77349. /**
  77350. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77351. * @param name defines the name of the mesh to create
  77352. * @param diameter sets the diameter size (float) of the torus (default 1)
  77353. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77354. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77355. * @param scene defines the hosting scene
  77356. * @param updatable defines if the mesh must be flagged as updatable
  77357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77358. * @returns a new Mesh
  77359. */
  77360. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77361. /**
  77362. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77363. * @param name defines the name of the mesh to create
  77364. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77365. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77366. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77367. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77368. * @param p the number of windings on X axis (positive integers, default 2)
  77369. * @param q the number of windings on Y axis (positive integers, default 3)
  77370. * @param scene defines the hosting scene
  77371. * @param updatable defines if the mesh must be flagged as updatable
  77372. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77373. * @returns a new Mesh
  77374. */
  77375. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77376. /**
  77377. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77378. * @param name defines the name of the mesh to create
  77379. * @param points is an array successive Vector3
  77380. * @param scene defines the hosting scene
  77381. * @param updatable defines if the mesh must be flagged as updatable
  77382. * @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).
  77383. * @returns a new Mesh
  77384. */
  77385. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77386. /**
  77387. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77388. * @param name defines the name of the mesh to create
  77389. * @param points is an array successive Vector3
  77390. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77391. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77392. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77393. * @param scene defines the hosting scene
  77394. * @param updatable defines if the mesh must be flagged as updatable
  77395. * @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)
  77396. * @returns a new Mesh
  77397. */
  77398. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77399. /**
  77400. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77401. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77402. * 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.
  77403. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77404. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77405. * Remember you can only change the shape positions, not their number when updating a polygon.
  77406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77407. * @param name defines the name of the mesh to create
  77408. * @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
  77409. * @param scene defines the hosting scene
  77410. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77411. * @param updatable defines if the mesh must be flagged as updatable
  77412. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77413. * @param earcutInjection can be used to inject your own earcut reference
  77414. * @returns a new Mesh
  77415. */
  77416. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77417. /**
  77418. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77419. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77420. * @param name defines the name of the mesh to create
  77421. * @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
  77422. * @param depth defines the height of extrusion
  77423. * @param scene defines the hosting scene
  77424. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77425. * @param updatable defines if the mesh must be flagged as updatable
  77426. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77427. * @param earcutInjection can be used to inject your own earcut reference
  77428. * @returns a new Mesh
  77429. */
  77430. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77431. /**
  77432. * Creates an extruded shape mesh.
  77433. * 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
  77434. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77435. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77436. * @param name defines the name of the mesh to create
  77437. * @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
  77438. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77439. * @param scale is the value to scale the shape
  77440. * @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
  77441. * @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
  77442. * @param scene defines the hosting scene
  77443. * @param updatable defines if the mesh must be flagged as updatable
  77444. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77445. * @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)
  77446. * @returns a new Mesh
  77447. */
  77448. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77449. /**
  77450. * Creates an custom extruded shape mesh.
  77451. * The custom extrusion is a parametric shape.
  77452. * It has no predefined shape. Its final shape will depend on the input parameters.
  77453. * Please consider using the same method from the MeshBuilder class instead
  77454. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77455. * @param name defines the name of the mesh to create
  77456. * @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
  77457. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77458. * @param scaleFunction is a custom Javascript function called on each path point
  77459. * @param rotationFunction is a custom Javascript function called on each path point
  77460. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77461. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77462. * @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
  77463. * @param scene defines the hosting scene
  77464. * @param updatable defines if the mesh must be flagged as updatable
  77465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77466. * @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)
  77467. * @returns a new Mesh
  77468. */
  77469. 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;
  77470. /**
  77471. * Creates lathe mesh.
  77472. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77473. * Please consider using the same method from the MeshBuilder class instead
  77474. * @param name defines the name of the mesh to create
  77475. * @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
  77476. * @param radius is the radius value of the lathe
  77477. * @param tessellation is the side number of the lathe.
  77478. * @param scene defines the hosting scene
  77479. * @param updatable defines if the mesh must be flagged as updatable
  77480. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77481. * @returns a new Mesh
  77482. */
  77483. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77484. /**
  77485. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77486. * @param name defines the name of the mesh to create
  77487. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77488. * @param scene defines the hosting scene
  77489. * @param updatable defines if the mesh must be flagged as updatable
  77490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77491. * @returns a new Mesh
  77492. */
  77493. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77494. /**
  77495. * Creates a ground mesh.
  77496. * Please consider using the same method from the MeshBuilder class instead
  77497. * @param name defines the name of the mesh to create
  77498. * @param width set the width of the ground
  77499. * @param height set the height of the ground
  77500. * @param subdivisions sets the number of subdivisions per side
  77501. * @param scene defines the hosting scene
  77502. * @param updatable defines if the mesh must be flagged as updatable
  77503. * @returns a new Mesh
  77504. */
  77505. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77506. /**
  77507. * Creates a tiled ground mesh.
  77508. * Please consider using the same method from the MeshBuilder class instead
  77509. * @param name defines the name of the mesh to create
  77510. * @param xmin set the ground minimum X coordinate
  77511. * @param zmin set the ground minimum Y coordinate
  77512. * @param xmax set the ground maximum X coordinate
  77513. * @param zmax set the ground maximum Z coordinate
  77514. * @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
  77515. * @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
  77516. * @param scene defines the hosting scene
  77517. * @param updatable defines if the mesh must be flagged as updatable
  77518. * @returns a new Mesh
  77519. */
  77520. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77521. w: number;
  77522. h: number;
  77523. }, precision: {
  77524. w: number;
  77525. h: number;
  77526. }, scene: Scene, updatable?: boolean): Mesh;
  77527. /**
  77528. * Creates a ground mesh from a height map.
  77529. * Please consider using the same method from the MeshBuilder class instead
  77530. * @see http://doc.babylonjs.com/babylon101/height_map
  77531. * @param name defines the name of the mesh to create
  77532. * @param url sets the URL of the height map image resource
  77533. * @param width set the ground width size
  77534. * @param height set the ground height size
  77535. * @param subdivisions sets the number of subdivision per side
  77536. * @param minHeight is the minimum altitude on the ground
  77537. * @param maxHeight is the maximum altitude on the ground
  77538. * @param scene defines the hosting scene
  77539. * @param updatable defines if the mesh must be flagged as updatable
  77540. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77541. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77542. * @returns a new Mesh
  77543. */
  77544. 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;
  77545. /**
  77546. * Creates a tube mesh.
  77547. * The tube is a parametric shape.
  77548. * It has no predefined shape. Its final shape will depend on the input parameters.
  77549. * Please consider using the same method from the MeshBuilder class instead
  77550. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77551. * @param name defines the name of the mesh to create
  77552. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77553. * @param radius sets the tube radius size
  77554. * @param tessellation is the number of sides on the tubular surface
  77555. * @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
  77556. * @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
  77557. * @param scene defines the hosting scene
  77558. * @param updatable defines if the mesh must be flagged as updatable
  77559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77560. * @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)
  77561. * @returns a new Mesh
  77562. */
  77563. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77564. (i: number, distance: number): number;
  77565. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77566. /**
  77567. * Creates a polyhedron mesh.
  77568. * Please consider using the same method from the MeshBuilder class instead.
  77569. * * 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
  77570. * * The parameter `size` (positive float, default 1) sets the polygon size
  77571. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77572. * * 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`
  77573. * * 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
  77574. * * 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)`)
  77575. * * 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
  77576. * * 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
  77577. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77578. * * If you create a double-sided mesh, you can choose what parts of 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
  77579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77580. * @param name defines the name of the mesh to create
  77581. * @param options defines the options used to create the mesh
  77582. * @param scene defines the hosting scene
  77583. * @returns a new Mesh
  77584. */
  77585. static CreatePolyhedron(name: string, options: {
  77586. type?: number;
  77587. size?: number;
  77588. sizeX?: number;
  77589. sizeY?: number;
  77590. sizeZ?: number;
  77591. custom?: any;
  77592. faceUV?: Vector4[];
  77593. faceColors?: Color4[];
  77594. updatable?: boolean;
  77595. sideOrientation?: number;
  77596. }, scene: Scene): Mesh;
  77597. /**
  77598. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77599. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77600. * * 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`)
  77601. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77602. * * 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
  77603. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77604. * * If you create a double-sided mesh, you can choose what parts of 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
  77605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77606. * @param name defines the name of the mesh
  77607. * @param options defines the options used to create the mesh
  77608. * @param scene defines the hosting scene
  77609. * @returns a new Mesh
  77610. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77611. */
  77612. static CreateIcoSphere(name: string, options: {
  77613. radius?: number;
  77614. flat?: boolean;
  77615. subdivisions?: number;
  77616. sideOrientation?: number;
  77617. updatable?: boolean;
  77618. }, scene: Scene): Mesh;
  77619. /**
  77620. * Creates a decal mesh.
  77621. * Please consider using the same method from the MeshBuilder class instead.
  77622. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77623. * @param name defines the name of the mesh
  77624. * @param sourceMesh defines the mesh receiving the decal
  77625. * @param position sets the position of the decal in world coordinates
  77626. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77627. * @param size sets the decal scaling
  77628. * @param angle sets the angle to rotate the decal
  77629. * @returns a new Mesh
  77630. */
  77631. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77632. /**
  77633. * Prepare internal position array for software CPU skinning
  77634. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77635. */
  77636. setPositionsForCPUSkinning(): Float32Array;
  77637. /**
  77638. * Prepare internal normal array for software CPU skinning
  77639. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77640. */
  77641. setNormalsForCPUSkinning(): Float32Array;
  77642. /**
  77643. * Updates the vertex buffer by applying transformation from the bones
  77644. * @param skeleton defines the skeleton to apply to current mesh
  77645. * @returns the current mesh
  77646. */
  77647. applySkeleton(skeleton: Skeleton): Mesh;
  77648. /**
  77649. * 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
  77650. * @param meshes defines the list of meshes to scan
  77651. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77652. */
  77653. static MinMax(meshes: AbstractMesh[]): {
  77654. min: Vector3;
  77655. max: Vector3;
  77656. };
  77657. /**
  77658. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77659. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77660. * @returns a vector3
  77661. */
  77662. static Center(meshesOrMinMaxVector: {
  77663. min: Vector3;
  77664. max: Vector3;
  77665. } | AbstractMesh[]): Vector3;
  77666. /**
  77667. * Merge the array of meshes into a single mesh for performance reasons.
  77668. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77669. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77670. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77671. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77672. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77673. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77674. * @returns a new mesh
  77675. */
  77676. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77677. /** @hidden */
  77678. addInstance(instance: InstancedMesh): void;
  77679. /** @hidden */
  77680. removeInstance(instance: InstancedMesh): void;
  77681. }
  77682. }
  77683. declare module BABYLON {
  77684. /**
  77685. * Base class for the main features of a material in Babylon.js
  77686. */
  77687. export class Material implements IAnimatable {
  77688. /**
  77689. * Returns the triangle fill mode
  77690. */
  77691. static readonly TriangleFillMode: number;
  77692. /**
  77693. * Returns the wireframe mode
  77694. */
  77695. static readonly WireFrameFillMode: number;
  77696. /**
  77697. * Returns the point fill mode
  77698. */
  77699. static readonly PointFillMode: number;
  77700. /**
  77701. * Returns the point list draw mode
  77702. */
  77703. static readonly PointListDrawMode: number;
  77704. /**
  77705. * Returns the line list draw mode
  77706. */
  77707. static readonly LineListDrawMode: number;
  77708. /**
  77709. * Returns the line loop draw mode
  77710. */
  77711. static readonly LineLoopDrawMode: number;
  77712. /**
  77713. * Returns the line strip draw mode
  77714. */
  77715. static readonly LineStripDrawMode: number;
  77716. /**
  77717. * Returns the triangle strip draw mode
  77718. */
  77719. static readonly TriangleStripDrawMode: number;
  77720. /**
  77721. * Returns the triangle fan draw mode
  77722. */
  77723. static readonly TriangleFanDrawMode: number;
  77724. /**
  77725. * Stores the clock-wise side orientation
  77726. */
  77727. static readonly ClockWiseSideOrientation: number;
  77728. /**
  77729. * Stores the counter clock-wise side orientation
  77730. */
  77731. static readonly CounterClockWiseSideOrientation: number;
  77732. /**
  77733. * The dirty texture flag value
  77734. */
  77735. static readonly TextureDirtyFlag: number;
  77736. /**
  77737. * The dirty light flag value
  77738. */
  77739. static readonly LightDirtyFlag: number;
  77740. /**
  77741. * The dirty fresnel flag value
  77742. */
  77743. static readonly FresnelDirtyFlag: number;
  77744. /**
  77745. * The dirty attribute flag value
  77746. */
  77747. static readonly AttributesDirtyFlag: number;
  77748. /**
  77749. * The dirty misc flag value
  77750. */
  77751. static readonly MiscDirtyFlag: number;
  77752. /**
  77753. * The all dirty flag value
  77754. */
  77755. static readonly AllDirtyFlag: number;
  77756. /**
  77757. * The ID of the material
  77758. */
  77759. id: string;
  77760. /**
  77761. * Gets or sets the unique id of the material
  77762. */
  77763. uniqueId: number;
  77764. /**
  77765. * The name of the material
  77766. */
  77767. name: string;
  77768. /**
  77769. * Gets or sets user defined metadata
  77770. */
  77771. metadata: any;
  77772. /**
  77773. * For internal use only. Please do not use.
  77774. */
  77775. reservedDataStore: any;
  77776. /**
  77777. * Specifies if the ready state should be checked on each call
  77778. */
  77779. checkReadyOnEveryCall: boolean;
  77780. /**
  77781. * Specifies if the ready state should be checked once
  77782. */
  77783. checkReadyOnlyOnce: boolean;
  77784. /**
  77785. * The state of the material
  77786. */
  77787. state: string;
  77788. /**
  77789. * The alpha value of the material
  77790. */
  77791. protected _alpha: number;
  77792. /**
  77793. * Sets the alpha value of the material
  77794. */
  77795. /**
  77796. * Gets the alpha value of the material
  77797. */
  77798. alpha: number;
  77799. /**
  77800. * Specifies if back face culling is enabled
  77801. */
  77802. protected _backFaceCulling: boolean;
  77803. /**
  77804. * Sets the back-face culling state
  77805. */
  77806. /**
  77807. * Gets the back-face culling state
  77808. */
  77809. backFaceCulling: boolean;
  77810. /**
  77811. * Stores the value for side orientation
  77812. */
  77813. sideOrientation: number;
  77814. /**
  77815. * Callback triggered when the material is compiled
  77816. */
  77817. onCompiled: (effect: Effect) => void;
  77818. /**
  77819. * Callback triggered when an error occurs
  77820. */
  77821. onError: (effect: Effect, errors: string) => void;
  77822. /**
  77823. * Callback triggered to get the render target textures
  77824. */
  77825. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  77826. /**
  77827. * Gets a boolean indicating that current material needs to register RTT
  77828. */
  77829. readonly hasRenderTargetTextures: boolean;
  77830. /**
  77831. * Specifies if the material should be serialized
  77832. */
  77833. doNotSerialize: boolean;
  77834. /**
  77835. * @hidden
  77836. */
  77837. _storeEffectOnSubMeshes: boolean;
  77838. /**
  77839. * Stores the animations for the material
  77840. */
  77841. animations: Array<Animation>;
  77842. /**
  77843. * An event triggered when the material is disposed
  77844. */
  77845. onDisposeObservable: Observable<Material>;
  77846. /**
  77847. * An observer which watches for dispose events
  77848. */
  77849. private _onDisposeObserver;
  77850. private _onUnBindObservable;
  77851. /**
  77852. * Called during a dispose event
  77853. */
  77854. onDispose: () => void;
  77855. private _onBindObservable;
  77856. /**
  77857. * An event triggered when the material is bound
  77858. */
  77859. readonly onBindObservable: Observable<AbstractMesh>;
  77860. /**
  77861. * An observer which watches for bind events
  77862. */
  77863. private _onBindObserver;
  77864. /**
  77865. * Called during a bind event
  77866. */
  77867. onBind: (Mesh: AbstractMesh) => void;
  77868. /**
  77869. * An event triggered when the material is unbound
  77870. */
  77871. readonly onUnBindObservable: Observable<Material>;
  77872. /**
  77873. * Stores the value of the alpha mode
  77874. */
  77875. private _alphaMode;
  77876. /**
  77877. * Sets the value of the alpha mode.
  77878. *
  77879. * | Value | Type | Description |
  77880. * | --- | --- | --- |
  77881. * | 0 | ALPHA_DISABLE | |
  77882. * | 1 | ALPHA_ADD | |
  77883. * | 2 | ALPHA_COMBINE | |
  77884. * | 3 | ALPHA_SUBTRACT | |
  77885. * | 4 | ALPHA_MULTIPLY | |
  77886. * | 5 | ALPHA_MAXIMIZED | |
  77887. * | 6 | ALPHA_ONEONE | |
  77888. * | 7 | ALPHA_PREMULTIPLIED | |
  77889. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  77890. * | 9 | ALPHA_INTERPOLATE | |
  77891. * | 10 | ALPHA_SCREENMODE | |
  77892. *
  77893. */
  77894. /**
  77895. * Gets the value of the alpha mode
  77896. */
  77897. alphaMode: number;
  77898. /**
  77899. * Stores the state of the need depth pre-pass value
  77900. */
  77901. private _needDepthPrePass;
  77902. /**
  77903. * Sets the need depth pre-pass value
  77904. */
  77905. /**
  77906. * Gets the depth pre-pass value
  77907. */
  77908. needDepthPrePass: boolean;
  77909. /**
  77910. * Specifies if depth writing should be disabled
  77911. */
  77912. disableDepthWrite: boolean;
  77913. /**
  77914. * Specifies if depth writing should be forced
  77915. */
  77916. forceDepthWrite: boolean;
  77917. /**
  77918. * Specifies if there should be a separate pass for culling
  77919. */
  77920. separateCullingPass: boolean;
  77921. /**
  77922. * Stores the state specifing if fog should be enabled
  77923. */
  77924. private _fogEnabled;
  77925. /**
  77926. * Sets the state for enabling fog
  77927. */
  77928. /**
  77929. * Gets the value of the fog enabled state
  77930. */
  77931. fogEnabled: boolean;
  77932. /**
  77933. * Stores the size of points
  77934. */
  77935. pointSize: number;
  77936. /**
  77937. * Stores the z offset value
  77938. */
  77939. zOffset: number;
  77940. /**
  77941. * Gets a value specifying if wireframe mode is enabled
  77942. */
  77943. /**
  77944. * Sets the state of wireframe mode
  77945. */
  77946. wireframe: boolean;
  77947. /**
  77948. * Gets the value specifying if point clouds are enabled
  77949. */
  77950. /**
  77951. * Sets the state of point cloud mode
  77952. */
  77953. pointsCloud: boolean;
  77954. /**
  77955. * Gets the material fill mode
  77956. */
  77957. /**
  77958. * Sets the material fill mode
  77959. */
  77960. fillMode: number;
  77961. /**
  77962. * @hidden
  77963. * Stores the effects for the material
  77964. */
  77965. _effect: Nullable<Effect>;
  77966. /**
  77967. * @hidden
  77968. * Specifies if the material was previously ready
  77969. */
  77970. _wasPreviouslyReady: boolean;
  77971. /**
  77972. * Specifies if uniform buffers should be used
  77973. */
  77974. private _useUBO;
  77975. /**
  77976. * Stores a reference to the scene
  77977. */
  77978. private _scene;
  77979. /**
  77980. * Stores the fill mode state
  77981. */
  77982. private _fillMode;
  77983. /**
  77984. * Specifies if the depth write state should be cached
  77985. */
  77986. private _cachedDepthWriteState;
  77987. /**
  77988. * Stores the uniform buffer
  77989. */
  77990. protected _uniformBuffer: UniformBuffer;
  77991. /** @hidden */
  77992. _indexInSceneMaterialArray: number;
  77993. /** @hidden */
  77994. meshMap: Nullable<{
  77995. [id: string]: AbstractMesh | undefined;
  77996. }>;
  77997. /**
  77998. * Creates a material instance
  77999. * @param name defines the name of the material
  78000. * @param scene defines the scene to reference
  78001. * @param doNotAdd specifies if the material should be added to the scene
  78002. */
  78003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78004. /**
  78005. * Returns a string representation of the current material
  78006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78007. * @returns a string with material information
  78008. */
  78009. toString(fullDetails?: boolean): string;
  78010. /**
  78011. * Gets the class name of the material
  78012. * @returns a string with the class name of the material
  78013. */
  78014. getClassName(): string;
  78015. /**
  78016. * Specifies if updates for the material been locked
  78017. */
  78018. readonly isFrozen: boolean;
  78019. /**
  78020. * Locks updates for the material
  78021. */
  78022. freeze(): void;
  78023. /**
  78024. * Unlocks updates for the material
  78025. */
  78026. unfreeze(): void;
  78027. /**
  78028. * Specifies if the material is ready to be used
  78029. * @param mesh defines the mesh to check
  78030. * @param useInstances specifies if instances should be used
  78031. * @returns a boolean indicating if the material is ready to be used
  78032. */
  78033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78034. /**
  78035. * Specifies that the submesh is ready to be used
  78036. * @param mesh defines the mesh to check
  78037. * @param subMesh defines which submesh to check
  78038. * @param useInstances specifies that instances should be used
  78039. * @returns a boolean indicating that the submesh is ready or not
  78040. */
  78041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78042. /**
  78043. * Returns the material effect
  78044. * @returns the effect associated with the material
  78045. */
  78046. getEffect(): Nullable<Effect>;
  78047. /**
  78048. * Returns the current scene
  78049. * @returns a Scene
  78050. */
  78051. getScene(): Scene;
  78052. /**
  78053. * Specifies if the material will require alpha blending
  78054. * @returns a boolean specifying if alpha blending is needed
  78055. */
  78056. needAlphaBlending(): boolean;
  78057. /**
  78058. * Specifies if the mesh will require alpha blending
  78059. * @param mesh defines the mesh to check
  78060. * @returns a boolean specifying if alpha blending is needed for the mesh
  78061. */
  78062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78063. /**
  78064. * Specifies if this material should be rendered in alpha test mode
  78065. * @returns a boolean specifying if an alpha test is needed.
  78066. */
  78067. needAlphaTesting(): boolean;
  78068. /**
  78069. * Gets the texture used for the alpha test
  78070. * @returns the texture to use for alpha testing
  78071. */
  78072. getAlphaTestTexture(): Nullable<BaseTexture>;
  78073. /**
  78074. * Marks the material to indicate that it needs to be re-calculated
  78075. */
  78076. markDirty(): void;
  78077. /** @hidden */
  78078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78079. /**
  78080. * Binds the material to the mesh
  78081. * @param world defines the world transformation matrix
  78082. * @param mesh defines the mesh to bind the material to
  78083. */
  78084. bind(world: Matrix, mesh?: Mesh): void;
  78085. /**
  78086. * Binds the submesh to the material
  78087. * @param world defines the world transformation matrix
  78088. * @param mesh defines the mesh containing the submesh
  78089. * @param subMesh defines the submesh to bind the material to
  78090. */
  78091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78092. /**
  78093. * Binds the world matrix to the material
  78094. * @param world defines the world transformation matrix
  78095. */
  78096. bindOnlyWorldMatrix(world: Matrix): void;
  78097. /**
  78098. * Binds the scene's uniform buffer to the effect.
  78099. * @param effect defines the effect to bind to the scene uniform buffer
  78100. * @param sceneUbo defines the uniform buffer storing scene data
  78101. */
  78102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78103. /**
  78104. * Binds the view matrix to the effect
  78105. * @param effect defines the effect to bind the view matrix to
  78106. */
  78107. bindView(effect: Effect): void;
  78108. /**
  78109. * Binds the view projection matrix to the effect
  78110. * @param effect defines the effect to bind the view projection matrix to
  78111. */
  78112. bindViewProjection(effect: Effect): void;
  78113. /**
  78114. * Specifies if material alpha testing should be turned on for the mesh
  78115. * @param mesh defines the mesh to check
  78116. */
  78117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78118. /**
  78119. * Processes to execute after binding the material to a mesh
  78120. * @param mesh defines the rendered mesh
  78121. */
  78122. protected _afterBind(mesh?: Mesh): void;
  78123. /**
  78124. * Unbinds the material from the mesh
  78125. */
  78126. unbind(): void;
  78127. /**
  78128. * Gets the active textures from the material
  78129. * @returns an array of textures
  78130. */
  78131. getActiveTextures(): BaseTexture[];
  78132. /**
  78133. * Specifies if the material uses a texture
  78134. * @param texture defines the texture to check against the material
  78135. * @returns a boolean specifying if the material uses the texture
  78136. */
  78137. hasTexture(texture: BaseTexture): boolean;
  78138. /**
  78139. * Makes a duplicate of the material, and gives it a new name
  78140. * @param name defines the new name for the duplicated material
  78141. * @returns the cloned material
  78142. */
  78143. clone(name: string): Nullable<Material>;
  78144. /**
  78145. * Gets the meshes bound to the material
  78146. * @returns an array of meshes bound to the material
  78147. */
  78148. getBindedMeshes(): AbstractMesh[];
  78149. /**
  78150. * Force shader compilation
  78151. * @param mesh defines the mesh associated with this material
  78152. * @param onCompiled defines a function to execute once the material is compiled
  78153. * @param options defines the options to configure the compilation
  78154. */
  78155. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78156. clipPlane: boolean;
  78157. }>): void;
  78158. /**
  78159. * Force shader compilation
  78160. * @param mesh defines the mesh that will use this material
  78161. * @param options defines additional options for compiling the shaders
  78162. * @returns a promise that resolves when the compilation completes
  78163. */
  78164. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78165. clipPlane: boolean;
  78166. }>): Promise<void>;
  78167. private static readonly _ImageProcessingDirtyCallBack;
  78168. private static readonly _TextureDirtyCallBack;
  78169. private static readonly _FresnelDirtyCallBack;
  78170. private static readonly _MiscDirtyCallBack;
  78171. private static readonly _LightsDirtyCallBack;
  78172. private static readonly _AttributeDirtyCallBack;
  78173. private static _FresnelAndMiscDirtyCallBack;
  78174. private static _TextureAndMiscDirtyCallBack;
  78175. private static readonly _DirtyCallbackArray;
  78176. private static readonly _RunDirtyCallBacks;
  78177. /**
  78178. * Marks a define in the material to indicate that it needs to be re-computed
  78179. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78180. */
  78181. markAsDirty(flag: number): void;
  78182. /**
  78183. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78184. * @param func defines a function which checks material defines against the submeshes
  78185. */
  78186. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78187. /**
  78188. * Indicates that image processing needs to be re-calculated for all submeshes
  78189. */
  78190. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78191. /**
  78192. * Indicates that textures need to be re-calculated for all submeshes
  78193. */
  78194. protected _markAllSubMeshesAsTexturesDirty(): void;
  78195. /**
  78196. * Indicates that fresnel needs to be re-calculated for all submeshes
  78197. */
  78198. protected _markAllSubMeshesAsFresnelDirty(): void;
  78199. /**
  78200. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78201. */
  78202. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78203. /**
  78204. * Indicates that lights need to be re-calculated for all submeshes
  78205. */
  78206. protected _markAllSubMeshesAsLightsDirty(): void;
  78207. /**
  78208. * Indicates that attributes need to be re-calculated for all submeshes
  78209. */
  78210. protected _markAllSubMeshesAsAttributesDirty(): void;
  78211. /**
  78212. * Indicates that misc needs to be re-calculated for all submeshes
  78213. */
  78214. protected _markAllSubMeshesAsMiscDirty(): void;
  78215. /**
  78216. * Indicates that textures and misc need to be re-calculated for all submeshes
  78217. */
  78218. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78219. /**
  78220. * Disposes the material
  78221. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78222. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78223. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78224. */
  78225. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78226. /** @hidden */
  78227. private releaseVertexArrayObject;
  78228. /**
  78229. * Serializes this material
  78230. * @returns the serialized material object
  78231. */
  78232. serialize(): any;
  78233. /**
  78234. * Creates a material from parsed material data
  78235. * @param parsedMaterial defines parsed material data
  78236. * @param scene defines the hosting scene
  78237. * @param rootUrl defines the root URL to use to load textures
  78238. * @returns a new material
  78239. */
  78240. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78241. }
  78242. }
  78243. declare module BABYLON {
  78244. /**
  78245. * Base class for submeshes
  78246. */
  78247. export class BaseSubMesh {
  78248. /** @hidden */
  78249. _materialDefines: Nullable<MaterialDefines>;
  78250. /** @hidden */
  78251. _materialEffect: Nullable<Effect>;
  78252. /**
  78253. * Gets associated effect
  78254. */
  78255. readonly effect: Nullable<Effect>;
  78256. /**
  78257. * Sets associated effect (effect used to render this submesh)
  78258. * @param effect defines the effect to associate with
  78259. * @param defines defines the set of defines used to compile this effect
  78260. */
  78261. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78262. }
  78263. /**
  78264. * Defines a subdivision inside a mesh
  78265. */
  78266. export class SubMesh extends BaseSubMesh implements ICullable {
  78267. /** the material index to use */
  78268. materialIndex: number;
  78269. /** vertex index start */
  78270. verticesStart: number;
  78271. /** vertices count */
  78272. verticesCount: number;
  78273. /** index start */
  78274. indexStart: number;
  78275. /** indices count */
  78276. indexCount: number;
  78277. /** @hidden */
  78278. _linesIndexCount: number;
  78279. private _mesh;
  78280. private _renderingMesh;
  78281. private _boundingInfo;
  78282. private _linesIndexBuffer;
  78283. /** @hidden */
  78284. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78285. /** @hidden */
  78286. _trianglePlanes: Plane[];
  78287. /** @hidden */
  78288. _lastColliderTransformMatrix: Matrix;
  78289. /** @hidden */
  78290. _renderId: number;
  78291. /** @hidden */
  78292. _alphaIndex: number;
  78293. /** @hidden */
  78294. _distanceToCamera: number;
  78295. /** @hidden */
  78296. _id: number;
  78297. private _currentMaterial;
  78298. /**
  78299. * Add a new submesh to a mesh
  78300. * @param materialIndex defines the material index to use
  78301. * @param verticesStart defines vertex index start
  78302. * @param verticesCount defines vertices count
  78303. * @param indexStart defines index start
  78304. * @param indexCount defines indices count
  78305. * @param mesh defines the parent mesh
  78306. * @param renderingMesh defines an optional rendering mesh
  78307. * @param createBoundingBox defines if bounding box should be created for this submesh
  78308. * @returns the new submesh
  78309. */
  78310. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78311. /**
  78312. * Creates a new submesh
  78313. * @param materialIndex defines the material index to use
  78314. * @param verticesStart defines vertex index start
  78315. * @param verticesCount defines vertices count
  78316. * @param indexStart defines index start
  78317. * @param indexCount defines indices count
  78318. * @param mesh defines the parent mesh
  78319. * @param renderingMesh defines an optional rendering mesh
  78320. * @param createBoundingBox defines if bounding box should be created for this submesh
  78321. */
  78322. constructor(
  78323. /** the material index to use */
  78324. materialIndex: number,
  78325. /** vertex index start */
  78326. verticesStart: number,
  78327. /** vertices count */
  78328. verticesCount: number,
  78329. /** index start */
  78330. indexStart: number,
  78331. /** indices count */
  78332. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78333. /**
  78334. * Returns true if this submesh covers the entire parent mesh
  78335. * @ignorenaming
  78336. */
  78337. readonly IsGlobal: boolean;
  78338. /**
  78339. * Returns the submesh BoudingInfo object
  78340. * @returns current bounding info (or mesh's one if the submesh is global)
  78341. */
  78342. getBoundingInfo(): BoundingInfo;
  78343. /**
  78344. * Sets the submesh BoundingInfo
  78345. * @param boundingInfo defines the new bounding info to use
  78346. * @returns the SubMesh
  78347. */
  78348. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  78349. /**
  78350. * Returns the mesh of the current submesh
  78351. * @return the parent mesh
  78352. */
  78353. getMesh(): AbstractMesh;
  78354. /**
  78355. * Returns the rendering mesh of the submesh
  78356. * @returns the rendering mesh (could be different from parent mesh)
  78357. */
  78358. getRenderingMesh(): Mesh;
  78359. /**
  78360. * Returns the submesh material
  78361. * @returns null or the current material
  78362. */
  78363. getMaterial(): Nullable<Material>;
  78364. /**
  78365. * Sets a new updated BoundingInfo object to the submesh
  78366. * @returns the SubMesh
  78367. */
  78368. refreshBoundingInfo(): SubMesh;
  78369. /** @hidden */
  78370. _checkCollision(collider: Collider): boolean;
  78371. /**
  78372. * Updates the submesh BoundingInfo
  78373. * @param world defines the world matrix to use to update the bounding info
  78374. * @returns the submesh
  78375. */
  78376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  78377. /**
  78378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  78379. * @param frustumPlanes defines the frustum planes
  78380. * @returns true if the submesh is intersecting with the frustum
  78381. */
  78382. isInFrustum(frustumPlanes: Plane[]): boolean;
  78383. /**
  78384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  78385. * @param frustumPlanes defines the frustum planes
  78386. * @returns true if the submesh is inside the frustum
  78387. */
  78388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78389. /**
  78390. * Renders the submesh
  78391. * @param enableAlphaMode defines if alpha needs to be used
  78392. * @returns the submesh
  78393. */
  78394. render(enableAlphaMode: boolean): SubMesh;
  78395. /**
  78396. * @hidden
  78397. */
  78398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  78399. /**
  78400. * Checks if the submesh intersects with a ray
  78401. * @param ray defines the ray to test
  78402. * @returns true is the passed ray intersects the submesh bounding box
  78403. */
  78404. canIntersects(ray: Ray): boolean;
  78405. /**
  78406. * Intersects current submesh with a ray
  78407. * @param ray defines the ray to test
  78408. * @param positions defines mesh's positions array
  78409. * @param indices defines mesh's indices array
  78410. * @param fastCheck defines if only bounding info should be used
  78411. * @returns intersection info or null if no intersection
  78412. */
  78413. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  78414. /** @hidden */
  78415. private _intersectLines;
  78416. /** @hidden */
  78417. private _intersectTriangles;
  78418. /** @hidden */
  78419. _rebuild(): void;
  78420. /**
  78421. * Creates a new submesh from the passed mesh
  78422. * @param newMesh defines the new hosting mesh
  78423. * @param newRenderingMesh defines an optional rendering mesh
  78424. * @returns the new submesh
  78425. */
  78426. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  78427. /**
  78428. * Release associated resources
  78429. */
  78430. dispose(): void;
  78431. /**
  78432. * Gets the class name
  78433. * @returns the string "SubMesh".
  78434. */
  78435. getClassName(): string;
  78436. /**
  78437. * Creates a new submesh from indices data
  78438. * @param materialIndex the index of the main mesh material
  78439. * @param startIndex the index where to start the copy in the mesh indices array
  78440. * @param indexCount the number of indices to copy then from the startIndex
  78441. * @param mesh the main mesh to create the submesh from
  78442. * @param renderingMesh the optional rendering mesh
  78443. * @returns a new submesh
  78444. */
  78445. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  78446. }
  78447. }
  78448. declare module BABYLON {
  78449. /**
  78450. * Class used to store geometry data (vertex buffers + index buffer)
  78451. */
  78452. export class Geometry implements IGetSetVerticesData {
  78453. /**
  78454. * Gets or sets the ID of the geometry
  78455. */
  78456. id: string;
  78457. /**
  78458. * Gets or sets the unique ID of the geometry
  78459. */
  78460. uniqueId: number;
  78461. /**
  78462. * Gets the delay loading state of the geometry (none by default which means not delayed)
  78463. */
  78464. delayLoadState: number;
  78465. /**
  78466. * Gets the file containing the data to load when running in delay load state
  78467. */
  78468. delayLoadingFile: Nullable<string>;
  78469. /**
  78470. * Callback called when the geometry is updated
  78471. */
  78472. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  78473. private _scene;
  78474. private _engine;
  78475. private _meshes;
  78476. private _totalVertices;
  78477. /** @hidden */
  78478. _indices: IndicesArray;
  78479. /** @hidden */
  78480. _vertexBuffers: {
  78481. [key: string]: VertexBuffer;
  78482. };
  78483. private _isDisposed;
  78484. private _extend;
  78485. private _boundingBias;
  78486. /** @hidden */
  78487. _delayInfo: Array<string>;
  78488. private _indexBuffer;
  78489. private _indexBufferIsUpdatable;
  78490. /** @hidden */
  78491. _boundingInfo: Nullable<BoundingInfo>;
  78492. /** @hidden */
  78493. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  78494. /** @hidden */
  78495. _softwareSkinningFrameId: number;
  78496. private _vertexArrayObjects;
  78497. private _updatable;
  78498. /** @hidden */
  78499. _positions: Nullable<Vector3[]>;
  78500. /**
  78501. * 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
  78502. */
  78503. /**
  78504. * 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
  78505. */
  78506. boundingBias: Vector2;
  78507. /**
  78508. * Static function used to attach a new empty geometry to a mesh
  78509. * @param mesh defines the mesh to attach the geometry to
  78510. * @returns the new Geometry
  78511. */
  78512. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  78513. /**
  78514. * Creates a new geometry
  78515. * @param id defines the unique ID
  78516. * @param scene defines the hosting scene
  78517. * @param vertexData defines the VertexData used to get geometry data
  78518. * @param updatable defines if geometry must be updatable (false by default)
  78519. * @param mesh defines the mesh that will be associated with the geometry
  78520. */
  78521. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  78522. /**
  78523. * Gets the current extend of the geometry
  78524. */
  78525. readonly extend: {
  78526. minimum: Vector3;
  78527. maximum: Vector3;
  78528. };
  78529. /**
  78530. * Gets the hosting scene
  78531. * @returns the hosting Scene
  78532. */
  78533. getScene(): Scene;
  78534. /**
  78535. * Gets the hosting engine
  78536. * @returns the hosting Engine
  78537. */
  78538. getEngine(): Engine;
  78539. /**
  78540. * Defines if the geometry is ready to use
  78541. * @returns true if the geometry is ready to be used
  78542. */
  78543. isReady(): boolean;
  78544. /**
  78545. * Gets a value indicating that the geometry should not be serialized
  78546. */
  78547. readonly doNotSerialize: boolean;
  78548. /** @hidden */
  78549. _rebuild(): void;
  78550. /**
  78551. * Affects all geometry data in one call
  78552. * @param vertexData defines the geometry data
  78553. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  78554. */
  78555. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  78556. /**
  78557. * Set specific vertex data
  78558. * @param kind defines the data kind (Position, normal, etc...)
  78559. * @param data defines the vertex data to use
  78560. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78561. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78562. */
  78563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  78564. /**
  78565. * Removes a specific vertex data
  78566. * @param kind defines the data kind (Position, normal, etc...)
  78567. */
  78568. removeVerticesData(kind: string): void;
  78569. /**
  78570. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  78571. * @param buffer defines the vertex buffer to use
  78572. * @param totalVertices defines the total number of vertices for position kind (could be null)
  78573. */
  78574. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  78575. /**
  78576. * Update a specific vertex buffer
  78577. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  78578. * It will do nothing if the buffer is not updatable
  78579. * @param kind defines the data kind (Position, normal, etc...)
  78580. * @param data defines the data to use
  78581. * @param offset defines the offset in the target buffer where to store the data
  78582. * @param useBytes set to true if the offset is in bytes
  78583. */
  78584. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  78585. /**
  78586. * Update a specific vertex buffer
  78587. * This function will create a new buffer if the current one is not updatable
  78588. * @param kind defines the data kind (Position, normal, etc...)
  78589. * @param data defines the data to use
  78590. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  78591. */
  78592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  78593. private _updateBoundingInfo;
  78594. /** @hidden */
  78595. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  78596. /**
  78597. * Gets total number of vertices
  78598. * @returns the total number of vertices
  78599. */
  78600. getTotalVertices(): number;
  78601. /**
  78602. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78603. * @param kind defines the data kind (Position, normal, etc...)
  78604. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78605. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78606. * @returns a float array containing vertex data
  78607. */
  78608. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78609. /**
  78610. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  78611. * @param kind defines the data kind (Position, normal, etc...)
  78612. * @returns true if the vertex buffer with the specified kind is updatable
  78613. */
  78614. isVertexBufferUpdatable(kind: string): boolean;
  78615. /**
  78616. * Gets a specific vertex buffer
  78617. * @param kind defines the data kind (Position, normal, etc...)
  78618. * @returns a VertexBuffer
  78619. */
  78620. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78621. /**
  78622. * Returns all vertex buffers
  78623. * @return an object holding all vertex buffers indexed by kind
  78624. */
  78625. getVertexBuffers(): Nullable<{
  78626. [key: string]: VertexBuffer;
  78627. }>;
  78628. /**
  78629. * Gets a boolean indicating if specific vertex buffer is present
  78630. * @param kind defines the data kind (Position, normal, etc...)
  78631. * @returns true if data is present
  78632. */
  78633. isVerticesDataPresent(kind: string): boolean;
  78634. /**
  78635. * Gets a list of all attached data kinds (Position, normal, etc...)
  78636. * @returns a list of string containing all kinds
  78637. */
  78638. getVerticesDataKinds(): string[];
  78639. /**
  78640. * Update index buffer
  78641. * @param indices defines the indices to store in the index buffer
  78642. * @param offset defines the offset in the target buffer where to store the data
  78643. */
  78644. updateIndices(indices: IndicesArray, offset?: number): void;
  78645. /**
  78646. * Creates a new index buffer
  78647. * @param indices defines the indices to store in the index buffer
  78648. * @param totalVertices defines the total number of vertices (could be null)
  78649. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78650. */
  78651. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  78652. /**
  78653. * Return the total number of indices
  78654. * @returns the total number of indices
  78655. */
  78656. getTotalIndices(): number;
  78657. /**
  78658. * Gets the index buffer array
  78659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78661. * @returns the index buffer array
  78662. */
  78663. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78664. /**
  78665. * Gets the index buffer
  78666. * @return the index buffer
  78667. */
  78668. getIndexBuffer(): Nullable<WebGLBuffer>;
  78669. /** @hidden */
  78670. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  78671. /**
  78672. * Release the associated resources for a specific mesh
  78673. * @param mesh defines the source mesh
  78674. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  78675. */
  78676. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  78677. /**
  78678. * Apply current geometry to a given mesh
  78679. * @param mesh defines the mesh to apply geometry to
  78680. */
  78681. applyToMesh(mesh: Mesh): void;
  78682. private _updateExtend;
  78683. private _applyToMesh;
  78684. private notifyUpdate;
  78685. /**
  78686. * Load the geometry if it was flagged as delay loaded
  78687. * @param scene defines the hosting scene
  78688. * @param onLoaded defines a callback called when the geometry is loaded
  78689. */
  78690. load(scene: Scene, onLoaded?: () => void): void;
  78691. private _queueLoad;
  78692. /**
  78693. * Invert the geometry to move from a right handed system to a left handed one.
  78694. */
  78695. toLeftHanded(): void;
  78696. /** @hidden */
  78697. _resetPointsArrayCache(): void;
  78698. /** @hidden */
  78699. _generatePointsArray(): boolean;
  78700. /**
  78701. * Gets a value indicating if the geometry is disposed
  78702. * @returns true if the geometry was disposed
  78703. */
  78704. isDisposed(): boolean;
  78705. private _disposeVertexArrayObjects;
  78706. /**
  78707. * Free all associated resources
  78708. */
  78709. dispose(): void;
  78710. /**
  78711. * Clone the current geometry into a new geometry
  78712. * @param id defines the unique ID of the new geometry
  78713. * @returns a new geometry object
  78714. */
  78715. copy(id: string): Geometry;
  78716. /**
  78717. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78718. * @return a JSON representation of the current geometry data (without the vertices data)
  78719. */
  78720. serialize(): any;
  78721. private toNumberArray;
  78722. /**
  78723. * Serialize all vertices data into a JSON oject
  78724. * @returns a JSON representation of the current geometry data
  78725. */
  78726. serializeVerticeData(): any;
  78727. /**
  78728. * Extracts a clone of a mesh geometry
  78729. * @param mesh defines the source mesh
  78730. * @param id defines the unique ID of the new geometry object
  78731. * @returns the new geometry object
  78732. */
  78733. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  78734. /**
  78735. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78736. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78737. * Be aware Math.random() could cause collisions, but:
  78738. * "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"
  78739. * @returns a string containing a new GUID
  78740. */
  78741. static RandomId(): string;
  78742. /** @hidden */
  78743. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  78744. private static _CleanMatricesWeights;
  78745. /**
  78746. * Create a new geometry from persisted data (Using .babylon file format)
  78747. * @param parsedVertexData defines the persisted data
  78748. * @param scene defines the hosting scene
  78749. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78750. * @returns the new geometry object
  78751. */
  78752. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  78753. }
  78754. }
  78755. declare module BABYLON {
  78756. /**
  78757. * Define an interface for all classes that will get and set the data on vertices
  78758. */
  78759. export interface IGetSetVerticesData {
  78760. /**
  78761. * Gets a boolean indicating if specific vertex data is present
  78762. * @param kind defines the vertex data kind to use
  78763. * @returns true is data kind is present
  78764. */
  78765. isVerticesDataPresent(kind: string): boolean;
  78766. /**
  78767. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78768. * @param kind defines the data kind (Position, normal, etc...)
  78769. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78770. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78771. * @returns a float array containing vertex data
  78772. */
  78773. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78774. /**
  78775. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78776. * @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.
  78777. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78778. * @returns the indices array or an empty array if the mesh has no geometry
  78779. */
  78780. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78781. /**
  78782. * Set specific vertex data
  78783. * @param kind defines the data kind (Position, normal, etc...)
  78784. * @param data defines the vertex data to use
  78785. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78786. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78787. */
  78788. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  78789. /**
  78790. * Update a specific associated vertex buffer
  78791. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78792. * - VertexBuffer.PositionKind
  78793. * - VertexBuffer.UVKind
  78794. * - VertexBuffer.UV2Kind
  78795. * - VertexBuffer.UV3Kind
  78796. * - VertexBuffer.UV4Kind
  78797. * - VertexBuffer.UV5Kind
  78798. * - VertexBuffer.UV6Kind
  78799. * - VertexBuffer.ColorKind
  78800. * - VertexBuffer.MatricesIndicesKind
  78801. * - VertexBuffer.MatricesIndicesExtraKind
  78802. * - VertexBuffer.MatricesWeightsKind
  78803. * - VertexBuffer.MatricesWeightsExtraKind
  78804. * @param data defines the data source
  78805. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78806. * @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)
  78807. */
  78808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  78809. /**
  78810. * Creates a new index buffer
  78811. * @param indices defines the indices to store in the index buffer
  78812. * @param totalVertices defines the total number of vertices (could be null)
  78813. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78814. */
  78815. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  78816. }
  78817. /**
  78818. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  78819. */
  78820. export class VertexData {
  78821. /**
  78822. * Mesh side orientation : usually the external or front surface
  78823. */
  78824. static readonly FRONTSIDE: number;
  78825. /**
  78826. * Mesh side orientation : usually the internal or back surface
  78827. */
  78828. static readonly BACKSIDE: number;
  78829. /**
  78830. * Mesh side orientation : both internal and external or front and back surfaces
  78831. */
  78832. static readonly DOUBLESIDE: number;
  78833. /**
  78834. * Mesh side orientation : by default, `FRONTSIDE`
  78835. */
  78836. static readonly DEFAULTSIDE: number;
  78837. /**
  78838. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  78839. */
  78840. positions: Nullable<FloatArray>;
  78841. /**
  78842. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  78843. */
  78844. normals: Nullable<FloatArray>;
  78845. /**
  78846. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  78847. */
  78848. tangents: Nullable<FloatArray>;
  78849. /**
  78850. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78851. */
  78852. uvs: Nullable<FloatArray>;
  78853. /**
  78854. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78855. */
  78856. uvs2: Nullable<FloatArray>;
  78857. /**
  78858. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78859. */
  78860. uvs3: Nullable<FloatArray>;
  78861. /**
  78862. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78863. */
  78864. uvs4: Nullable<FloatArray>;
  78865. /**
  78866. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78867. */
  78868. uvs5: Nullable<FloatArray>;
  78869. /**
  78870. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78871. */
  78872. uvs6: Nullable<FloatArray>;
  78873. /**
  78874. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  78875. */
  78876. colors: Nullable<FloatArray>;
  78877. /**
  78878. * 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).
  78879. */
  78880. matricesIndices: Nullable<FloatArray>;
  78881. /**
  78882. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  78883. */
  78884. matricesWeights: Nullable<FloatArray>;
  78885. /**
  78886. * An array extending the number of possible indices
  78887. */
  78888. matricesIndicesExtra: Nullable<FloatArray>;
  78889. /**
  78890. * An array extending the number of possible weights when the number of indices is extended
  78891. */
  78892. matricesWeightsExtra: Nullable<FloatArray>;
  78893. /**
  78894. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  78895. */
  78896. indices: Nullable<IndicesArray>;
  78897. /**
  78898. * Uses the passed data array to set the set the values for the specified kind of data
  78899. * @param data a linear array of floating numbers
  78900. * @param kind the type of data that is being set, eg positions, colors etc
  78901. */
  78902. set(data: FloatArray, kind: string): void;
  78903. /**
  78904. * Associates the vertexData to the passed Mesh.
  78905. * Sets it as updatable or not (default `false`)
  78906. * @param mesh the mesh the vertexData is applied to
  78907. * @param updatable when used and having the value true allows new data to update the vertexData
  78908. * @returns the VertexData
  78909. */
  78910. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  78911. /**
  78912. * Associates the vertexData to the passed Geometry.
  78913. * Sets it as updatable or not (default `false`)
  78914. * @param geometry the geometry the vertexData is applied to
  78915. * @param updatable when used and having the value true allows new data to update the vertexData
  78916. * @returns VertexData
  78917. */
  78918. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  78919. /**
  78920. * Updates the associated mesh
  78921. * @param mesh the mesh to be updated
  78922. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78923. * @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
  78924. * @returns VertexData
  78925. */
  78926. updateMesh(mesh: Mesh): VertexData;
  78927. /**
  78928. * Updates the associated geometry
  78929. * @param geometry the geometry to be updated
  78930. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78931. * @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
  78932. * @returns VertexData.
  78933. */
  78934. updateGeometry(geometry: Geometry): VertexData;
  78935. private _applyTo;
  78936. private _update;
  78937. /**
  78938. * Transforms each position and each normal of the vertexData according to the passed Matrix
  78939. * @param matrix the transforming matrix
  78940. * @returns the VertexData
  78941. */
  78942. transform(matrix: Matrix): VertexData;
  78943. /**
  78944. * Merges the passed VertexData into the current one
  78945. * @param other the VertexData to be merged into the current one
  78946. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  78947. * @returns the modified VertexData
  78948. */
  78949. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  78950. private _mergeElement;
  78951. private _validate;
  78952. /**
  78953. * Serializes the VertexData
  78954. * @returns a serialized object
  78955. */
  78956. serialize(): any;
  78957. /**
  78958. * Extracts the vertexData from a mesh
  78959. * @param mesh the mesh from which to extract the VertexData
  78960. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  78961. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78962. * @returns the object VertexData associated to the passed mesh
  78963. */
  78964. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78965. /**
  78966. * Extracts the vertexData from the geometry
  78967. * @param geometry the geometry from which to extract the VertexData
  78968. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  78969. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78970. * @returns the object VertexData associated to the passed mesh
  78971. */
  78972. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78973. private static _ExtractFrom;
  78974. /**
  78975. * Creates the VertexData for a Ribbon
  78976. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  78977. * * pathArray array of paths, each of which an array of successive Vector3
  78978. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  78979. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  78980. * * 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
  78981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78982. * * 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)
  78983. * * 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)
  78984. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  78985. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  78986. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  78987. * @returns the VertexData of the ribbon
  78988. */
  78989. static CreateRibbon(options: {
  78990. pathArray: Vector3[][];
  78991. closeArray?: boolean;
  78992. closePath?: boolean;
  78993. offset?: number;
  78994. sideOrientation?: number;
  78995. frontUVs?: Vector4;
  78996. backUVs?: Vector4;
  78997. invertUV?: boolean;
  78998. uvs?: Vector2[];
  78999. colors?: Color4[];
  79000. }): VertexData;
  79001. /**
  79002. * Creates the VertexData for a box
  79003. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79004. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79005. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79006. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79007. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79008. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79009. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79011. * * 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)
  79012. * * 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)
  79013. * @returns the VertexData of the box
  79014. */
  79015. static CreateBox(options: {
  79016. size?: number;
  79017. width?: number;
  79018. height?: number;
  79019. depth?: number;
  79020. faceUV?: Vector4[];
  79021. faceColors?: Color4[];
  79022. sideOrientation?: number;
  79023. frontUVs?: Vector4;
  79024. backUVs?: Vector4;
  79025. }): VertexData;
  79026. /**
  79027. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79029. * * segments sets the number of horizontal strips optional, default 32
  79030. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79031. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79032. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79033. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79034. * * 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
  79035. * * 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
  79036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79037. * * 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)
  79038. * * 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)
  79039. * @returns the VertexData of the ellipsoid
  79040. */
  79041. static CreateSphere(options: {
  79042. segments?: number;
  79043. diameter?: number;
  79044. diameterX?: number;
  79045. diameterY?: number;
  79046. diameterZ?: number;
  79047. arc?: number;
  79048. slice?: number;
  79049. sideOrientation?: number;
  79050. frontUVs?: Vector4;
  79051. backUVs?: Vector4;
  79052. }): VertexData;
  79053. /**
  79054. * Creates the VertexData for a cylinder, cone or prism
  79055. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79056. * * height sets the height (y direction) of the cylinder, optional, default 2
  79057. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79058. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79059. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79060. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79061. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79062. * * 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
  79063. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79064. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79065. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79066. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79068. * * 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)
  79069. * * 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)
  79070. * @returns the VertexData of the cylinder, cone or prism
  79071. */
  79072. static CreateCylinder(options: {
  79073. height?: number;
  79074. diameterTop?: number;
  79075. diameterBottom?: number;
  79076. diameter?: number;
  79077. tessellation?: number;
  79078. subdivisions?: number;
  79079. arc?: number;
  79080. faceColors?: Color4[];
  79081. faceUV?: Vector4[];
  79082. hasRings?: boolean;
  79083. enclose?: boolean;
  79084. sideOrientation?: number;
  79085. frontUVs?: Vector4;
  79086. backUVs?: Vector4;
  79087. }): VertexData;
  79088. /**
  79089. * Creates the VertexData for a torus
  79090. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79091. * * diameter the diameter of the torus, optional default 1
  79092. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79093. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79095. * * 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)
  79096. * * 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)
  79097. * @returns the VertexData of the torus
  79098. */
  79099. static CreateTorus(options: {
  79100. diameter?: number;
  79101. thickness?: number;
  79102. tessellation?: number;
  79103. sideOrientation?: number;
  79104. frontUVs?: Vector4;
  79105. backUVs?: Vector4;
  79106. }): VertexData;
  79107. /**
  79108. * Creates the VertexData of the LineSystem
  79109. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79110. * - lines an array of lines, each line being an array of successive Vector3
  79111. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79112. * @returns the VertexData of the LineSystem
  79113. */
  79114. static CreateLineSystem(options: {
  79115. lines: Vector3[][];
  79116. colors?: Nullable<Color4[][]>;
  79117. }): VertexData;
  79118. /**
  79119. * Create the VertexData for a DashedLines
  79120. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79121. * - points an array successive Vector3
  79122. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79123. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79124. * - dashNb the intended total number of dashes, optional, default 200
  79125. * @returns the VertexData for the DashedLines
  79126. */
  79127. static CreateDashedLines(options: {
  79128. points: Vector3[];
  79129. dashSize?: number;
  79130. gapSize?: number;
  79131. dashNb?: number;
  79132. }): VertexData;
  79133. /**
  79134. * Creates the VertexData for a Ground
  79135. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79136. * - width the width (x direction) of the ground, optional, default 1
  79137. * - height the height (z direction) of the ground, optional, default 1
  79138. * - subdivisions the number of subdivisions per side, optional, default 1
  79139. * @returns the VertexData of the Ground
  79140. */
  79141. static CreateGround(options: {
  79142. width?: number;
  79143. height?: number;
  79144. subdivisions?: number;
  79145. subdivisionsX?: number;
  79146. subdivisionsY?: number;
  79147. }): VertexData;
  79148. /**
  79149. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79150. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79151. * * xmin the ground minimum X coordinate, optional, default -1
  79152. * * zmin the ground minimum Z coordinate, optional, default -1
  79153. * * xmax the ground maximum X coordinate, optional, default 1
  79154. * * zmax the ground maximum Z coordinate, optional, default 1
  79155. * * 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}
  79156. * * 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}
  79157. * @returns the VertexData of the TiledGround
  79158. */
  79159. static CreateTiledGround(options: {
  79160. xmin: number;
  79161. zmin: number;
  79162. xmax: number;
  79163. zmax: number;
  79164. subdivisions?: {
  79165. w: number;
  79166. h: number;
  79167. };
  79168. precision?: {
  79169. w: number;
  79170. h: number;
  79171. };
  79172. }): VertexData;
  79173. /**
  79174. * Creates the VertexData of the Ground designed from a heightmap
  79175. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79176. * * width the width (x direction) of the ground
  79177. * * height the height (z direction) of the ground
  79178. * * subdivisions the number of subdivisions per side
  79179. * * minHeight the minimum altitude on the ground, optional, default 0
  79180. * * maxHeight the maximum altitude on the ground, optional default 1
  79181. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79182. * * buffer the array holding the image color data
  79183. * * bufferWidth the width of image
  79184. * * bufferHeight the height of image
  79185. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79186. * @returns the VertexData of the Ground designed from a heightmap
  79187. */
  79188. static CreateGroundFromHeightMap(options: {
  79189. width: number;
  79190. height: number;
  79191. subdivisions: number;
  79192. minHeight: number;
  79193. maxHeight: number;
  79194. colorFilter: Color3;
  79195. buffer: Uint8Array;
  79196. bufferWidth: number;
  79197. bufferHeight: number;
  79198. alphaFilter: number;
  79199. }): VertexData;
  79200. /**
  79201. * Creates the VertexData for a Plane
  79202. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79203. * * size sets the width and height of the plane to the value of size, optional default 1
  79204. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79205. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79207. * * 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)
  79208. * * 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)
  79209. * @returns the VertexData of the box
  79210. */
  79211. static CreatePlane(options: {
  79212. size?: number;
  79213. width?: number;
  79214. height?: number;
  79215. sideOrientation?: number;
  79216. frontUVs?: Vector4;
  79217. backUVs?: Vector4;
  79218. }): VertexData;
  79219. /**
  79220. * Creates the VertexData of the Disc or regular Polygon
  79221. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79222. * * radius the radius of the disc, optional default 0.5
  79223. * * tessellation the number of polygon sides, optional, default 64
  79224. * * 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
  79225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79226. * * 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)
  79227. * * 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)
  79228. * @returns the VertexData of the box
  79229. */
  79230. static CreateDisc(options: {
  79231. radius?: number;
  79232. tessellation?: number;
  79233. arc?: number;
  79234. sideOrientation?: number;
  79235. frontUVs?: Vector4;
  79236. backUVs?: Vector4;
  79237. }): VertexData;
  79238. /**
  79239. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79240. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79241. * @param polygon a mesh built from polygonTriangulation.build()
  79242. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79243. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79244. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79245. * @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)
  79246. * @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)
  79247. * @returns the VertexData of the Polygon
  79248. */
  79249. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79250. /**
  79251. * Creates the VertexData of the IcoSphere
  79252. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79253. * * radius the radius of the IcoSphere, optional default 1
  79254. * * radiusX allows stretching in the x direction, optional, default radius
  79255. * * radiusY allows stretching in the y direction, optional, default radius
  79256. * * radiusZ allows stretching in the z direction, optional, default radius
  79257. * * flat when true creates a flat shaded mesh, optional, default true
  79258. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79260. * * 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)
  79261. * * 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)
  79262. * @returns the VertexData of the IcoSphere
  79263. */
  79264. static CreateIcoSphere(options: {
  79265. radius?: number;
  79266. radiusX?: number;
  79267. radiusY?: number;
  79268. radiusZ?: number;
  79269. flat?: boolean;
  79270. subdivisions?: number;
  79271. sideOrientation?: number;
  79272. frontUVs?: Vector4;
  79273. backUVs?: Vector4;
  79274. }): VertexData;
  79275. /**
  79276. * Creates the VertexData for a Polyhedron
  79277. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79278. * * type provided types are:
  79279. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79280. * * 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)
  79281. * * size the size of the IcoSphere, optional default 1
  79282. * * sizeX allows stretching in the x direction, optional, default size
  79283. * * sizeY allows stretching in the y direction, optional, default size
  79284. * * sizeZ allows stretching in the z direction, optional, default size
  79285. * * 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
  79286. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79287. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79288. * * flat when true creates a flat shaded mesh, optional, default true
  79289. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79291. * * 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)
  79292. * * 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)
  79293. * @returns the VertexData of the Polyhedron
  79294. */
  79295. static CreatePolyhedron(options: {
  79296. type?: number;
  79297. size?: number;
  79298. sizeX?: number;
  79299. sizeY?: number;
  79300. sizeZ?: number;
  79301. custom?: any;
  79302. faceUV?: Vector4[];
  79303. faceColors?: Color4[];
  79304. flat?: boolean;
  79305. sideOrientation?: number;
  79306. frontUVs?: Vector4;
  79307. backUVs?: Vector4;
  79308. }): VertexData;
  79309. /**
  79310. * Creates the VertexData for a TorusKnot
  79311. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79312. * * radius the radius of the torus knot, optional, default 2
  79313. * * tube the thickness of the tube, optional, default 0.5
  79314. * * radialSegments the number of sides on each tube segments, optional, default 32
  79315. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79316. * * p the number of windings around the z axis, optional, default 2
  79317. * * q the number of windings around the x axis, optional, default 3
  79318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79319. * * 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)
  79320. * * 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)
  79321. * @returns the VertexData of the Torus Knot
  79322. */
  79323. static CreateTorusKnot(options: {
  79324. radius?: number;
  79325. tube?: number;
  79326. radialSegments?: number;
  79327. tubularSegments?: number;
  79328. p?: number;
  79329. q?: number;
  79330. sideOrientation?: number;
  79331. frontUVs?: Vector4;
  79332. backUVs?: Vector4;
  79333. }): VertexData;
  79334. /**
  79335. * Compute normals for given positions and indices
  79336. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79337. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79338. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79339. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79340. * * facetNormals : optional array of facet normals (vector3)
  79341. * * facetPositions : optional array of facet positions (vector3)
  79342. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79343. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79344. * * bInfo : optional bounding info, required for facetPartitioning computation
  79345. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79346. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  79347. * * useRightHandedSystem: optional boolean to for right handed system computation
  79348. * * depthSort : optional boolean to enable the facet depth sort computation
  79349. * * distanceTo : optional Vector3 to compute the facet depth from this location
  79350. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  79351. */
  79352. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  79353. facetNormals?: any;
  79354. facetPositions?: any;
  79355. facetPartitioning?: any;
  79356. ratio?: number;
  79357. bInfo?: any;
  79358. bbSize?: Vector3;
  79359. subDiv?: any;
  79360. useRightHandedSystem?: boolean;
  79361. depthSort?: boolean;
  79362. distanceTo?: Vector3;
  79363. depthSortedFacets?: any;
  79364. }): void;
  79365. /** @hidden */
  79366. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  79367. /**
  79368. * Applies VertexData created from the imported parameters to the geometry
  79369. * @param parsedVertexData the parsed data from an imported file
  79370. * @param geometry the geometry to apply the VertexData to
  79371. */
  79372. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  79373. }
  79374. }
  79375. declare module BABYLON {
  79376. /**
  79377. * Class containing static functions to help procedurally build meshes
  79378. */
  79379. export class DiscBuilder {
  79380. /**
  79381. * Creates a plane polygonal mesh. By default, this is a disc
  79382. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79383. * * 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
  79384. * * 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
  79385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79388. * @param name defines the name of the mesh
  79389. * @param options defines the options used to create the mesh
  79390. * @param scene defines the hosting scene
  79391. * @returns the plane polygonal mesh
  79392. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79393. */
  79394. static CreateDisc(name: string, options: {
  79395. radius?: number;
  79396. tessellation?: number;
  79397. arc?: number;
  79398. updatable?: boolean;
  79399. sideOrientation?: number;
  79400. frontUVs?: Vector4;
  79401. backUVs?: Vector4;
  79402. }, scene?: Nullable<Scene>): Mesh;
  79403. }
  79404. }
  79405. declare module BABYLON {
  79406. /**
  79407. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  79408. *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.
  79409. * The SPS is also a particle system. It provides some methods to manage the particles.
  79410. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  79411. *
  79412. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  79413. */
  79414. export class SolidParticleSystem implements IDisposable {
  79415. /**
  79416. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  79417. * Example : var p = SPS.particles[i];
  79418. */
  79419. particles: SolidParticle[];
  79420. /**
  79421. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  79422. */
  79423. nbParticles: number;
  79424. /**
  79425. * If the particles must ever face the camera (default false). Useful for planar particles.
  79426. */
  79427. billboard: boolean;
  79428. /**
  79429. * Recompute normals when adding a shape
  79430. */
  79431. recomputeNormals: boolean;
  79432. /**
  79433. * This a counter ofr your own usage. It's not set by any SPS functions.
  79434. */
  79435. counter: number;
  79436. /**
  79437. * The SPS name. This name is also given to the underlying mesh.
  79438. */
  79439. name: string;
  79440. /**
  79441. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  79442. */
  79443. mesh: Mesh;
  79444. /**
  79445. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  79446. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  79447. */
  79448. vars: any;
  79449. /**
  79450. * This array is populated when the SPS is set as 'pickable'.
  79451. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  79452. * Each element of this array is an object `{idx: int, faceId: int}`.
  79453. * `idx` is the picked particle index in the `SPS.particles` array
  79454. * `faceId` is the picked face index counted within this particle.
  79455. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  79456. */
  79457. pickedParticles: {
  79458. idx: number;
  79459. faceId: number;
  79460. }[];
  79461. /**
  79462. * This array is populated when `enableDepthSort` is set to true.
  79463. * Each element of this array is an instance of the class DepthSortedParticle.
  79464. */
  79465. depthSortedParticles: DepthSortedParticle[];
  79466. /**
  79467. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  79468. * @hidden
  79469. */
  79470. _bSphereOnly: boolean;
  79471. /**
  79472. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  79473. * @hidden
  79474. */
  79475. _bSphereRadiusFactor: number;
  79476. private _scene;
  79477. private _positions;
  79478. private _indices;
  79479. private _normals;
  79480. private _colors;
  79481. private _uvs;
  79482. private _indices32;
  79483. private _positions32;
  79484. private _normals32;
  79485. private _fixedNormal32;
  79486. private _colors32;
  79487. private _uvs32;
  79488. private _index;
  79489. private _updatable;
  79490. private _pickable;
  79491. private _isVisibilityBoxLocked;
  79492. private _alwaysVisible;
  79493. private _depthSort;
  79494. private _shapeCounter;
  79495. private _copy;
  79496. private _color;
  79497. private _computeParticleColor;
  79498. private _computeParticleTexture;
  79499. private _computeParticleRotation;
  79500. private _computeParticleVertex;
  79501. private _computeBoundingBox;
  79502. private _depthSortParticles;
  79503. private _camera;
  79504. private _mustUnrotateFixedNormals;
  79505. private _particlesIntersect;
  79506. private _needs32Bits;
  79507. /**
  79508. * Creates a SPS (Solid Particle System) object.
  79509. * @param name (String) is the SPS name, this will be the underlying mesh name.
  79510. * @param scene (Scene) is the scene in which the SPS is added.
  79511. * @param options defines the options of the sps e.g.
  79512. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  79513. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  79514. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  79515. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  79516. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  79517. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  79518. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  79519. */
  79520. constructor(name: string, scene: Scene, options?: {
  79521. updatable?: boolean;
  79522. isPickable?: boolean;
  79523. enableDepthSort?: boolean;
  79524. particleIntersection?: boolean;
  79525. boundingSphereOnly?: boolean;
  79526. bSphereRadiusFactor?: number;
  79527. });
  79528. /**
  79529. * Builds the SPS underlying mesh. Returns a standard Mesh.
  79530. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  79531. * @returns the created mesh
  79532. */
  79533. buildMesh(): Mesh;
  79534. /**
  79535. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  79536. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  79537. * Thus the particles generated from `digest()` have their property `position` set yet.
  79538. * @param mesh ( Mesh ) is the mesh to be digested
  79539. * @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
  79540. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  79541. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  79542. * @returns the current SPS
  79543. */
  79544. digest(mesh: Mesh, options?: {
  79545. facetNb?: number;
  79546. number?: number;
  79547. delta?: number;
  79548. }): SolidParticleSystem;
  79549. private _unrotateFixedNormals;
  79550. private _resetCopy;
  79551. private _meshBuilder;
  79552. private _posToShape;
  79553. private _uvsToShapeUV;
  79554. private _addParticle;
  79555. /**
  79556. * Adds some particles to the SPS from the model shape. Returns the shape id.
  79557. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  79558. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  79559. * @param nb (positive integer) the number of particles to be created from this model
  79560. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  79561. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  79562. * @returns the number of shapes in the system
  79563. */
  79564. addShape(mesh: Mesh, nb: number, options?: {
  79565. positionFunction?: any;
  79566. vertexFunction?: any;
  79567. }): number;
  79568. private _rebuildParticle;
  79569. /**
  79570. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  79571. * @returns the SPS.
  79572. */
  79573. rebuildMesh(): SolidParticleSystem;
  79574. /**
  79575. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  79576. * This method calls `updateParticle()` for each particle of the SPS.
  79577. * For an animated SPS, it is usually called within the render loop.
  79578. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  79579. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  79580. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  79581. * @returns the SPS.
  79582. */
  79583. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  79584. /**
  79585. * Disposes the SPS.
  79586. */
  79587. dispose(): void;
  79588. /**
  79589. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  79590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79591. * @returns the SPS.
  79592. */
  79593. refreshVisibleSize(): SolidParticleSystem;
  79594. /**
  79595. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  79596. * @param size the size (float) of the visibility box
  79597. * note : this doesn't lock the SPS mesh bounding box.
  79598. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79599. */
  79600. setVisibilityBox(size: number): void;
  79601. /**
  79602. * Gets whether the SPS as always visible or not
  79603. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79604. */
  79605. /**
  79606. * Sets the SPS as always visible or not
  79607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79608. */
  79609. isAlwaysVisible: boolean;
  79610. /**
  79611. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79612. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79613. */
  79614. /**
  79615. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79616. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79617. */
  79618. isVisibilityBoxLocked: boolean;
  79619. /**
  79620. * Tells to `setParticles()` to compute the particle rotations or not.
  79621. * Default value : true. The SPS is faster when it's set to false.
  79622. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79623. */
  79624. /**
  79625. * Gets if `setParticles()` computes the particle rotations or not.
  79626. * Default value : true. The SPS is faster when it's set to false.
  79627. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79628. */
  79629. computeParticleRotation: boolean;
  79630. /**
  79631. * Tells to `setParticles()` to compute the particle colors or not.
  79632. * Default value : true. The SPS is faster when it's set to false.
  79633. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79634. */
  79635. /**
  79636. * Gets if `setParticles()` computes the particle colors or not.
  79637. * Default value : true. The SPS is faster when it's set to false.
  79638. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79639. */
  79640. computeParticleColor: boolean;
  79641. /**
  79642. * Gets if `setParticles()` computes the particle textures or not.
  79643. * Default value : true. The SPS is faster when it's set to false.
  79644. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  79645. */
  79646. computeParticleTexture: boolean;
  79647. /**
  79648. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  79649. * Default value : false. The SPS is faster when it's set to false.
  79650. * Note : the particle custom vertex positions aren't stored values.
  79651. */
  79652. /**
  79653. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  79654. * Default value : false. The SPS is faster when it's set to false.
  79655. * Note : the particle custom vertex positions aren't stored values.
  79656. */
  79657. computeParticleVertex: boolean;
  79658. /**
  79659. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  79660. */
  79661. /**
  79662. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  79663. */
  79664. computeBoundingBox: boolean;
  79665. /**
  79666. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  79667. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79668. * Default : `true`
  79669. */
  79670. /**
  79671. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  79672. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79673. * Default : `true`
  79674. */
  79675. depthSortParticles: boolean;
  79676. /**
  79677. * This function does nothing. It may be overwritten to set all the particle first values.
  79678. * The SPS doesn't call this function, you may have to call it by your own.
  79679. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79680. */
  79681. initParticles(): void;
  79682. /**
  79683. * This function does nothing. It may be overwritten to recycle a particle.
  79684. * The SPS doesn't call this function, you may have to call it by your own.
  79685. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79686. * @param particle The particle to recycle
  79687. * @returns the recycled particle
  79688. */
  79689. recycleParticle(particle: SolidParticle): SolidParticle;
  79690. /**
  79691. * Updates a particle : this function should be overwritten by the user.
  79692. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  79693. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79694. * @example : just set a particle position or velocity and recycle conditions
  79695. * @param particle The particle to update
  79696. * @returns the updated particle
  79697. */
  79698. updateParticle(particle: SolidParticle): SolidParticle;
  79699. /**
  79700. * Updates a vertex of a particle : it can be overwritten by the user.
  79701. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  79702. * @param particle the current particle
  79703. * @param vertex the current index of the current particle
  79704. * @param pt the index of the current vertex in the particle shape
  79705. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  79706. * @example : just set a vertex particle position
  79707. * @returns the updated vertex
  79708. */
  79709. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  79710. /**
  79711. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  79712. * This does nothing and may be overwritten by the user.
  79713. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79714. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79715. * @param update the boolean update value actually passed to setParticles()
  79716. */
  79717. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79718. /**
  79719. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  79720. * This will be passed three parameters.
  79721. * This does nothing and may be overwritten by the user.
  79722. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79723. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79724. * @param update the boolean update value actually passed to setParticles()
  79725. */
  79726. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79727. }
  79728. }
  79729. declare module BABYLON {
  79730. /**
  79731. * Represents one particle of a solid particle system.
  79732. */
  79733. export class SolidParticle {
  79734. /**
  79735. * particle global index
  79736. */
  79737. idx: number;
  79738. /**
  79739. * The color of the particle
  79740. */
  79741. color: Nullable<Color4>;
  79742. /**
  79743. * The world space position of the particle.
  79744. */
  79745. position: Vector3;
  79746. /**
  79747. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  79748. */
  79749. rotation: Vector3;
  79750. /**
  79751. * The world space rotation quaternion of the particle.
  79752. */
  79753. rotationQuaternion: Nullable<Quaternion>;
  79754. /**
  79755. * The scaling of the particle.
  79756. */
  79757. scaling: Vector3;
  79758. /**
  79759. * The uvs of the particle.
  79760. */
  79761. uvs: Vector4;
  79762. /**
  79763. * The current speed of the particle.
  79764. */
  79765. velocity: Vector3;
  79766. /**
  79767. * The pivot point in the particle local space.
  79768. */
  79769. pivot: Vector3;
  79770. /**
  79771. * Must the particle be translated from its pivot point in its local space ?
  79772. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  79773. * Default : false
  79774. */
  79775. translateFromPivot: boolean;
  79776. /**
  79777. * Is the particle active or not ?
  79778. */
  79779. alive: boolean;
  79780. /**
  79781. * Is the particle visible or not ?
  79782. */
  79783. isVisible: boolean;
  79784. /**
  79785. * Index of this particle in the global "positions" array (Internal use)
  79786. * @hidden
  79787. */
  79788. _pos: number;
  79789. /**
  79790. * @hidden Index of this particle in the global "indices" array (Internal use)
  79791. */
  79792. _ind: number;
  79793. /**
  79794. * @hidden ModelShape of this particle (Internal use)
  79795. */
  79796. _model: ModelShape;
  79797. /**
  79798. * ModelShape id of this particle
  79799. */
  79800. shapeId: number;
  79801. /**
  79802. * Index of the particle in its shape id (Internal use)
  79803. */
  79804. idxInShape: number;
  79805. /**
  79806. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  79807. */
  79808. _modelBoundingInfo: BoundingInfo;
  79809. /**
  79810. * @hidden Particle BoundingInfo object (Internal use)
  79811. */
  79812. _boundingInfo: BoundingInfo;
  79813. /**
  79814. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  79815. */
  79816. _sps: SolidParticleSystem;
  79817. /**
  79818. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  79819. */
  79820. _stillInvisible: boolean;
  79821. /**
  79822. * @hidden Last computed particle rotation matrix
  79823. */
  79824. _rotationMatrix: number[];
  79825. /**
  79826. * Parent particle Id, if any.
  79827. * Default null.
  79828. */
  79829. parentId: Nullable<number>;
  79830. /**
  79831. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  79832. * The possible values are :
  79833. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79834. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79835. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79836. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79837. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79838. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  79839. * */
  79840. cullingStrategy: number;
  79841. /**
  79842. * @hidden Internal global position in the SPS.
  79843. */
  79844. _globalPosition: Vector3;
  79845. /**
  79846. * Creates a Solid Particle object.
  79847. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  79848. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  79849. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  79850. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  79851. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  79852. * @param shapeId (integer) is the model shape identifier in the SPS.
  79853. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  79854. * @param sps defines the sps it is associated to
  79855. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  79856. */
  79857. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  79858. /**
  79859. * Legacy support, changed scale to scaling
  79860. */
  79861. /**
  79862. * Legacy support, changed scale to scaling
  79863. */
  79864. scale: Vector3;
  79865. /**
  79866. * Legacy support, changed quaternion to rotationQuaternion
  79867. */
  79868. /**
  79869. * Legacy support, changed quaternion to rotationQuaternion
  79870. */
  79871. quaternion: Nullable<Quaternion>;
  79872. /**
  79873. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  79874. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  79875. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  79876. * @returns true if it intersects
  79877. */
  79878. intersectsMesh(target: Mesh | SolidParticle): boolean;
  79879. /**
  79880. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  79881. * A particle is in the frustum if its bounding box intersects the frustum
  79882. * @param frustumPlanes defines the frustum to test
  79883. * @returns true if the particle is in the frustum planes
  79884. */
  79885. isInFrustum(frustumPlanes: Plane[]): boolean;
  79886. /**
  79887. * get the rotation matrix of the particle
  79888. * @hidden
  79889. */
  79890. getRotationMatrix(m: Matrix): void;
  79891. }
  79892. /**
  79893. * Represents the shape of the model used by one particle of a solid particle system.
  79894. * SPS internal tool, don't use it manually.
  79895. */
  79896. export class ModelShape {
  79897. /**
  79898. * The shape id
  79899. * @hidden
  79900. */
  79901. shapeID: number;
  79902. /**
  79903. * flat array of model positions (internal use)
  79904. * @hidden
  79905. */
  79906. _shape: Vector3[];
  79907. /**
  79908. * flat array of model UVs (internal use)
  79909. * @hidden
  79910. */
  79911. _shapeUV: number[];
  79912. /**
  79913. * length of the shape in the model indices array (internal use)
  79914. * @hidden
  79915. */
  79916. _indicesLength: number;
  79917. /**
  79918. * Custom position function (internal use)
  79919. * @hidden
  79920. */
  79921. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  79922. /**
  79923. * Custom vertex function (internal use)
  79924. * @hidden
  79925. */
  79926. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  79927. /**
  79928. * 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.
  79929. * SPS internal tool, don't use it manually.
  79930. * @hidden
  79931. */
  79932. 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>);
  79933. }
  79934. /**
  79935. * Represents a Depth Sorted Particle in the solid particle system.
  79936. */
  79937. export class DepthSortedParticle {
  79938. /**
  79939. * Index of the particle in the "indices" array
  79940. */
  79941. ind: number;
  79942. /**
  79943. * Length of the particle shape in the "indices" array
  79944. */
  79945. indicesLength: number;
  79946. /**
  79947. * Squared distance from the particle to the camera
  79948. */
  79949. sqDistance: number;
  79950. }
  79951. }
  79952. declare module BABYLON {
  79953. /**
  79954. * Class used to store all common mesh properties
  79955. */
  79956. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  79957. /** No occlusion */
  79958. static OCCLUSION_TYPE_NONE: number;
  79959. /** Occlusion set to optimisitic */
  79960. static OCCLUSION_TYPE_OPTIMISTIC: number;
  79961. /** Occlusion set to strict */
  79962. static OCCLUSION_TYPE_STRICT: number;
  79963. /** Use an accurante occlusion algorithm */
  79964. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  79965. /** Use a conservative occlusion algorithm */
  79966. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  79967. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79968. * Test order :
  79969. * Is the bounding sphere outside the frustum ?
  79970. * If not, are the bounding box vertices outside the frustum ?
  79971. * It not, then the cullable object is in the frustum.
  79972. */
  79973. static readonly CULLINGSTRATEGY_STANDARD: number;
  79974. /** Culling strategy : Bounding Sphere Only.
  79975. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79976. * It's also less accurate than the standard because some not visible objects can still be selected.
  79977. * Test : is the bounding sphere outside the frustum ?
  79978. * If not, then the cullable object is in the frustum.
  79979. */
  79980. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79981. /** Culling strategy : Optimistic Inclusion.
  79982. * This in an inclusion test first, then the standard exclusion test.
  79983. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79984. * 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.
  79985. * Anyway, it's as accurate as the standard strategy.
  79986. * Test :
  79987. * Is the cullable object bounding sphere center in the frustum ?
  79988. * If not, apply the default culling strategy.
  79989. */
  79990. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79991. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79992. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79993. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79994. * 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.
  79995. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79996. * Test :
  79997. * Is the cullable object bounding sphere center in the frustum ?
  79998. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79999. */
  80000. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80001. /**
  80002. * No billboard
  80003. */
  80004. static readonly BILLBOARDMODE_NONE: number;
  80005. /** Billboard on X axis */
  80006. static readonly BILLBOARDMODE_X: number;
  80007. /** Billboard on Y axis */
  80008. static readonly BILLBOARDMODE_Y: number;
  80009. /** Billboard on Z axis */
  80010. static readonly BILLBOARDMODE_Z: number;
  80011. /** Billboard on all axes */
  80012. static readonly BILLBOARDMODE_ALL: number;
  80013. private _facetData;
  80014. /**
  80015. * The culling strategy to use to check whether the mesh must be rendered or not.
  80016. * This value can be changed at any time and will be used on the next render mesh selection.
  80017. * The possible values are :
  80018. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80019. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80020. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80021. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80022. * Please read each static variable documentation to get details about the culling process.
  80023. * */
  80024. cullingStrategy: number;
  80025. /**
  80026. * Gets the number of facets in the mesh
  80027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80028. */
  80029. readonly facetNb: number;
  80030. /**
  80031. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80033. */
  80034. partitioningSubdivisions: number;
  80035. /**
  80036. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80037. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80039. */
  80040. partitioningBBoxRatio: number;
  80041. /**
  80042. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80043. * Works only for updatable meshes.
  80044. * Doesn't work with multi-materials
  80045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80046. */
  80047. mustDepthSortFacets: boolean;
  80048. /**
  80049. * The location (Vector3) where the facet depth sort must be computed from.
  80050. * By default, the active camera position.
  80051. * Used only when facet depth sort is enabled
  80052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80053. */
  80054. facetDepthSortFrom: Vector3;
  80055. /**
  80056. * gets a boolean indicating if facetData is enabled
  80057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80058. */
  80059. readonly isFacetDataEnabled: boolean;
  80060. /** @hidden */
  80061. _updateNonUniformScalingState(value: boolean): boolean;
  80062. /**
  80063. * An event triggered when this mesh collides with another one
  80064. */
  80065. onCollideObservable: Observable<AbstractMesh>;
  80066. private _onCollideObserver;
  80067. /** Set a function to call when this mesh collides with another one */
  80068. onCollide: () => void;
  80069. /**
  80070. * An event triggered when the collision's position changes
  80071. */
  80072. onCollisionPositionChangeObservable: Observable<Vector3>;
  80073. private _onCollisionPositionChangeObserver;
  80074. /** Set a function to call when the collision's position changes */
  80075. onCollisionPositionChange: () => void;
  80076. /**
  80077. * An event triggered when material is changed
  80078. */
  80079. onMaterialChangedObservable: Observable<AbstractMesh>;
  80080. /**
  80081. * Gets or sets the orientation for POV movement & rotation
  80082. */
  80083. definedFacingForward: boolean;
  80084. /** @hidden */
  80085. _occlusionQuery: Nullable<WebGLQuery>;
  80086. private _visibility;
  80087. /**
  80088. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80089. */
  80090. /**
  80091. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80092. */
  80093. visibility: number;
  80094. /** Gets or sets the alpha index used to sort transparent meshes
  80095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80096. */
  80097. alphaIndex: number;
  80098. /**
  80099. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80100. */
  80101. isVisible: boolean;
  80102. /**
  80103. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80104. */
  80105. isPickable: boolean;
  80106. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80107. showSubMeshesBoundingBox: boolean;
  80108. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80110. */
  80111. isBlocker: boolean;
  80112. /**
  80113. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80114. */
  80115. enablePointerMoveEvents: boolean;
  80116. /**
  80117. * Specifies the rendering group id for this mesh (0 by default)
  80118. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80119. */
  80120. renderingGroupId: number;
  80121. private _material;
  80122. /** Gets or sets current material */
  80123. material: Nullable<Material>;
  80124. private _receiveShadows;
  80125. /**
  80126. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80127. * @see http://doc.babylonjs.com/babylon101/shadows
  80128. */
  80129. receiveShadows: boolean;
  80130. /** Defines color to use when rendering outline */
  80131. outlineColor: Color3;
  80132. /** Define width to use when rendering outline */
  80133. outlineWidth: number;
  80134. /** Defines color to use when rendering overlay */
  80135. overlayColor: Color3;
  80136. /** Defines alpha to use when rendering overlay */
  80137. overlayAlpha: number;
  80138. private _hasVertexAlpha;
  80139. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80140. hasVertexAlpha: boolean;
  80141. private _useVertexColors;
  80142. /** 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) */
  80143. useVertexColors: boolean;
  80144. private _computeBonesUsingShaders;
  80145. /**
  80146. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80147. */
  80148. computeBonesUsingShaders: boolean;
  80149. private _numBoneInfluencers;
  80150. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80151. numBoneInfluencers: number;
  80152. private _applyFog;
  80153. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80154. applyFog: boolean;
  80155. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80156. useOctreeForRenderingSelection: boolean;
  80157. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80158. useOctreeForPicking: boolean;
  80159. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80160. useOctreeForCollisions: boolean;
  80161. private _layerMask;
  80162. /**
  80163. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80164. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80165. */
  80166. layerMask: number;
  80167. /**
  80168. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80169. */
  80170. alwaysSelectAsActiveMesh: boolean;
  80171. /**
  80172. * Gets or sets the current action manager
  80173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80174. */
  80175. actionManager: Nullable<AbstractActionManager>;
  80176. private _checkCollisions;
  80177. private _collisionMask;
  80178. private _collisionGroup;
  80179. /**
  80180. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80181. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80182. */
  80183. ellipsoid: Vector3;
  80184. /**
  80185. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80186. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80187. */
  80188. ellipsoidOffset: Vector3;
  80189. private _collider;
  80190. private _oldPositionForCollisions;
  80191. private _diffPositionForCollisions;
  80192. /**
  80193. * Gets or sets a collision mask used to mask collisions (default is -1).
  80194. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80195. */
  80196. collisionMask: number;
  80197. /**
  80198. * Gets or sets the current collision group mask (-1 by default).
  80199. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80200. */
  80201. collisionGroup: number;
  80202. /**
  80203. * Defines edge width used when edgesRenderer is enabled
  80204. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80205. */
  80206. edgesWidth: number;
  80207. /**
  80208. * Defines edge color used when edgesRenderer is enabled
  80209. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80210. */
  80211. edgesColor: Color4;
  80212. /** @hidden */
  80213. _edgesRenderer: Nullable<IEdgesRenderer>;
  80214. /** @hidden */
  80215. _masterMesh: Nullable<AbstractMesh>;
  80216. /** @hidden */
  80217. _boundingInfo: Nullable<BoundingInfo>;
  80218. /** @hidden */
  80219. _renderId: number;
  80220. /**
  80221. * Gets or sets the list of subMeshes
  80222. * @see http://doc.babylonjs.com/how_to/multi_materials
  80223. */
  80224. subMeshes: SubMesh[];
  80225. /** @hidden */
  80226. _intersectionsInProgress: AbstractMesh[];
  80227. /** @hidden */
  80228. _unIndexed: boolean;
  80229. /** @hidden */
  80230. _lightSources: Light[];
  80231. /** @hidden */
  80232. readonly _positions: Nullable<Vector3[]>;
  80233. /** @hidden */
  80234. _waitingActions: any;
  80235. /** @hidden */
  80236. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80237. private _skeleton;
  80238. /** @hidden */
  80239. _bonesTransformMatrices: Nullable<Float32Array>;
  80240. /**
  80241. * Gets or sets a skeleton to apply skining transformations
  80242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80243. */
  80244. skeleton: Nullable<Skeleton>;
  80245. /**
  80246. * An event triggered when the mesh is rebuilt.
  80247. */
  80248. onRebuildObservable: Observable<AbstractMesh>;
  80249. /**
  80250. * Creates a new AbstractMesh
  80251. * @param name defines the name of the mesh
  80252. * @param scene defines the hosting scene
  80253. */
  80254. constructor(name: string, scene?: Nullable<Scene>);
  80255. /**
  80256. * Returns the string "AbstractMesh"
  80257. * @returns "AbstractMesh"
  80258. */
  80259. getClassName(): string;
  80260. /**
  80261. * Gets a string representation of the current mesh
  80262. * @param fullDetails defines a boolean indicating if full details must be included
  80263. * @returns a string representation of the current mesh
  80264. */
  80265. toString(fullDetails?: boolean): string;
  80266. /** @hidden */
  80267. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80268. /** @hidden */
  80269. _rebuild(): void;
  80270. /** @hidden */
  80271. _resyncLightSources(): void;
  80272. /** @hidden */
  80273. _resyncLighSource(light: Light): void;
  80274. /** @hidden */
  80275. _unBindEffect(): void;
  80276. /** @hidden */
  80277. _removeLightSource(light: Light): void;
  80278. private _markSubMeshesAsDirty;
  80279. /** @hidden */
  80280. _markSubMeshesAsLightDirty(): void;
  80281. /** @hidden */
  80282. _markSubMeshesAsAttributesDirty(): void;
  80283. /** @hidden */
  80284. _markSubMeshesAsMiscDirty(): void;
  80285. /**
  80286. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80287. */
  80288. scaling: Vector3;
  80289. /**
  80290. * Returns true if the mesh is blocked. Implemented by child classes
  80291. */
  80292. readonly isBlocked: boolean;
  80293. /**
  80294. * Returns the mesh itself by default. Implemented by child classes
  80295. * @param camera defines the camera to use to pick the right LOD level
  80296. * @returns the currentAbstractMesh
  80297. */
  80298. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80299. /**
  80300. * Returns 0 by default. Implemented by child classes
  80301. * @returns an integer
  80302. */
  80303. getTotalVertices(): number;
  80304. /**
  80305. * Returns a positive integer : the total number of indices in this mesh geometry.
  80306. * @returns the numner of indices or zero if the mesh has no geometry.
  80307. */
  80308. getTotalIndices(): number;
  80309. /**
  80310. * Returns null by default. Implemented by child classes
  80311. * @returns null
  80312. */
  80313. getIndices(): Nullable<IndicesArray>;
  80314. /**
  80315. * Returns the array of the requested vertex data kind. Implemented by child classes
  80316. * @param kind defines the vertex data kind to use
  80317. * @returns null
  80318. */
  80319. getVerticesData(kind: string): Nullable<FloatArray>;
  80320. /**
  80321. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80322. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80323. * Note that a new underlying VertexBuffer object is created each call.
  80324. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80325. * @param kind defines vertex data kind:
  80326. * * VertexBuffer.PositionKind
  80327. * * VertexBuffer.UVKind
  80328. * * VertexBuffer.UV2Kind
  80329. * * VertexBuffer.UV3Kind
  80330. * * VertexBuffer.UV4Kind
  80331. * * VertexBuffer.UV5Kind
  80332. * * VertexBuffer.UV6Kind
  80333. * * VertexBuffer.ColorKind
  80334. * * VertexBuffer.MatricesIndicesKind
  80335. * * VertexBuffer.MatricesIndicesExtraKind
  80336. * * VertexBuffer.MatricesWeightsKind
  80337. * * VertexBuffer.MatricesWeightsExtraKind
  80338. * @param data defines the data source
  80339. * @param updatable defines if the data must be flagged as updatable (or static)
  80340. * @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
  80341. * @returns the current mesh
  80342. */
  80343. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80344. /**
  80345. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80346. * If the mesh has no geometry, it is simply returned as it is.
  80347. * @param kind defines vertex data kind:
  80348. * * VertexBuffer.PositionKind
  80349. * * VertexBuffer.UVKind
  80350. * * VertexBuffer.UV2Kind
  80351. * * VertexBuffer.UV3Kind
  80352. * * VertexBuffer.UV4Kind
  80353. * * VertexBuffer.UV5Kind
  80354. * * VertexBuffer.UV6Kind
  80355. * * VertexBuffer.ColorKind
  80356. * * VertexBuffer.MatricesIndicesKind
  80357. * * VertexBuffer.MatricesIndicesExtraKind
  80358. * * VertexBuffer.MatricesWeightsKind
  80359. * * VertexBuffer.MatricesWeightsExtraKind
  80360. * @param data defines the data source
  80361. * @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
  80362. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80363. * @returns the current mesh
  80364. */
  80365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  80366. /**
  80367. * Sets the mesh indices,
  80368. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80369. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80370. * @param totalVertices Defines the total number of vertices
  80371. * @returns the current mesh
  80372. */
  80373. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  80374. /**
  80375. * Gets a boolean indicating if specific vertex data is present
  80376. * @param kind defines the vertex data kind to use
  80377. * @returns true is data kind is present
  80378. */
  80379. isVerticesDataPresent(kind: string): boolean;
  80380. /**
  80381. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80382. * @returns a BoundingInfo
  80383. */
  80384. getBoundingInfo(): BoundingInfo;
  80385. /**
  80386. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80387. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80388. * @returns the current mesh
  80389. */
  80390. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  80391. /**
  80392. * Overwrite the current bounding info
  80393. * @param boundingInfo defines the new bounding info
  80394. * @returns the current mesh
  80395. */
  80396. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  80397. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80398. readonly useBones: boolean;
  80399. /** @hidden */
  80400. _preActivate(): void;
  80401. /** @hidden */
  80402. _preActivateForIntermediateRendering(renderId: number): void;
  80403. /** @hidden */
  80404. _activate(renderId: number): void;
  80405. /**
  80406. * Gets the current world matrix
  80407. * @returns a Matrix
  80408. */
  80409. getWorldMatrix(): Matrix;
  80410. /** @hidden */
  80411. _getWorldMatrixDeterminant(): number;
  80412. /**
  80413. * Perform relative position change from the point of view of behind the front of the mesh.
  80414. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80415. * Supports definition of mesh facing forward or backward
  80416. * @param amountRight defines the distance on the right axis
  80417. * @param amountUp defines the distance on the up axis
  80418. * @param amountForward defines the distance on the forward axis
  80419. * @returns the current mesh
  80420. */
  80421. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  80422. /**
  80423. * Calculate relative position change from the point of view of behind the front of the mesh.
  80424. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80425. * Supports definition of mesh facing forward or backward
  80426. * @param amountRight defines the distance on the right axis
  80427. * @param amountUp defines the distance on the up axis
  80428. * @param amountForward defines the distance on the forward axis
  80429. * @returns the new displacement vector
  80430. */
  80431. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  80432. /**
  80433. * Perform relative rotation change from the point of view of behind the front of the mesh.
  80434. * Supports definition of mesh facing forward or backward
  80435. * @param flipBack defines the flip
  80436. * @param twirlClockwise defines the twirl
  80437. * @param tiltRight defines the tilt
  80438. * @returns the current mesh
  80439. */
  80440. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  80441. /**
  80442. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  80443. * Supports definition of mesh facing forward or backward.
  80444. * @param flipBack defines the flip
  80445. * @param twirlClockwise defines the twirl
  80446. * @param tiltRight defines the tilt
  80447. * @returns the new rotation vector
  80448. */
  80449. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  80450. /**
  80451. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  80452. * @param includeDescendants Include bounding info from descendants as well (true by default)
  80453. * @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
  80454. * @returns the new bounding vectors
  80455. */
  80456. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  80457. min: Vector3;
  80458. max: Vector3;
  80459. };
  80460. /**
  80461. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80462. * This means the mesh underlying bounding box and sphere are recomputed.
  80463. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80464. * @returns the current mesh
  80465. */
  80466. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  80467. /** @hidden */
  80468. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  80469. /** @hidden */
  80470. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  80471. /** @hidden */
  80472. _updateBoundingInfo(): AbstractMesh;
  80473. /** @hidden */
  80474. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  80475. /** @hidden */
  80476. protected _afterComputeWorldMatrix(): void;
  80477. /**
  80478. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80479. * A mesh is in the frustum if its bounding box intersects the frustum
  80480. * @param frustumPlanes defines the frustum to test
  80481. * @returns true if the mesh is in the frustum planes
  80482. */
  80483. isInFrustum(frustumPlanes: Plane[]): boolean;
  80484. /**
  80485. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  80486. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  80487. * @param frustumPlanes defines the frustum to test
  80488. * @returns true if the mesh is completely in the frustum planes
  80489. */
  80490. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80491. /**
  80492. * True if the mesh intersects another mesh or a SolidParticle object
  80493. * @param mesh defines a target mesh or SolidParticle to test
  80494. * @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)
  80495. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  80496. * @returns true if there is an intersection
  80497. */
  80498. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  80499. /**
  80500. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  80501. * @param point defines the point to test
  80502. * @returns true if there is an intersection
  80503. */
  80504. intersectsPoint(point: Vector3): boolean;
  80505. /**
  80506. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80508. */
  80509. checkCollisions: boolean;
  80510. /**
  80511. * Gets Collider object used to compute collisions (not physics)
  80512. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80513. */
  80514. readonly collider: Collider;
  80515. /**
  80516. * Move the mesh using collision engine
  80517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80518. * @param displacement defines the requested displacement vector
  80519. * @returns the current mesh
  80520. */
  80521. moveWithCollisions(displacement: Vector3): AbstractMesh;
  80522. private _onCollisionPositionChange;
  80523. /** @hidden */
  80524. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  80525. /** @hidden */
  80526. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  80527. /** @hidden */
  80528. _checkCollision(collider: Collider): AbstractMesh;
  80529. /** @hidden */
  80530. _generatePointsArray(): boolean;
  80531. /**
  80532. * Checks if the passed Ray intersects with the mesh
  80533. * @param ray defines the ray to use
  80534. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80535. * @returns the picking info
  80536. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80537. */
  80538. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  80539. /**
  80540. * Clones the current mesh
  80541. * @param name defines the mesh name
  80542. * @param newParent defines the new mesh parent
  80543. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80544. * @returns the new mesh
  80545. */
  80546. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  80547. /**
  80548. * Disposes all the submeshes of the current meshnp
  80549. * @returns the current mesh
  80550. */
  80551. releaseSubMeshes(): AbstractMesh;
  80552. /**
  80553. * Releases resources associated with this abstract mesh.
  80554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80556. */
  80557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80558. /**
  80559. * Adds the passed mesh as a child to the current mesh
  80560. * @param mesh defines the child mesh
  80561. * @returns the current mesh
  80562. */
  80563. addChild(mesh: AbstractMesh): AbstractMesh;
  80564. /**
  80565. * Removes the passed mesh from the current mesh children list
  80566. * @param mesh defines the child mesh
  80567. * @returns the current mesh
  80568. */
  80569. removeChild(mesh: AbstractMesh): AbstractMesh;
  80570. /** @hidden */
  80571. private _initFacetData;
  80572. /**
  80573. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80574. * This method can be called within the render loop.
  80575. * 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
  80576. * @returns the current mesh
  80577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80578. */
  80579. updateFacetData(): AbstractMesh;
  80580. /**
  80581. * Returns the facetLocalNormals array.
  80582. * The normals are expressed in the mesh local spac
  80583. * @returns an array of Vector3
  80584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80585. */
  80586. getFacetLocalNormals(): Vector3[];
  80587. /**
  80588. * Returns the facetLocalPositions array.
  80589. * The facet positions are expressed in the mesh local space
  80590. * @returns an array of Vector3
  80591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80592. */
  80593. getFacetLocalPositions(): Vector3[];
  80594. /**
  80595. * Returns the facetLocalPartioning array
  80596. * @returns an array of array of numbers
  80597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80598. */
  80599. getFacetLocalPartitioning(): number[][];
  80600. /**
  80601. * Returns the i-th facet position in the world system.
  80602. * This method allocates a new Vector3 per call
  80603. * @param i defines the facet index
  80604. * @returns a new Vector3
  80605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80606. */
  80607. getFacetPosition(i: number): Vector3;
  80608. /**
  80609. * Sets the reference Vector3 with the i-th facet position in the world system
  80610. * @param i defines the facet index
  80611. * @param ref defines the target vector
  80612. * @returns the current mesh
  80613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80614. */
  80615. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  80616. /**
  80617. * Returns the i-th facet normal in the world system.
  80618. * This method allocates a new Vector3 per call
  80619. * @param i defines the facet index
  80620. * @returns a new Vector3
  80621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80622. */
  80623. getFacetNormal(i: number): Vector3;
  80624. /**
  80625. * Sets the reference Vector3 with the i-th facet normal in the world system
  80626. * @param i defines the facet index
  80627. * @param ref defines the target vector
  80628. * @returns the current mesh
  80629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80630. */
  80631. getFacetNormalToRef(i: number, ref: Vector3): this;
  80632. /**
  80633. * 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)
  80634. * @param x defines x coordinate
  80635. * @param y defines y coordinate
  80636. * @param z defines z coordinate
  80637. * @returns the array of facet indexes
  80638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80639. */
  80640. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  80641. /**
  80642. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80643. * @param projected sets as the (x,y,z) world projection on the facet
  80644. * @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
  80645. * @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
  80646. * @param x defines x coordinate
  80647. * @param y defines y coordinate
  80648. * @param z defines z coordinate
  80649. * @returns the face index if found (or null instead)
  80650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80651. */
  80652. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80653. /**
  80654. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80655. * @param projected sets as the (x,y,z) local projection on the facet
  80656. * @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
  80657. * @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
  80658. * @param x defines x coordinate
  80659. * @param y defines y coordinate
  80660. * @param z defines z coordinate
  80661. * @returns the face index if found (or null instead)
  80662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80663. */
  80664. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80665. /**
  80666. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80667. * @returns the parameters
  80668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80669. */
  80670. getFacetDataParameters(): any;
  80671. /**
  80672. * Disables the feature FacetData and frees the related memory
  80673. * @returns the current mesh
  80674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80675. */
  80676. disableFacetData(): AbstractMesh;
  80677. /**
  80678. * Updates the AbstractMesh indices array
  80679. * @param indices defines the data source
  80680. * @returns the current mesh
  80681. */
  80682. updateIndices(indices: IndicesArray): AbstractMesh;
  80683. /**
  80684. * Creates new normals data for the mesh
  80685. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80686. * @returns the current mesh
  80687. */
  80688. createNormals(updatable: boolean): AbstractMesh;
  80689. /**
  80690. * Align the mesh with a normal
  80691. * @param normal defines the normal to use
  80692. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80693. * @returns the current mesh
  80694. */
  80695. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  80696. /** @hidden */
  80697. _checkOcclusionQuery(): boolean;
  80698. }
  80699. }
  80700. declare module BABYLON {
  80701. /**
  80702. * Interface used to define ActionEvent
  80703. */
  80704. export interface IActionEvent {
  80705. /** The mesh or sprite that triggered the action */
  80706. source: any;
  80707. /** The X mouse cursor position at the time of the event */
  80708. pointerX: number;
  80709. /** The Y mouse cursor position at the time of the event */
  80710. pointerY: number;
  80711. /** The mesh that is currently pointed at (can be null) */
  80712. meshUnderPointer: Nullable<AbstractMesh>;
  80713. /** the original (browser) event that triggered the ActionEvent */
  80714. sourceEvent?: any;
  80715. /** additional data for the event */
  80716. additionalData?: any;
  80717. }
  80718. /**
  80719. * ActionEvent is the event being sent when an action is triggered.
  80720. */
  80721. export class ActionEvent implements IActionEvent {
  80722. /** The mesh or sprite that triggered the action */
  80723. source: any;
  80724. /** The X mouse cursor position at the time of the event */
  80725. pointerX: number;
  80726. /** The Y mouse cursor position at the time of the event */
  80727. pointerY: number;
  80728. /** The mesh that is currently pointed at (can be null) */
  80729. meshUnderPointer: Nullable<AbstractMesh>;
  80730. /** the original (browser) event that triggered the ActionEvent */
  80731. sourceEvent?: any;
  80732. /** additional data for the event */
  80733. additionalData?: any;
  80734. /**
  80735. * Creates a new ActionEvent
  80736. * @param source The mesh or sprite that triggered the action
  80737. * @param pointerX The X mouse cursor position at the time of the event
  80738. * @param pointerY The Y mouse cursor position at the time of the event
  80739. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  80740. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  80741. * @param additionalData additional data for the event
  80742. */
  80743. constructor(
  80744. /** The mesh or sprite that triggered the action */
  80745. source: any,
  80746. /** The X mouse cursor position at the time of the event */
  80747. pointerX: number,
  80748. /** The Y mouse cursor position at the time of the event */
  80749. pointerY: number,
  80750. /** The mesh that is currently pointed at (can be null) */
  80751. meshUnderPointer: Nullable<AbstractMesh>,
  80752. /** the original (browser) event that triggered the ActionEvent */
  80753. sourceEvent?: any,
  80754. /** additional data for the event */
  80755. additionalData?: any);
  80756. /**
  80757. * Helper function to auto-create an ActionEvent from a source mesh.
  80758. * @param source The source mesh that triggered the event
  80759. * @param evt The original (browser) event
  80760. * @param additionalData additional data for the event
  80761. * @returns the new ActionEvent
  80762. */
  80763. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  80764. /**
  80765. * Helper function to auto-create an ActionEvent from a source sprite
  80766. * @param source The source sprite that triggered the event
  80767. * @param scene Scene associated with the sprite
  80768. * @param evt The original (browser) event
  80769. * @param additionalData additional data for the event
  80770. * @returns the new ActionEvent
  80771. */
  80772. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  80773. /**
  80774. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  80775. * @param scene the scene where the event occurred
  80776. * @param evt The original (browser) event
  80777. * @returns the new ActionEvent
  80778. */
  80779. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  80780. /**
  80781. * Helper function to auto-create an ActionEvent from a primitive
  80782. * @param prim defines the target primitive
  80783. * @param pointerPos defines the pointer position
  80784. * @param evt The original (browser) event
  80785. * @param additionalData additional data for the event
  80786. * @returns the new ActionEvent
  80787. */
  80788. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  80789. }
  80790. }
  80791. declare module BABYLON {
  80792. /**
  80793. * Abstract class used to decouple action Manager from scene and meshes.
  80794. * Do not instantiate.
  80795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80796. */
  80797. export abstract class AbstractActionManager implements IDisposable {
  80798. /** Gets the list of active triggers */
  80799. static Triggers: {
  80800. [key: string]: number;
  80801. };
  80802. /** Gets the cursor to use when hovering items */
  80803. hoverCursor: string;
  80804. /** Gets the list of actions */
  80805. actions: IAction[];
  80806. /**
  80807. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  80808. */
  80809. isRecursive: boolean;
  80810. /**
  80811. * Releases all associated resources
  80812. */
  80813. abstract dispose(): void;
  80814. /**
  80815. * Does this action manager has pointer triggers
  80816. */
  80817. abstract readonly hasPointerTriggers: boolean;
  80818. /**
  80819. * Does this action manager has pick triggers
  80820. */
  80821. abstract readonly hasPickTriggers: boolean;
  80822. /**
  80823. * Process a specific trigger
  80824. * @param trigger defines the trigger to process
  80825. * @param evt defines the event details to be processed
  80826. */
  80827. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  80828. /**
  80829. * Does this action manager handles actions of any of the given triggers
  80830. * @param triggers defines the triggers to be tested
  80831. * @return a boolean indicating whether one (or more) of the triggers is handled
  80832. */
  80833. abstract hasSpecificTriggers(triggers: number[]): boolean;
  80834. /**
  80835. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80836. * speed.
  80837. * @param triggerA defines the trigger to be tested
  80838. * @param triggerB defines the trigger to be tested
  80839. * @return a boolean indicating whether one (or more) of the triggers is handled
  80840. */
  80841. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80842. /**
  80843. * Does this action manager handles actions of a given trigger
  80844. * @param trigger defines the trigger to be tested
  80845. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80846. * @return whether the trigger is handled
  80847. */
  80848. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80849. /**
  80850. * Serialize this manager to a JSON object
  80851. * @param name defines the property name to store this manager
  80852. * @returns a JSON representation of this manager
  80853. */
  80854. abstract serialize(name: string): any;
  80855. /**
  80856. * Does exist one action manager with at least one trigger
  80857. **/
  80858. static readonly HasTriggers: boolean;
  80859. /**
  80860. * Does exist one action manager with at least one pick trigger
  80861. **/
  80862. static readonly HasPickTriggers: boolean;
  80863. /**
  80864. * Does exist one action manager that handles actions of a given trigger
  80865. * @param trigger defines the trigger to be tested
  80866. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  80867. **/
  80868. static HasSpecificTrigger(trigger: number): boolean;
  80869. }
  80870. }
  80871. declare module BABYLON {
  80872. /**
  80873. * Defines how a node can be built from a string name.
  80874. */
  80875. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80876. /**
  80877. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80878. */
  80879. export class Node implements IBehaviorAware<Node> {
  80880. /** @hidden */
  80881. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80882. private static _NodeConstructors;
  80883. /**
  80884. * Add a new node constructor
  80885. * @param type defines the type name of the node to construct
  80886. * @param constructorFunc defines the constructor function
  80887. */
  80888. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80889. /**
  80890. * Returns a node constructor based on type name
  80891. * @param type defines the type name
  80892. * @param name defines the new node name
  80893. * @param scene defines the hosting scene
  80894. * @param options defines optional options to transmit to constructors
  80895. * @returns the new constructor or null
  80896. */
  80897. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80898. /**
  80899. * Gets or sets the name of the node
  80900. */
  80901. name: string;
  80902. /**
  80903. * Gets or sets the id of the node
  80904. */
  80905. id: string;
  80906. /**
  80907. * Gets or sets the unique id of the node
  80908. */
  80909. uniqueId: number;
  80910. /**
  80911. * Gets or sets a string used to store user defined state for the node
  80912. */
  80913. state: string;
  80914. /**
  80915. * Gets or sets an object used to store user defined information for the node
  80916. */
  80917. metadata: any;
  80918. /**
  80919. * For internal use only. Please do not use.
  80920. */
  80921. reservedDataStore: any;
  80922. /**
  80923. * Gets or sets a boolean used to define if the node must be serialized
  80924. */
  80925. doNotSerialize: boolean;
  80926. /** @hidden */
  80927. _isDisposed: boolean;
  80928. /**
  80929. * Gets a list of Animations associated with the node
  80930. */
  80931. animations: Animation[];
  80932. protected _ranges: {
  80933. [name: string]: Nullable<AnimationRange>;
  80934. };
  80935. /**
  80936. * Callback raised when the node is ready to be used
  80937. */
  80938. onReady: (node: Node) => void;
  80939. private _isEnabled;
  80940. private _isParentEnabled;
  80941. private _isReady;
  80942. /** @hidden */
  80943. _currentRenderId: number;
  80944. private _parentRenderId;
  80945. protected _childRenderId: number;
  80946. /** @hidden */
  80947. _waitingParentId: Nullable<string>;
  80948. /** @hidden */
  80949. _scene: Scene;
  80950. /** @hidden */
  80951. _cache: any;
  80952. private _parentNode;
  80953. private _children;
  80954. /** @hidden */
  80955. _worldMatrix: Matrix;
  80956. /** @hidden */
  80957. _worldMatrixDeterminant: number;
  80958. /** @hidden */
  80959. private _sceneRootNodesIndex;
  80960. /**
  80961. * Gets a boolean indicating if the node has been disposed
  80962. * @returns true if the node was disposed
  80963. */
  80964. isDisposed(): boolean;
  80965. /**
  80966. * Gets or sets the parent of the node
  80967. */
  80968. parent: Nullable<Node>;
  80969. private addToSceneRootNodes;
  80970. private removeFromSceneRootNodes;
  80971. private _animationPropertiesOverride;
  80972. /**
  80973. * Gets or sets the animation properties override
  80974. */
  80975. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80976. /**
  80977. * Gets a string idenfifying the name of the class
  80978. * @returns "Node" string
  80979. */
  80980. getClassName(): string;
  80981. /** @hidden */
  80982. readonly _isNode: boolean;
  80983. /**
  80984. * An event triggered when the mesh is disposed
  80985. */
  80986. onDisposeObservable: Observable<Node>;
  80987. private _onDisposeObserver;
  80988. /**
  80989. * Sets a callback that will be raised when the node will be disposed
  80990. */
  80991. onDispose: () => void;
  80992. /**
  80993. * Creates a new Node
  80994. * @param name the name and id to be given to this node
  80995. * @param scene the scene this node will be added to
  80996. * @param addToRootNodes the node will be added to scene.rootNodes
  80997. */
  80998. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80999. /**
  81000. * Gets the scene of the node
  81001. * @returns a scene
  81002. */
  81003. getScene(): Scene;
  81004. /**
  81005. * Gets the engine of the node
  81006. * @returns a Engine
  81007. */
  81008. getEngine(): Engine;
  81009. private _behaviors;
  81010. /**
  81011. * Attach a behavior to the node
  81012. * @see http://doc.babylonjs.com/features/behaviour
  81013. * @param behavior defines the behavior to attach
  81014. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81015. * @returns the current Node
  81016. */
  81017. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81018. /**
  81019. * Remove an attached behavior
  81020. * @see http://doc.babylonjs.com/features/behaviour
  81021. * @param behavior defines the behavior to attach
  81022. * @returns the current Node
  81023. */
  81024. removeBehavior(behavior: Behavior<Node>): Node;
  81025. /**
  81026. * Gets the list of attached behaviors
  81027. * @see http://doc.babylonjs.com/features/behaviour
  81028. */
  81029. readonly behaviors: Behavior<Node>[];
  81030. /**
  81031. * Gets an attached behavior by name
  81032. * @param name defines the name of the behavior to look for
  81033. * @see http://doc.babylonjs.com/features/behaviour
  81034. * @returns null if behavior was not found else the requested behavior
  81035. */
  81036. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81037. /**
  81038. * Returns the latest update of the World matrix
  81039. * @returns a Matrix
  81040. */
  81041. getWorldMatrix(): Matrix;
  81042. /** @hidden */
  81043. _getWorldMatrixDeterminant(): number;
  81044. /**
  81045. * Returns directly the latest state of the mesh World matrix.
  81046. * A Matrix is returned.
  81047. */
  81048. readonly worldMatrixFromCache: Matrix;
  81049. /** @hidden */
  81050. _initCache(): void;
  81051. /** @hidden */
  81052. updateCache(force?: boolean): void;
  81053. /** @hidden */
  81054. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81055. /** @hidden */
  81056. _updateCache(ignoreParentClass?: boolean): void;
  81057. /** @hidden */
  81058. _isSynchronized(): boolean;
  81059. /** @hidden */
  81060. _markSyncedWithParent(): void;
  81061. /** @hidden */
  81062. isSynchronizedWithParent(): boolean;
  81063. /** @hidden */
  81064. isSynchronized(): boolean;
  81065. /**
  81066. * Is this node ready to be used/rendered
  81067. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81068. * @return true if the node is ready
  81069. */
  81070. isReady(completeCheck?: boolean): boolean;
  81071. /**
  81072. * Is this node enabled?
  81073. * 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
  81074. * @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
  81075. * @return whether this node (and its parent) is enabled
  81076. */
  81077. isEnabled(checkAncestors?: boolean): boolean;
  81078. /** @hidden */
  81079. protected _syncParentEnabledState(): void;
  81080. /**
  81081. * Set the enabled state of this node
  81082. * @param value defines the new enabled state
  81083. */
  81084. setEnabled(value: boolean): void;
  81085. /**
  81086. * Is this node a descendant of the given node?
  81087. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81088. * @param ancestor defines the parent node to inspect
  81089. * @returns a boolean indicating if this node is a descendant of the given node
  81090. */
  81091. isDescendantOf(ancestor: Node): boolean;
  81092. /** @hidden */
  81093. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81094. /**
  81095. * Will return all nodes that have this node as ascendant
  81096. * @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
  81097. * @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
  81098. * @return all children nodes of all types
  81099. */
  81100. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81101. /**
  81102. * Get all child-meshes of this node
  81103. * @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)
  81104. * @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
  81105. * @returns an array of AbstractMesh
  81106. */
  81107. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81108. /**
  81109. * Get all direct children of this node
  81110. * @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
  81111. * @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)
  81112. * @returns an array of Node
  81113. */
  81114. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81115. /** @hidden */
  81116. _setReady(state: boolean): void;
  81117. /**
  81118. * Get an animation by name
  81119. * @param name defines the name of the animation to look for
  81120. * @returns null if not found else the requested animation
  81121. */
  81122. getAnimationByName(name: string): Nullable<Animation>;
  81123. /**
  81124. * Creates an animation range for this node
  81125. * @param name defines the name of the range
  81126. * @param from defines the starting key
  81127. * @param to defines the end key
  81128. */
  81129. createAnimationRange(name: string, from: number, to: number): void;
  81130. /**
  81131. * Delete a specific animation range
  81132. * @param name defines the name of the range to delete
  81133. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81134. */
  81135. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81136. /**
  81137. * Get an animation range by name
  81138. * @param name defines the name of the animation range to look for
  81139. * @returns null if not found else the requested animation range
  81140. */
  81141. getAnimationRange(name: string): Nullable<AnimationRange>;
  81142. /**
  81143. * Will start the animation sequence
  81144. * @param name defines the range frames for animation sequence
  81145. * @param loop defines if the animation should loop (false by default)
  81146. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81147. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81148. * @returns the object created for this animation. If range does not exist, it will return null
  81149. */
  81150. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81151. /**
  81152. * Serialize animation ranges into a JSON compatible object
  81153. * @returns serialization object
  81154. */
  81155. serializeAnimationRanges(): any;
  81156. /**
  81157. * Computes the world matrix of the node
  81158. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81159. * @returns the world matrix
  81160. */
  81161. computeWorldMatrix(force?: boolean): Matrix;
  81162. /**
  81163. * Releases resources associated with this node.
  81164. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81165. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81166. */
  81167. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81168. /**
  81169. * Parse animation range data from a serialization object and store them into a given node
  81170. * @param node defines where to store the animation ranges
  81171. * @param parsedNode defines the serialization object to read data from
  81172. * @param scene defines the hosting scene
  81173. */
  81174. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81175. }
  81176. }
  81177. declare module BABYLON {
  81178. /**
  81179. * Class used to store any kind of animation
  81180. */
  81181. export class Animation {
  81182. /**Name of the animation */
  81183. name: string;
  81184. /**Property to animate */
  81185. targetProperty: string;
  81186. /**The frames per second of the animation */
  81187. framePerSecond: number;
  81188. /**The data type of the animation */
  81189. dataType: number;
  81190. /**The loop mode of the animation */
  81191. loopMode?: number | undefined;
  81192. /**Specifies if blending should be enabled */
  81193. enableBlending?: boolean | undefined;
  81194. /**
  81195. * Use matrix interpolation instead of using direct key value when animating matrices
  81196. */
  81197. static AllowMatricesInterpolation: boolean;
  81198. /**
  81199. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81200. */
  81201. static AllowMatrixDecomposeForInterpolation: boolean;
  81202. /**
  81203. * Stores the key frames of the animation
  81204. */
  81205. private _keys;
  81206. /**
  81207. * Stores the easing function of the animation
  81208. */
  81209. private _easingFunction;
  81210. /**
  81211. * @hidden Internal use only
  81212. */
  81213. _runtimeAnimations: RuntimeAnimation[];
  81214. /**
  81215. * The set of event that will be linked to this animation
  81216. */
  81217. private _events;
  81218. /**
  81219. * Stores an array of target property paths
  81220. */
  81221. targetPropertyPath: string[];
  81222. /**
  81223. * Stores the blending speed of the animation
  81224. */
  81225. blendingSpeed: number;
  81226. /**
  81227. * Stores the animation ranges for the animation
  81228. */
  81229. private _ranges;
  81230. /**
  81231. * @hidden Internal use
  81232. */
  81233. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81234. /**
  81235. * Sets up an animation
  81236. * @param property The property to animate
  81237. * @param animationType The animation type to apply
  81238. * @param framePerSecond The frames per second of the animation
  81239. * @param easingFunction The easing function used in the animation
  81240. * @returns The created animation
  81241. */
  81242. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81243. /**
  81244. * Create and start an animation on a node
  81245. * @param name defines the name of the global animation that will be run on all nodes
  81246. * @param node defines the root node where the animation will take place
  81247. * @param targetProperty defines property to animate
  81248. * @param framePerSecond defines the number of frame per second yo use
  81249. * @param totalFrame defines the number of frames in total
  81250. * @param from defines the initial value
  81251. * @param to defines the final value
  81252. * @param loopMode defines which loop mode you want to use (off by default)
  81253. * @param easingFunction defines the easing function to use (linear by default)
  81254. * @param onAnimationEnd defines the callback to call when animation end
  81255. * @returns the animatable created for this animation
  81256. */
  81257. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81258. /**
  81259. * Create and start an animation on a node and its descendants
  81260. * @param name defines the name of the global animation that will be run on all nodes
  81261. * @param node defines the root node where the animation will take place
  81262. * @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
  81263. * @param targetProperty defines property to animate
  81264. * @param framePerSecond defines the number of frame per second to use
  81265. * @param totalFrame defines the number of frames in total
  81266. * @param from defines the initial value
  81267. * @param to defines the final value
  81268. * @param loopMode defines which loop mode you want to use (off by default)
  81269. * @param easingFunction defines the easing function to use (linear by default)
  81270. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81271. * @returns the list of animatables created for all nodes
  81272. * @example https://www.babylonjs-playground.com/#MH0VLI
  81273. */
  81274. 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[]>;
  81275. /**
  81276. * Creates a new animation, merges it with the existing animations and starts it
  81277. * @param name Name of the animation
  81278. * @param node Node which contains the scene that begins the animations
  81279. * @param targetProperty Specifies which property to animate
  81280. * @param framePerSecond The frames per second of the animation
  81281. * @param totalFrame The total number of frames
  81282. * @param from The frame at the beginning of the animation
  81283. * @param to The frame at the end of the animation
  81284. * @param loopMode Specifies the loop mode of the animation
  81285. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81286. * @param onAnimationEnd Callback to run once the animation is complete
  81287. * @returns Nullable animation
  81288. */
  81289. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81290. /**
  81291. * Transition property of an host to the target Value
  81292. * @param property The property to transition
  81293. * @param targetValue The target Value of the property
  81294. * @param host The object where the property to animate belongs
  81295. * @param scene Scene used to run the animation
  81296. * @param frameRate Framerate (in frame/s) to use
  81297. * @param transition The transition type we want to use
  81298. * @param duration The duration of the animation, in milliseconds
  81299. * @param onAnimationEnd Callback trigger at the end of the animation
  81300. * @returns Nullable animation
  81301. */
  81302. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81303. /**
  81304. * Return the array of runtime animations currently using this animation
  81305. */
  81306. readonly runtimeAnimations: RuntimeAnimation[];
  81307. /**
  81308. * Specifies if any of the runtime animations are currently running
  81309. */
  81310. readonly hasRunningRuntimeAnimations: boolean;
  81311. /**
  81312. * Initializes the animation
  81313. * @param name Name of the animation
  81314. * @param targetProperty Property to animate
  81315. * @param framePerSecond The frames per second of the animation
  81316. * @param dataType The data type of the animation
  81317. * @param loopMode The loop mode of the animation
  81318. * @param enableBlending Specifies if blending should be enabled
  81319. */
  81320. constructor(
  81321. /**Name of the animation */
  81322. name: string,
  81323. /**Property to animate */
  81324. targetProperty: string,
  81325. /**The frames per second of the animation */
  81326. framePerSecond: number,
  81327. /**The data type of the animation */
  81328. dataType: number,
  81329. /**The loop mode of the animation */
  81330. loopMode?: number | undefined,
  81331. /**Specifies if blending should be enabled */
  81332. enableBlending?: boolean | undefined);
  81333. /**
  81334. * Converts the animation to a string
  81335. * @param fullDetails support for multiple levels of logging within scene loading
  81336. * @returns String form of the animation
  81337. */
  81338. toString(fullDetails?: boolean): string;
  81339. /**
  81340. * Add an event to this animation
  81341. * @param event Event to add
  81342. */
  81343. addEvent(event: AnimationEvent): void;
  81344. /**
  81345. * Remove all events found at the given frame
  81346. * @param frame The frame to remove events from
  81347. */
  81348. removeEvents(frame: number): void;
  81349. /**
  81350. * Retrieves all the events from the animation
  81351. * @returns Events from the animation
  81352. */
  81353. getEvents(): AnimationEvent[];
  81354. /**
  81355. * Creates an animation range
  81356. * @param name Name of the animation range
  81357. * @param from Starting frame of the animation range
  81358. * @param to Ending frame of the animation
  81359. */
  81360. createRange(name: string, from: number, to: number): void;
  81361. /**
  81362. * Deletes an animation range by name
  81363. * @param name Name of the animation range to delete
  81364. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81365. */
  81366. deleteRange(name: string, deleteFrames?: boolean): void;
  81367. /**
  81368. * Gets the animation range by name, or null if not defined
  81369. * @param name Name of the animation range
  81370. * @returns Nullable animation range
  81371. */
  81372. getRange(name: string): Nullable<AnimationRange>;
  81373. /**
  81374. * Gets the key frames from the animation
  81375. * @returns The key frames of the animation
  81376. */
  81377. getKeys(): Array<IAnimationKey>;
  81378. /**
  81379. * Gets the highest frame rate of the animation
  81380. * @returns Highest frame rate of the animation
  81381. */
  81382. getHighestFrame(): number;
  81383. /**
  81384. * Gets the easing function of the animation
  81385. * @returns Easing function of the animation
  81386. */
  81387. getEasingFunction(): IEasingFunction;
  81388. /**
  81389. * Sets the easing function of the animation
  81390. * @param easingFunction A custom mathematical formula for animation
  81391. */
  81392. setEasingFunction(easingFunction: EasingFunction): void;
  81393. /**
  81394. * Interpolates a scalar linearly
  81395. * @param startValue Start value of the animation curve
  81396. * @param endValue End value of the animation curve
  81397. * @param gradient Scalar amount to interpolate
  81398. * @returns Interpolated scalar value
  81399. */
  81400. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81401. /**
  81402. * Interpolates a scalar cubically
  81403. * @param startValue Start value of the animation curve
  81404. * @param outTangent End tangent of the animation
  81405. * @param endValue End value of the animation curve
  81406. * @param inTangent Start tangent of the animation curve
  81407. * @param gradient Scalar amount to interpolate
  81408. * @returns Interpolated scalar value
  81409. */
  81410. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81411. /**
  81412. * Interpolates a quaternion using a spherical linear interpolation
  81413. * @param startValue Start value of the animation curve
  81414. * @param endValue End value of the animation curve
  81415. * @param gradient Scalar amount to interpolate
  81416. * @returns Interpolated quaternion value
  81417. */
  81418. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81419. /**
  81420. * Interpolates a quaternion cubically
  81421. * @param startValue Start value of the animation curve
  81422. * @param outTangent End tangent of the animation curve
  81423. * @param endValue End value of the animation curve
  81424. * @param inTangent Start tangent of the animation curve
  81425. * @param gradient Scalar amount to interpolate
  81426. * @returns Interpolated quaternion value
  81427. */
  81428. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81429. /**
  81430. * Interpolates a Vector3 linearl
  81431. * @param startValue Start value of the animation curve
  81432. * @param endValue End value of the animation curve
  81433. * @param gradient Scalar amount to interpolate
  81434. * @returns Interpolated scalar value
  81435. */
  81436. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81437. /**
  81438. * Interpolates a Vector3 cubically
  81439. * @param startValue Start value of the animation curve
  81440. * @param outTangent End tangent of the animation
  81441. * @param endValue End value of the animation curve
  81442. * @param inTangent Start tangent of the animation curve
  81443. * @param gradient Scalar amount to interpolate
  81444. * @returns InterpolatedVector3 value
  81445. */
  81446. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81447. /**
  81448. * Interpolates a Vector2 linearly
  81449. * @param startValue Start value of the animation curve
  81450. * @param endValue End value of the animation curve
  81451. * @param gradient Scalar amount to interpolate
  81452. * @returns Interpolated Vector2 value
  81453. */
  81454. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81455. /**
  81456. * Interpolates a Vector2 cubically
  81457. * @param startValue Start value of the animation curve
  81458. * @param outTangent End tangent of the animation
  81459. * @param endValue End value of the animation curve
  81460. * @param inTangent Start tangent of the animation curve
  81461. * @param gradient Scalar amount to interpolate
  81462. * @returns Interpolated Vector2 value
  81463. */
  81464. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81465. /**
  81466. * Interpolates a size linearly
  81467. * @param startValue Start value of the animation curve
  81468. * @param endValue End value of the animation curve
  81469. * @param gradient Scalar amount to interpolate
  81470. * @returns Interpolated Size value
  81471. */
  81472. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81473. /**
  81474. * Interpolates a Color3 linearly
  81475. * @param startValue Start value of the animation curve
  81476. * @param endValue End value of the animation curve
  81477. * @param gradient Scalar amount to interpolate
  81478. * @returns Interpolated Color3 value
  81479. */
  81480. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81481. /**
  81482. * @hidden Internal use only
  81483. */
  81484. _getKeyValue(value: any): any;
  81485. /**
  81486. * @hidden Internal use only
  81487. */
  81488. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81489. /**
  81490. * Defines the function to use to interpolate matrices
  81491. * @param startValue defines the start matrix
  81492. * @param endValue defines the end matrix
  81493. * @param gradient defines the gradient between both matrices
  81494. * @param result defines an optional target matrix where to store the interpolation
  81495. * @returns the interpolated matrix
  81496. */
  81497. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81498. /**
  81499. * Makes a copy of the animation
  81500. * @returns Cloned animation
  81501. */
  81502. clone(): Animation;
  81503. /**
  81504. * Sets the key frames of the animation
  81505. * @param values The animation key frames to set
  81506. */
  81507. setKeys(values: Array<IAnimationKey>): void;
  81508. /**
  81509. * Serializes the animation to an object
  81510. * @returns Serialized object
  81511. */
  81512. serialize(): any;
  81513. /**
  81514. * Float animation type
  81515. */
  81516. private static _ANIMATIONTYPE_FLOAT;
  81517. /**
  81518. * Vector3 animation type
  81519. */
  81520. private static _ANIMATIONTYPE_VECTOR3;
  81521. /**
  81522. * Quaternion animation type
  81523. */
  81524. private static _ANIMATIONTYPE_QUATERNION;
  81525. /**
  81526. * Matrix animation type
  81527. */
  81528. private static _ANIMATIONTYPE_MATRIX;
  81529. /**
  81530. * Color3 animation type
  81531. */
  81532. private static _ANIMATIONTYPE_COLOR3;
  81533. /**
  81534. * Vector2 animation type
  81535. */
  81536. private static _ANIMATIONTYPE_VECTOR2;
  81537. /**
  81538. * Size animation type
  81539. */
  81540. private static _ANIMATIONTYPE_SIZE;
  81541. /**
  81542. * Relative Loop Mode
  81543. */
  81544. private static _ANIMATIONLOOPMODE_RELATIVE;
  81545. /**
  81546. * Cycle Loop Mode
  81547. */
  81548. private static _ANIMATIONLOOPMODE_CYCLE;
  81549. /**
  81550. * Constant Loop Mode
  81551. */
  81552. private static _ANIMATIONLOOPMODE_CONSTANT;
  81553. /**
  81554. * Get the float animation type
  81555. */
  81556. static readonly ANIMATIONTYPE_FLOAT: number;
  81557. /**
  81558. * Get the Vector3 animation type
  81559. */
  81560. static readonly ANIMATIONTYPE_VECTOR3: number;
  81561. /**
  81562. * Get the Vector2 animation type
  81563. */
  81564. static readonly ANIMATIONTYPE_VECTOR2: number;
  81565. /**
  81566. * Get the Size animation type
  81567. */
  81568. static readonly ANIMATIONTYPE_SIZE: number;
  81569. /**
  81570. * Get the Quaternion animation type
  81571. */
  81572. static readonly ANIMATIONTYPE_QUATERNION: number;
  81573. /**
  81574. * Get the Matrix animation type
  81575. */
  81576. static readonly ANIMATIONTYPE_MATRIX: number;
  81577. /**
  81578. * Get the Color3 animation type
  81579. */
  81580. static readonly ANIMATIONTYPE_COLOR3: number;
  81581. /**
  81582. * Get the Relative Loop Mode
  81583. */
  81584. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81585. /**
  81586. * Get the Cycle Loop Mode
  81587. */
  81588. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81589. /**
  81590. * Get the Constant Loop Mode
  81591. */
  81592. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81593. /** @hidden */
  81594. static _UniversalLerp(left: any, right: any, amount: number): any;
  81595. /**
  81596. * Parses an animation object and creates an animation
  81597. * @param parsedAnimation Parsed animation object
  81598. * @returns Animation object
  81599. */
  81600. static Parse(parsedAnimation: any): Animation;
  81601. /**
  81602. * Appends the serialized animations from the source animations
  81603. * @param source Source containing the animations
  81604. * @param destination Target to store the animations
  81605. */
  81606. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81607. }
  81608. }
  81609. declare module BABYLON {
  81610. /**
  81611. * Base class of all the textures in babylon.
  81612. * It groups all the common properties the materials, post process, lights... might need
  81613. * in order to make a correct use of the texture.
  81614. */
  81615. export class BaseTexture implements IAnimatable {
  81616. /**
  81617. * Default anisotropic filtering level for the application.
  81618. * It is set to 4 as a good tradeoff between perf and quality.
  81619. */
  81620. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81621. /**
  81622. * Gets or sets the unique id of the texture
  81623. */
  81624. uniqueId: number;
  81625. /**
  81626. * Define the name of the texture.
  81627. */
  81628. name: string;
  81629. /**
  81630. * Gets or sets an object used to store user defined information.
  81631. */
  81632. metadata: any;
  81633. /**
  81634. * For internal use only. Please do not use.
  81635. */
  81636. reservedDataStore: any;
  81637. private _hasAlpha;
  81638. /**
  81639. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81640. */
  81641. hasAlpha: boolean;
  81642. /**
  81643. * Defines if the alpha value should be determined via the rgb values.
  81644. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81645. */
  81646. getAlphaFromRGB: boolean;
  81647. /**
  81648. * Intensity or strength of the texture.
  81649. * It is commonly used by materials to fine tune the intensity of the texture
  81650. */
  81651. level: number;
  81652. /**
  81653. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81654. * This is part of the texture as textures usually maps to one uv set.
  81655. */
  81656. coordinatesIndex: number;
  81657. private _coordinatesMode;
  81658. /**
  81659. * How a texture is mapped.
  81660. *
  81661. * | Value | Type | Description |
  81662. * | ----- | ----------------------------------- | ----------- |
  81663. * | 0 | EXPLICIT_MODE | |
  81664. * | 1 | SPHERICAL_MODE | |
  81665. * | 2 | PLANAR_MODE | |
  81666. * | 3 | CUBIC_MODE | |
  81667. * | 4 | PROJECTION_MODE | |
  81668. * | 5 | SKYBOX_MODE | |
  81669. * | 6 | INVCUBIC_MODE | |
  81670. * | 7 | EQUIRECTANGULAR_MODE | |
  81671. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81672. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81673. */
  81674. coordinatesMode: number;
  81675. /**
  81676. * | Value | Type | Description |
  81677. * | ----- | ------------------ | ----------- |
  81678. * | 0 | CLAMP_ADDRESSMODE | |
  81679. * | 1 | WRAP_ADDRESSMODE | |
  81680. * | 2 | MIRROR_ADDRESSMODE | |
  81681. */
  81682. wrapU: number;
  81683. /**
  81684. * | Value | Type | Description |
  81685. * | ----- | ------------------ | ----------- |
  81686. * | 0 | CLAMP_ADDRESSMODE | |
  81687. * | 1 | WRAP_ADDRESSMODE | |
  81688. * | 2 | MIRROR_ADDRESSMODE | |
  81689. */
  81690. wrapV: number;
  81691. /**
  81692. * | Value | Type | Description |
  81693. * | ----- | ------------------ | ----------- |
  81694. * | 0 | CLAMP_ADDRESSMODE | |
  81695. * | 1 | WRAP_ADDRESSMODE | |
  81696. * | 2 | MIRROR_ADDRESSMODE | |
  81697. */
  81698. wrapR: number;
  81699. /**
  81700. * With compliant hardware and browser (supporting anisotropic filtering)
  81701. * this defines the level of anisotropic filtering in the texture.
  81702. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81703. */
  81704. anisotropicFilteringLevel: number;
  81705. /**
  81706. * Define if the texture is a cube texture or if false a 2d texture.
  81707. */
  81708. isCube: boolean;
  81709. /**
  81710. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81711. */
  81712. is3D: boolean;
  81713. /**
  81714. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81715. * HDR texture are usually stored in linear space.
  81716. * This only impacts the PBR and Background materials
  81717. */
  81718. gammaSpace: boolean;
  81719. /**
  81720. * Gets whether or not the texture contains RGBD data.
  81721. */
  81722. readonly isRGBD: boolean;
  81723. /**
  81724. * Is Z inverted in the texture (useful in a cube texture).
  81725. */
  81726. invertZ: boolean;
  81727. /**
  81728. * Are mip maps generated for this texture or not.
  81729. */
  81730. readonly noMipmap: boolean;
  81731. /**
  81732. * @hidden
  81733. */
  81734. lodLevelInAlpha: boolean;
  81735. /**
  81736. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81737. */
  81738. lodGenerationOffset: number;
  81739. /**
  81740. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81741. */
  81742. lodGenerationScale: number;
  81743. /**
  81744. * Define if the texture is a render target.
  81745. */
  81746. isRenderTarget: boolean;
  81747. /**
  81748. * Define the unique id of the texture in the scene.
  81749. */
  81750. readonly uid: string;
  81751. /**
  81752. * Return a string representation of the texture.
  81753. * @returns the texture as a string
  81754. */
  81755. toString(): string;
  81756. /**
  81757. * Get the class name of the texture.
  81758. * @returns "BaseTexture"
  81759. */
  81760. getClassName(): string;
  81761. /**
  81762. * Define the list of animation attached to the texture.
  81763. */
  81764. animations: Animation[];
  81765. /**
  81766. * An event triggered when the texture is disposed.
  81767. */
  81768. onDisposeObservable: Observable<BaseTexture>;
  81769. private _onDisposeObserver;
  81770. /**
  81771. * Callback triggered when the texture has been disposed.
  81772. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81773. */
  81774. onDispose: () => void;
  81775. /**
  81776. * Define the current state of the loading sequence when in delayed load mode.
  81777. */
  81778. delayLoadState: number;
  81779. private _scene;
  81780. /** @hidden */
  81781. _texture: Nullable<InternalTexture>;
  81782. private _uid;
  81783. /**
  81784. * Define if the texture is preventinga material to render or not.
  81785. * If not and the texture is not ready, the engine will use a default black texture instead.
  81786. */
  81787. readonly isBlocking: boolean;
  81788. /**
  81789. * Instantiates a new BaseTexture.
  81790. * Base class of all the textures in babylon.
  81791. * It groups all the common properties the materials, post process, lights... might need
  81792. * in order to make a correct use of the texture.
  81793. * @param scene Define the scene the texture blongs to
  81794. */
  81795. constructor(scene: Nullable<Scene>);
  81796. /**
  81797. * Get the scene the texture belongs to.
  81798. * @returns the scene or null if undefined
  81799. */
  81800. getScene(): Nullable<Scene>;
  81801. /**
  81802. * Get the texture transform matrix used to offset tile the texture for istance.
  81803. * @returns the transformation matrix
  81804. */
  81805. getTextureMatrix(): Matrix;
  81806. /**
  81807. * Get the texture reflection matrix used to rotate/transform the reflection.
  81808. * @returns the reflection matrix
  81809. */
  81810. getReflectionTextureMatrix(): Matrix;
  81811. /**
  81812. * Get the underlying lower level texture from Babylon.
  81813. * @returns the insternal texture
  81814. */
  81815. getInternalTexture(): Nullable<InternalTexture>;
  81816. /**
  81817. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81818. * @returns true if ready or not blocking
  81819. */
  81820. isReadyOrNotBlocking(): boolean;
  81821. /**
  81822. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81823. * @returns true if fully ready
  81824. */
  81825. isReady(): boolean;
  81826. private _cachedSize;
  81827. /**
  81828. * Get the size of the texture.
  81829. * @returns the texture size.
  81830. */
  81831. getSize(): ISize;
  81832. /**
  81833. * Get the base size of the texture.
  81834. * It can be different from the size if the texture has been resized for POT for instance
  81835. * @returns the base size
  81836. */
  81837. getBaseSize(): ISize;
  81838. /**
  81839. * Update the sampling mode of the texture.
  81840. * Default is Trilinear mode.
  81841. *
  81842. * | Value | Type | Description |
  81843. * | ----- | ------------------ | ----------- |
  81844. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81845. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81846. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81847. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81848. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81849. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81850. * | 7 | NEAREST_LINEAR | |
  81851. * | 8 | NEAREST_NEAREST | |
  81852. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81853. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81854. * | 11 | LINEAR_LINEAR | |
  81855. * | 12 | LINEAR_NEAREST | |
  81856. *
  81857. * > _mag_: magnification filter (close to the viewer)
  81858. * > _min_: minification filter (far from the viewer)
  81859. * > _mip_: filter used between mip map levels
  81860. *@param samplingMode Define the new sampling mode of the texture
  81861. */
  81862. updateSamplingMode(samplingMode: number): void;
  81863. /**
  81864. * Scales the texture if is `canRescale()`
  81865. * @param ratio the resize factor we want to use to rescale
  81866. */
  81867. scale(ratio: number): void;
  81868. /**
  81869. * Get if the texture can rescale.
  81870. */
  81871. readonly canRescale: boolean;
  81872. /** @hidden */
  81873. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81874. /** @hidden */
  81875. _rebuild(): void;
  81876. /**
  81877. * Triggers the load sequence in delayed load mode.
  81878. */
  81879. delayLoad(): void;
  81880. /**
  81881. * Clones the texture.
  81882. * @returns the cloned texture
  81883. */
  81884. clone(): Nullable<BaseTexture>;
  81885. /**
  81886. * Get the texture underlying type (INT, FLOAT...)
  81887. */
  81888. readonly textureType: number;
  81889. /**
  81890. * Get the texture underlying format (RGB, RGBA...)
  81891. */
  81892. readonly textureFormat: number;
  81893. /**
  81894. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81895. * This will returns an RGBA array buffer containing either in values (0-255) or
  81896. * float values (0-1) depending of the underlying buffer type.
  81897. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81898. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81899. * @param buffer defines a user defined buffer to fill with data (can be null)
  81900. * @returns The Array buffer containing the pixels data.
  81901. */
  81902. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81903. /**
  81904. * Release and destroy the underlying lower level texture aka internalTexture.
  81905. */
  81906. releaseInternalTexture(): void;
  81907. /**
  81908. * Get the polynomial representation of the texture data.
  81909. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81910. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81911. */
  81912. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81913. /** @hidden */
  81914. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81915. /** @hidden */
  81916. readonly _lodTextureMid: Nullable<BaseTexture>;
  81917. /** @hidden */
  81918. readonly _lodTextureLow: Nullable<BaseTexture>;
  81919. /**
  81920. * Dispose the texture and release its associated resources.
  81921. */
  81922. dispose(): void;
  81923. /**
  81924. * Serialize the texture into a JSON representation that can be parsed later on.
  81925. * @returns the JSON representation of the texture
  81926. */
  81927. serialize(): any;
  81928. /**
  81929. * Helper function to be called back once a list of texture contains only ready textures.
  81930. * @param textures Define the list of textures to wait for
  81931. * @param callback Define the callback triggered once the entire list will be ready
  81932. */
  81933. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81934. }
  81935. }
  81936. declare module BABYLON {
  81937. /**
  81938. * Uniform buffer objects.
  81939. *
  81940. * Handles blocks of uniform on the GPU.
  81941. *
  81942. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81943. *
  81944. * For more information, please refer to :
  81945. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81946. */
  81947. export class UniformBuffer {
  81948. private _engine;
  81949. private _buffer;
  81950. private _data;
  81951. private _bufferData;
  81952. private _dynamic?;
  81953. private _uniformLocations;
  81954. private _uniformSizes;
  81955. private _uniformLocationPointer;
  81956. private _needSync;
  81957. private _noUBO;
  81958. private _currentEffect;
  81959. private static _MAX_UNIFORM_SIZE;
  81960. private static _tempBuffer;
  81961. /**
  81962. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81963. * This is dynamic to allow compat with webgl 1 and 2.
  81964. * You will need to pass the name of the uniform as well as the value.
  81965. */
  81966. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81967. /**
  81968. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81969. * This is dynamic to allow compat with webgl 1 and 2.
  81970. * You will need to pass the name of the uniform as well as the value.
  81971. */
  81972. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81973. /**
  81974. * Lambda to Update a single float in a uniform buffer.
  81975. * This is dynamic to allow compat with webgl 1 and 2.
  81976. * You will need to pass the name of the uniform as well as the value.
  81977. */
  81978. updateFloat: (name: string, x: number) => void;
  81979. /**
  81980. * Lambda to Update a vec2 of float in a uniform buffer.
  81981. * This is dynamic to allow compat with webgl 1 and 2.
  81982. * You will need to pass the name of the uniform as well as the value.
  81983. */
  81984. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81985. /**
  81986. * Lambda to Update a vec3 of float in a uniform buffer.
  81987. * This is dynamic to allow compat with webgl 1 and 2.
  81988. * You will need to pass the name of the uniform as well as the value.
  81989. */
  81990. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81991. /**
  81992. * Lambda to Update a vec4 of float in a uniform buffer.
  81993. * This is dynamic to allow compat with webgl 1 and 2.
  81994. * You will need to pass the name of the uniform as well as the value.
  81995. */
  81996. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81997. /**
  81998. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81999. * This is dynamic to allow compat with webgl 1 and 2.
  82000. * You will need to pass the name of the uniform as well as the value.
  82001. */
  82002. updateMatrix: (name: string, mat: Matrix) => void;
  82003. /**
  82004. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82005. * This is dynamic to allow compat with webgl 1 and 2.
  82006. * You will need to pass the name of the uniform as well as the value.
  82007. */
  82008. updateVector3: (name: string, vector: Vector3) => void;
  82009. /**
  82010. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82011. * This is dynamic to allow compat with webgl 1 and 2.
  82012. * You will need to pass the name of the uniform as well as the value.
  82013. */
  82014. updateVector4: (name: string, vector: Vector4) => void;
  82015. /**
  82016. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82017. * This is dynamic to allow compat with webgl 1 and 2.
  82018. * You will need to pass the name of the uniform as well as the value.
  82019. */
  82020. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82021. /**
  82022. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82023. * This is dynamic to allow compat with webgl 1 and 2.
  82024. * You will need to pass the name of the uniform as well as the value.
  82025. */
  82026. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82027. /**
  82028. * Instantiates a new Uniform buffer objects.
  82029. *
  82030. * Handles blocks of uniform on the GPU.
  82031. *
  82032. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82033. *
  82034. * For more information, please refer to :
  82035. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82036. * @param engine Define the engine the buffer is associated with
  82037. * @param data Define the data contained in the buffer
  82038. * @param dynamic Define if the buffer is updatable
  82039. */
  82040. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82041. /**
  82042. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82043. * or just falling back on setUniformXXX calls.
  82044. */
  82045. readonly useUbo: boolean;
  82046. /**
  82047. * Indicates if the WebGL underlying uniform buffer is in sync
  82048. * with the javascript cache data.
  82049. */
  82050. readonly isSync: boolean;
  82051. /**
  82052. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82053. * Also, a dynamic UniformBuffer will disable cache verification and always
  82054. * update the underlying WebGL uniform buffer to the GPU.
  82055. * @returns if Dynamic, otherwise false
  82056. */
  82057. isDynamic(): boolean;
  82058. /**
  82059. * The data cache on JS side.
  82060. * @returns the underlying data as a float array
  82061. */
  82062. getData(): Float32Array;
  82063. /**
  82064. * The underlying WebGL Uniform buffer.
  82065. * @returns the webgl buffer
  82066. */
  82067. getBuffer(): Nullable<WebGLBuffer>;
  82068. /**
  82069. * std140 layout specifies how to align data within an UBO structure.
  82070. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82071. * for specs.
  82072. */
  82073. private _fillAlignment;
  82074. /**
  82075. * Adds an uniform in the buffer.
  82076. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82077. * for the layout to be correct !
  82078. * @param name Name of the uniform, as used in the uniform block in the shader.
  82079. * @param size Data size, or data directly.
  82080. */
  82081. addUniform(name: string, size: number | number[]): void;
  82082. /**
  82083. * Adds a Matrix 4x4 to the uniform buffer.
  82084. * @param name Name of the uniform, as used in the uniform block in the shader.
  82085. * @param mat A 4x4 matrix.
  82086. */
  82087. addMatrix(name: string, mat: Matrix): void;
  82088. /**
  82089. * Adds a vec2 to the uniform buffer.
  82090. * @param name Name of the uniform, as used in the uniform block in the shader.
  82091. * @param x Define the x component value of the vec2
  82092. * @param y Define the y component value of the vec2
  82093. */
  82094. addFloat2(name: string, x: number, y: number): void;
  82095. /**
  82096. * Adds a vec3 to the uniform buffer.
  82097. * @param name Name of the uniform, as used in the uniform block in the shader.
  82098. * @param x Define the x component value of the vec3
  82099. * @param y Define the y component value of the vec3
  82100. * @param z Define the z component value of the vec3
  82101. */
  82102. addFloat3(name: string, x: number, y: number, z: number): void;
  82103. /**
  82104. * Adds a vec3 to the uniform buffer.
  82105. * @param name Name of the uniform, as used in the uniform block in the shader.
  82106. * @param color Define the vec3 from a Color
  82107. */
  82108. addColor3(name: string, color: Color3): void;
  82109. /**
  82110. * Adds a vec4 to the uniform buffer.
  82111. * @param name Name of the uniform, as used in the uniform block in the shader.
  82112. * @param color Define the rgb components from a Color
  82113. * @param alpha Define the a component of the vec4
  82114. */
  82115. addColor4(name: string, color: Color3, alpha: number): void;
  82116. /**
  82117. * Adds a vec3 to the uniform buffer.
  82118. * @param name Name of the uniform, as used in the uniform block in the shader.
  82119. * @param vector Define the vec3 components from a Vector
  82120. */
  82121. addVector3(name: string, vector: Vector3): void;
  82122. /**
  82123. * Adds a Matrix 3x3 to the uniform buffer.
  82124. * @param name Name of the uniform, as used in the uniform block in the shader.
  82125. */
  82126. addMatrix3x3(name: string): void;
  82127. /**
  82128. * Adds a Matrix 2x2 to the uniform buffer.
  82129. * @param name Name of the uniform, as used in the uniform block in the shader.
  82130. */
  82131. addMatrix2x2(name: string): void;
  82132. /**
  82133. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82134. */
  82135. create(): void;
  82136. /** @hidden */
  82137. _rebuild(): void;
  82138. /**
  82139. * Updates the WebGL Uniform Buffer on the GPU.
  82140. * If the `dynamic` flag is set to true, no cache comparison is done.
  82141. * Otherwise, the buffer will be updated only if the cache differs.
  82142. */
  82143. update(): void;
  82144. /**
  82145. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82146. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82147. * @param data Define the flattened data
  82148. * @param size Define the size of the data.
  82149. */
  82150. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82151. private _updateMatrix3x3ForUniform;
  82152. private _updateMatrix3x3ForEffect;
  82153. private _updateMatrix2x2ForEffect;
  82154. private _updateMatrix2x2ForUniform;
  82155. private _updateFloatForEffect;
  82156. private _updateFloatForUniform;
  82157. private _updateFloat2ForEffect;
  82158. private _updateFloat2ForUniform;
  82159. private _updateFloat3ForEffect;
  82160. private _updateFloat3ForUniform;
  82161. private _updateFloat4ForEffect;
  82162. private _updateFloat4ForUniform;
  82163. private _updateMatrixForEffect;
  82164. private _updateMatrixForUniform;
  82165. private _updateVector3ForEffect;
  82166. private _updateVector3ForUniform;
  82167. private _updateVector4ForEffect;
  82168. private _updateVector4ForUniform;
  82169. private _updateColor3ForEffect;
  82170. private _updateColor3ForUniform;
  82171. private _updateColor4ForEffect;
  82172. private _updateColor4ForUniform;
  82173. /**
  82174. * Sets a sampler uniform on the effect.
  82175. * @param name Define the name of the sampler.
  82176. * @param texture Define the texture to set in the sampler
  82177. */
  82178. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82179. /**
  82180. * Directly updates the value of the uniform in the cache AND on the GPU.
  82181. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82182. * @param data Define the flattened data
  82183. */
  82184. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82185. /**
  82186. * Binds this uniform buffer to an effect.
  82187. * @param effect Define the effect to bind the buffer to
  82188. * @param name Name of the uniform block in the shader.
  82189. */
  82190. bindToEffect(effect: Effect, name: string): void;
  82191. /**
  82192. * Disposes the uniform buffer.
  82193. */
  82194. dispose(): void;
  82195. }
  82196. }
  82197. declare module BABYLON {
  82198. /**
  82199. * This represents the required contract to create a new type of texture loader.
  82200. */
  82201. export interface IInternalTextureLoader {
  82202. /**
  82203. * Defines wether the loader supports cascade loading the different faces.
  82204. */
  82205. supportCascades: boolean;
  82206. /**
  82207. * This returns if the loader support the current file information.
  82208. * @param extension defines the file extension of the file being loaded
  82209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82210. * @param fallback defines the fallback internal texture if any
  82211. * @param isBase64 defines whether the texture is encoded as a base64
  82212. * @param isBuffer defines whether the texture data are stored as a buffer
  82213. * @returns true if the loader can load the specified file
  82214. */
  82215. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82216. /**
  82217. * Transform the url before loading if required.
  82218. * @param rootUrl the url of the texture
  82219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82220. * @returns the transformed texture
  82221. */
  82222. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82223. /**
  82224. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82225. * @param rootUrl the url of the texture
  82226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82227. * @returns the fallback texture
  82228. */
  82229. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82230. /**
  82231. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82232. * @param data contains the texture data
  82233. * @param texture defines the BabylonJS internal texture
  82234. * @param createPolynomials will be true if polynomials have been requested
  82235. * @param onLoad defines the callback to trigger once the texture is ready
  82236. * @param onError defines the callback to trigger in case of error
  82237. */
  82238. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82239. /**
  82240. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82241. * @param data contains the texture data
  82242. * @param texture defines the BabylonJS internal texture
  82243. * @param callback defines the method to call once ready to upload
  82244. */
  82245. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82246. }
  82247. }
  82248. declare module BABYLON {
  82249. /**
  82250. * Creation options of the multi render target texture.
  82251. */
  82252. export interface IMultiRenderTargetOptions {
  82253. /**
  82254. * Define if the texture needs to create mip maps after render.
  82255. */
  82256. generateMipMaps?: boolean;
  82257. /**
  82258. * Define the types of all the draw buffers we want to create
  82259. */
  82260. types?: number[];
  82261. /**
  82262. * Define the sampling modes of all the draw buffers we want to create
  82263. */
  82264. samplingModes?: number[];
  82265. /**
  82266. * Define if a depth buffer is required
  82267. */
  82268. generateDepthBuffer?: boolean;
  82269. /**
  82270. * Define if a stencil buffer is required
  82271. */
  82272. generateStencilBuffer?: boolean;
  82273. /**
  82274. * Define if a depth texture is required instead of a depth buffer
  82275. */
  82276. generateDepthTexture?: boolean;
  82277. /**
  82278. * Define the number of desired draw buffers
  82279. */
  82280. textureCount?: number;
  82281. /**
  82282. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82283. */
  82284. doNotChangeAspectRatio?: boolean;
  82285. /**
  82286. * Define the default type of the buffers we are creating
  82287. */
  82288. defaultType?: number;
  82289. }
  82290. /**
  82291. * A multi render target, like a render target provides the ability to render to a texture.
  82292. * Unlike the render target, it can render to several draw buffers in one draw.
  82293. * This is specially interesting in deferred rendering or for any effects requiring more than
  82294. * just one color from a single pass.
  82295. */
  82296. export class MultiRenderTarget extends RenderTargetTexture {
  82297. private _internalTextures;
  82298. private _textures;
  82299. private _multiRenderTargetOptions;
  82300. /**
  82301. * Get if draw buffers are currently supported by the used hardware and browser.
  82302. */
  82303. readonly isSupported: boolean;
  82304. /**
  82305. * Get the list of textures generated by the multi render target.
  82306. */
  82307. readonly textures: Texture[];
  82308. /**
  82309. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82310. */
  82311. readonly depthTexture: Texture;
  82312. /**
  82313. * Set the wrapping mode on U of all the textures we are rendering to.
  82314. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82315. */
  82316. wrapU: number;
  82317. /**
  82318. * Set the wrapping mode on V of all the textures we are rendering to.
  82319. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82320. */
  82321. wrapV: number;
  82322. /**
  82323. * Instantiate a new multi render target texture.
  82324. * A multi render target, like a render target provides the ability to render to a texture.
  82325. * Unlike the render target, it can render to several draw buffers in one draw.
  82326. * This is specially interesting in deferred rendering or for any effects requiring more than
  82327. * just one color from a single pass.
  82328. * @param name Define the name of the texture
  82329. * @param size Define the size of the buffers to render to
  82330. * @param count Define the number of target we are rendering into
  82331. * @param scene Define the scene the texture belongs to
  82332. * @param options Define the options used to create the multi render target
  82333. */
  82334. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82335. /** @hidden */
  82336. _rebuild(): void;
  82337. private _createInternalTextures;
  82338. private _createTextures;
  82339. /**
  82340. * Define the number of samples used if MSAA is enabled.
  82341. */
  82342. samples: number;
  82343. /**
  82344. * Resize all the textures in the multi render target.
  82345. * Be carrefull as it will recreate all the data in the new texture.
  82346. * @param size Define the new size
  82347. */
  82348. resize(size: any): void;
  82349. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82350. /**
  82351. * Dispose the render targets and their associated resources
  82352. */
  82353. dispose(): void;
  82354. /**
  82355. * Release all the underlying texture used as draw buffers.
  82356. */
  82357. releaseInternalTextures(): void;
  82358. }
  82359. }
  82360. declare module BABYLON {
  82361. /**
  82362. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82364. */
  82365. export class Analyser {
  82366. /**
  82367. * Gets or sets the smoothing
  82368. * @ignorenaming
  82369. */
  82370. SMOOTHING: number;
  82371. /**
  82372. * Gets or sets the FFT table size
  82373. * @ignorenaming
  82374. */
  82375. FFT_SIZE: number;
  82376. /**
  82377. * Gets or sets the bar graph amplitude
  82378. * @ignorenaming
  82379. */
  82380. BARGRAPHAMPLITUDE: number;
  82381. /**
  82382. * Gets or sets the position of the debug canvas
  82383. * @ignorenaming
  82384. */
  82385. DEBUGCANVASPOS: {
  82386. x: number;
  82387. y: number;
  82388. };
  82389. /**
  82390. * Gets or sets the debug canvas size
  82391. * @ignorenaming
  82392. */
  82393. DEBUGCANVASSIZE: {
  82394. width: number;
  82395. height: number;
  82396. };
  82397. private _byteFreqs;
  82398. private _byteTime;
  82399. private _floatFreqs;
  82400. private _webAudioAnalyser;
  82401. private _debugCanvas;
  82402. private _debugCanvasContext;
  82403. private _scene;
  82404. private _registerFunc;
  82405. private _audioEngine;
  82406. /**
  82407. * Creates a new analyser
  82408. * @param scene defines hosting scene
  82409. */
  82410. constructor(scene: Scene);
  82411. /**
  82412. * Get the number of data values you will have to play with for the visualization
  82413. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82414. * @returns a number
  82415. */
  82416. getFrequencyBinCount(): number;
  82417. /**
  82418. * Gets the current frequency data as a byte array
  82419. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82420. * @returns a Uint8Array
  82421. */
  82422. getByteFrequencyData(): Uint8Array;
  82423. /**
  82424. * Gets the current waveform as a byte array
  82425. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82426. * @returns a Uint8Array
  82427. */
  82428. getByteTimeDomainData(): Uint8Array;
  82429. /**
  82430. * Gets the current frequency data as a float array
  82431. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82432. * @returns a Float32Array
  82433. */
  82434. getFloatFrequencyData(): Float32Array;
  82435. /**
  82436. * Renders the debug canvas
  82437. */
  82438. drawDebugCanvas(): void;
  82439. /**
  82440. * Stops rendering the debug canvas and removes it
  82441. */
  82442. stopDebugCanvas(): void;
  82443. /**
  82444. * Connects two audio nodes
  82445. * @param inputAudioNode defines first node to connect
  82446. * @param outputAudioNode defines second node to connect
  82447. */
  82448. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82449. /**
  82450. * Releases all associated resources
  82451. */
  82452. dispose(): void;
  82453. }
  82454. }
  82455. declare module BABYLON {
  82456. /**
  82457. * This represents an audio engine and it is responsible
  82458. * to play, synchronize and analyse sounds throughout the application.
  82459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82460. */
  82461. export interface IAudioEngine extends IDisposable {
  82462. /**
  82463. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82464. */
  82465. readonly canUseWebAudio: boolean;
  82466. /**
  82467. * Gets the current AudioContext if available.
  82468. */
  82469. readonly audioContext: Nullable<AudioContext>;
  82470. /**
  82471. * The master gain node defines the global audio volume of your audio engine.
  82472. */
  82473. readonly masterGain: GainNode;
  82474. /**
  82475. * Gets whether or not mp3 are supported by your browser.
  82476. */
  82477. readonly isMP3supported: boolean;
  82478. /**
  82479. * Gets whether or not ogg are supported by your browser.
  82480. */
  82481. readonly isOGGsupported: boolean;
  82482. /**
  82483. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82484. * @ignoreNaming
  82485. */
  82486. WarnedWebAudioUnsupported: boolean;
  82487. /**
  82488. * Defines if the audio engine relies on a custom unlocked button.
  82489. * In this case, the embedded button will not be displayed.
  82490. */
  82491. useCustomUnlockedButton: boolean;
  82492. /**
  82493. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82494. */
  82495. readonly unlocked: boolean;
  82496. /**
  82497. * Event raised when audio has been unlocked on the browser.
  82498. */
  82499. onAudioUnlockedObservable: Observable<AudioEngine>;
  82500. /**
  82501. * Event raised when audio has been locked on the browser.
  82502. */
  82503. onAudioLockedObservable: Observable<AudioEngine>;
  82504. /**
  82505. * Flags the audio engine in Locked state.
  82506. * This happens due to new browser policies preventing audio to autoplay.
  82507. */
  82508. lock(): void;
  82509. /**
  82510. * Unlocks the audio engine once a user action has been done on the dom.
  82511. * This is helpful to resume play once browser policies have been satisfied.
  82512. */
  82513. unlock(): void;
  82514. }
  82515. /**
  82516. * This represents the default audio engine used in babylon.
  82517. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82519. */
  82520. export class AudioEngine implements IAudioEngine {
  82521. private _audioContext;
  82522. private _audioContextInitialized;
  82523. private _muteButton;
  82524. private _hostElement;
  82525. /**
  82526. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82527. */
  82528. canUseWebAudio: boolean;
  82529. /**
  82530. * The master gain node defines the global audio volume of your audio engine.
  82531. */
  82532. masterGain: GainNode;
  82533. /**
  82534. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82535. * @ignoreNaming
  82536. */
  82537. WarnedWebAudioUnsupported: boolean;
  82538. /**
  82539. * Gets whether or not mp3 are supported by your browser.
  82540. */
  82541. isMP3supported: boolean;
  82542. /**
  82543. * Gets whether or not ogg are supported by your browser.
  82544. */
  82545. isOGGsupported: boolean;
  82546. /**
  82547. * Gets whether audio has been unlocked on the device.
  82548. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82549. * a user interaction has happened.
  82550. */
  82551. unlocked: boolean;
  82552. /**
  82553. * Defines if the audio engine relies on a custom unlocked button.
  82554. * In this case, the embedded button will not be displayed.
  82555. */
  82556. useCustomUnlockedButton: boolean;
  82557. /**
  82558. * Event raised when audio has been unlocked on the browser.
  82559. */
  82560. onAudioUnlockedObservable: Observable<AudioEngine>;
  82561. /**
  82562. * Event raised when audio has been locked on the browser.
  82563. */
  82564. onAudioLockedObservable: Observable<AudioEngine>;
  82565. /**
  82566. * Gets the current AudioContext if available.
  82567. */
  82568. readonly audioContext: Nullable<AudioContext>;
  82569. private _connectedAnalyser;
  82570. /**
  82571. * Instantiates a new audio engine.
  82572. *
  82573. * There should be only one per page as some browsers restrict the number
  82574. * of audio contexts you can create.
  82575. * @param hostElement defines the host element where to display the mute icon if necessary
  82576. */
  82577. constructor(hostElement?: Nullable<HTMLElement>);
  82578. /**
  82579. * Flags the audio engine in Locked state.
  82580. * This happens due to new browser policies preventing audio to autoplay.
  82581. */
  82582. lock(): void;
  82583. /**
  82584. * Unlocks the audio engine once a user action has been done on the dom.
  82585. * This is helpful to resume play once browser policies have been satisfied.
  82586. */
  82587. unlock(): void;
  82588. private _resumeAudioContext;
  82589. private _initializeAudioContext;
  82590. private _tryToRun;
  82591. private _triggerRunningState;
  82592. private _triggerSuspendedState;
  82593. private _displayMuteButton;
  82594. private _moveButtonToTopLeft;
  82595. private _onResize;
  82596. private _hideMuteButton;
  82597. /**
  82598. * Destroy and release the resources associated with the audio ccontext.
  82599. */
  82600. dispose(): void;
  82601. /**
  82602. * Gets the global volume sets on the master gain.
  82603. * @returns the global volume if set or -1 otherwise
  82604. */
  82605. getGlobalVolume(): number;
  82606. /**
  82607. * Sets the global volume of your experience (sets on the master gain).
  82608. * @param newVolume Defines the new global volume of the application
  82609. */
  82610. setGlobalVolume(newVolume: number): void;
  82611. /**
  82612. * Connect the audio engine to an audio analyser allowing some amazing
  82613. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82615. * @param analyser The analyser to connect to the engine
  82616. */
  82617. connectToAnalyser(analyser: Analyser): void;
  82618. }
  82619. }
  82620. declare module BABYLON {
  82621. /**
  82622. * Interface used to present a loading screen while loading a scene
  82623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82624. */
  82625. export interface ILoadingScreen {
  82626. /**
  82627. * Function called to display the loading screen
  82628. */
  82629. displayLoadingUI: () => void;
  82630. /**
  82631. * Function called to hide the loading screen
  82632. */
  82633. hideLoadingUI: () => void;
  82634. /**
  82635. * Gets or sets the color to use for the background
  82636. */
  82637. loadingUIBackgroundColor: string;
  82638. /**
  82639. * Gets or sets the text to display while loading
  82640. */
  82641. loadingUIText: string;
  82642. }
  82643. /**
  82644. * Class used for the default loading screen
  82645. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82646. */
  82647. export class DefaultLoadingScreen implements ILoadingScreen {
  82648. private _renderingCanvas;
  82649. private _loadingText;
  82650. private _loadingDivBackgroundColor;
  82651. private _loadingDiv;
  82652. private _loadingTextDiv;
  82653. /**
  82654. * Creates a new default loading screen
  82655. * @param _renderingCanvas defines the canvas used to render the scene
  82656. * @param _loadingText defines the default text to display
  82657. * @param _loadingDivBackgroundColor defines the default background color
  82658. */
  82659. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82660. /**
  82661. * Function called to display the loading screen
  82662. */
  82663. displayLoadingUI(): void;
  82664. /**
  82665. * Function called to hide the loading screen
  82666. */
  82667. hideLoadingUI(): void;
  82668. /**
  82669. * Gets or sets the text to display while loading
  82670. */
  82671. loadingUIText: string;
  82672. /**
  82673. * Gets or sets the color to use for the background
  82674. */
  82675. loadingUIBackgroundColor: string;
  82676. private _resizeLoadingUI;
  82677. }
  82678. }
  82679. declare module BABYLON {
  82680. /**
  82681. * Settings for finer control over video usage
  82682. */
  82683. export interface VideoTextureSettings {
  82684. /**
  82685. * Applies `autoplay` to video, if specified
  82686. */
  82687. autoPlay?: boolean;
  82688. /**
  82689. * Applies `loop` to video, if specified
  82690. */
  82691. loop?: boolean;
  82692. /**
  82693. * Automatically updates internal texture from video at every frame in the render loop
  82694. */
  82695. autoUpdateTexture: boolean;
  82696. /**
  82697. * Image src displayed during the video loading or until the user interacts with the video.
  82698. */
  82699. poster?: string;
  82700. }
  82701. /**
  82702. * If you want to display a video in your scene, this is the special texture for that.
  82703. * This special texture works similar to other textures, with the exception of a few parameters.
  82704. * @see https://doc.babylonjs.com/how_to/video_texture
  82705. */
  82706. export class VideoTexture extends Texture {
  82707. /**
  82708. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82709. */
  82710. readonly autoUpdateTexture: boolean;
  82711. /**
  82712. * The video instance used by the texture internally
  82713. */
  82714. readonly video: HTMLVideoElement;
  82715. private _onUserActionRequestedObservable;
  82716. /**
  82717. * Event triggerd when a dom action is required by the user to play the video.
  82718. * This happens due to recent changes in browser policies preventing video to auto start.
  82719. */
  82720. readonly onUserActionRequestedObservable: Observable<Texture>;
  82721. private _generateMipMaps;
  82722. private _engine;
  82723. private _stillImageCaptured;
  82724. private _displayingPosterTexture;
  82725. private _settings;
  82726. private _createInternalTextureOnEvent;
  82727. /**
  82728. * Creates a video texture.
  82729. * If you want to display a video in your scene, this is the special texture for that.
  82730. * This special texture works similar to other textures, with the exception of a few parameters.
  82731. * @see https://doc.babylonjs.com/how_to/video_texture
  82732. * @param name optional name, will detect from video source, if not defined
  82733. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82734. * @param scene is obviously the current scene.
  82735. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82736. * @param invertY is false by default but can be used to invert video on Y axis
  82737. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82738. * @param settings allows finer control over video usage
  82739. */
  82740. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82741. private _getName;
  82742. private _getVideo;
  82743. private _createInternalTexture;
  82744. private reset;
  82745. /**
  82746. * @hidden Internal method to initiate `update`.
  82747. */
  82748. _rebuild(): void;
  82749. /**
  82750. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82751. */
  82752. update(): void;
  82753. /**
  82754. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82755. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82756. */
  82757. updateTexture(isVisible: boolean): void;
  82758. protected _updateInternalTexture: () => void;
  82759. /**
  82760. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82761. * @param url New url.
  82762. */
  82763. updateURL(url: string): void;
  82764. /**
  82765. * Dispose the texture and release its associated resources.
  82766. */
  82767. dispose(): void;
  82768. /**
  82769. * Creates a video texture straight from your WebCam video feed.
  82770. * @param scene Define the scene the texture should be created in
  82771. * @param onReady Define a callback to triggered once the texture will be ready
  82772. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82773. */
  82774. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82775. minWidth: number;
  82776. maxWidth: number;
  82777. minHeight: number;
  82778. maxHeight: number;
  82779. deviceId: string;
  82780. }): void;
  82781. }
  82782. }
  82783. declare module BABYLON {
  82784. /**
  82785. * Interface for attribute information associated with buffer instanciation
  82786. */
  82787. export class InstancingAttributeInfo {
  82788. /**
  82789. * Index/offset of the attribute in the vertex shader
  82790. */
  82791. index: number;
  82792. /**
  82793. * size of the attribute, 1, 2, 3 or 4
  82794. */
  82795. attributeSize: number;
  82796. /**
  82797. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82798. * default is FLOAT
  82799. */
  82800. attribyteType: number;
  82801. /**
  82802. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82803. */
  82804. normalized: boolean;
  82805. /**
  82806. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82807. */
  82808. offset: number;
  82809. /**
  82810. * Name of the GLSL attribute, for debugging purpose only
  82811. */
  82812. attributeName: string;
  82813. }
  82814. /**
  82815. * Define options used to create a depth texture
  82816. */
  82817. export class DepthTextureCreationOptions {
  82818. /** Specifies whether or not a stencil should be allocated in the texture */
  82819. generateStencil?: boolean;
  82820. /** Specifies whether or not bilinear filtering is enable on the texture */
  82821. bilinearFiltering?: boolean;
  82822. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82823. comparisonFunction?: number;
  82824. /** Specifies if the created texture is a cube texture */
  82825. isCube?: boolean;
  82826. }
  82827. /**
  82828. * Class used to describe the capabilities of the engine relatively to the current browser
  82829. */
  82830. export class EngineCapabilities {
  82831. /** Maximum textures units per fragment shader */
  82832. maxTexturesImageUnits: number;
  82833. /** Maximum texture units per vertex shader */
  82834. maxVertexTextureImageUnits: number;
  82835. /** Maximum textures units in the entire pipeline */
  82836. maxCombinedTexturesImageUnits: number;
  82837. /** Maximum texture size */
  82838. maxTextureSize: number;
  82839. /** Maximum cube texture size */
  82840. maxCubemapTextureSize: number;
  82841. /** Maximum render texture size */
  82842. maxRenderTextureSize: number;
  82843. /** Maximum number of vertex attributes */
  82844. maxVertexAttribs: number;
  82845. /** Maximum number of varyings */
  82846. maxVaryingVectors: number;
  82847. /** Maximum number of uniforms per vertex shader */
  82848. maxVertexUniformVectors: number;
  82849. /** Maximum number of uniforms per fragment shader */
  82850. maxFragmentUniformVectors: number;
  82851. /** Defines if standard derivates (dx/dy) are supported */
  82852. standardDerivatives: boolean;
  82853. /** Defines if s3tc texture compression is supported */
  82854. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82855. /** Defines if pvrtc texture compression is supported */
  82856. pvrtc: any;
  82857. /** Defines if etc1 texture compression is supported */
  82858. etc1: any;
  82859. /** Defines if etc2 texture compression is supported */
  82860. etc2: any;
  82861. /** Defines if astc texture compression is supported */
  82862. astc: any;
  82863. /** Defines if float textures are supported */
  82864. textureFloat: boolean;
  82865. /** Defines if vertex array objects are supported */
  82866. vertexArrayObject: boolean;
  82867. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82868. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82869. /** Gets the maximum level of anisotropy supported */
  82870. maxAnisotropy: number;
  82871. /** Defines if instancing is supported */
  82872. instancedArrays: boolean;
  82873. /** Defines if 32 bits indices are supported */
  82874. uintIndices: boolean;
  82875. /** Defines if high precision shaders are supported */
  82876. highPrecisionShaderSupported: boolean;
  82877. /** Defines if depth reading in the fragment shader is supported */
  82878. fragmentDepthSupported: boolean;
  82879. /** Defines if float texture linear filtering is supported*/
  82880. textureFloatLinearFiltering: boolean;
  82881. /** Defines if rendering to float textures is supported */
  82882. textureFloatRender: boolean;
  82883. /** Defines if half float textures are supported*/
  82884. textureHalfFloat: boolean;
  82885. /** Defines if half float texture linear filtering is supported*/
  82886. textureHalfFloatLinearFiltering: boolean;
  82887. /** Defines if rendering to half float textures is supported */
  82888. textureHalfFloatRender: boolean;
  82889. /** Defines if textureLOD shader command is supported */
  82890. textureLOD: boolean;
  82891. /** Defines if draw buffers extension is supported */
  82892. drawBuffersExtension: boolean;
  82893. /** Defines if depth textures are supported */
  82894. depthTextureExtension: boolean;
  82895. /** Defines if float color buffer are supported */
  82896. colorBufferFloat: boolean;
  82897. /** Gets disjoint timer query extension (null if not supported) */
  82898. timerQuery: EXT_disjoint_timer_query;
  82899. /** Defines if timestamp can be used with timer query */
  82900. canUseTimestampForTimerQuery: boolean;
  82901. /** Function used to let the system compiles shaders in background */
  82902. parallelShaderCompile: {
  82903. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82904. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82905. COMPLETION_STATUS_KHR: number;
  82906. };
  82907. }
  82908. /** Interface defining initialization parameters for Engine class */
  82909. export interface EngineOptions extends WebGLContextAttributes {
  82910. /**
  82911. * Defines if the engine should no exceed a specified device ratio
  82912. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82913. */
  82914. limitDeviceRatio?: number;
  82915. /**
  82916. * Defines if webvr should be enabled automatically
  82917. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82918. */
  82919. autoEnableWebVR?: boolean;
  82920. /**
  82921. * Defines if webgl2 should be turned off even if supported
  82922. * @see http://doc.babylonjs.com/features/webgl2
  82923. */
  82924. disableWebGL2Support?: boolean;
  82925. /**
  82926. * Defines if webaudio should be initialized as well
  82927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82928. */
  82929. audioEngine?: boolean;
  82930. /**
  82931. * Defines if animations should run using a deterministic lock step
  82932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82933. */
  82934. deterministicLockstep?: boolean;
  82935. /** Defines the maximum steps to use with deterministic lock step mode */
  82936. lockstepMaxSteps?: number;
  82937. /**
  82938. * Defines that engine should ignore context lost events
  82939. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82940. */
  82941. doNotHandleContextLost?: boolean;
  82942. /**
  82943. * Defines that engine should ignore modifying touch action attribute and style
  82944. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82945. */
  82946. doNotHandleTouchAction?: boolean;
  82947. }
  82948. /**
  82949. * Defines the interface used by display changed events
  82950. */
  82951. export interface IDisplayChangedEventArgs {
  82952. /** Gets the vrDisplay object (if any) */
  82953. vrDisplay: Nullable<any>;
  82954. /** Gets a boolean indicating if webVR is supported */
  82955. vrSupported: boolean;
  82956. }
  82957. /**
  82958. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82959. */
  82960. export class Engine {
  82961. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82962. static ExceptionList: ({
  82963. key: string;
  82964. capture: string;
  82965. captureConstraint: number;
  82966. targets: string[];
  82967. } | {
  82968. key: string;
  82969. capture: null;
  82970. captureConstraint: null;
  82971. targets: string[];
  82972. })[];
  82973. /** Gets the list of created engines */
  82974. static readonly Instances: Engine[];
  82975. /**
  82976. * Gets the latest created engine
  82977. */
  82978. static readonly LastCreatedEngine: Nullable<Engine>;
  82979. /**
  82980. * Gets the latest created scene
  82981. */
  82982. static readonly LastCreatedScene: Nullable<Scene>;
  82983. /**
  82984. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82985. * @param flag defines which part of the materials must be marked as dirty
  82986. * @param predicate defines a predicate used to filter which materials should be affected
  82987. */
  82988. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82989. /**
  82990. * Hidden
  82991. */
  82992. static _TextureLoaders: IInternalTextureLoader[];
  82993. /** Defines that alpha blending is disabled */
  82994. static readonly ALPHA_DISABLE: number;
  82995. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82996. static readonly ALPHA_ADD: number;
  82997. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82998. static readonly ALPHA_COMBINE: number;
  82999. /** Defines that alpha blending to DEST - SRC * DEST */
  83000. static readonly ALPHA_SUBTRACT: number;
  83001. /** Defines that alpha blending to SRC * DEST */
  83002. static readonly ALPHA_MULTIPLY: number;
  83003. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83004. static readonly ALPHA_MAXIMIZED: number;
  83005. /** Defines that alpha blending to SRC + DEST */
  83006. static readonly ALPHA_ONEONE: number;
  83007. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83008. static readonly ALPHA_PREMULTIPLIED: number;
  83009. /**
  83010. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83011. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83012. */
  83013. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83014. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83015. static readonly ALPHA_INTERPOLATE: number;
  83016. /**
  83017. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83018. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83019. */
  83020. static readonly ALPHA_SCREENMODE: number;
  83021. /** Defines that the ressource is not delayed*/
  83022. static readonly DELAYLOADSTATE_NONE: number;
  83023. /** Defines that the ressource was successfully delay loaded */
  83024. static readonly DELAYLOADSTATE_LOADED: number;
  83025. /** Defines that the ressource is currently delay loading */
  83026. static readonly DELAYLOADSTATE_LOADING: number;
  83027. /** Defines that the ressource is delayed and has not started loading */
  83028. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83029. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83030. static readonly NEVER: number;
  83031. /** 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 */
  83032. static readonly ALWAYS: number;
  83033. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83034. static readonly LESS: number;
  83035. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83036. static readonly EQUAL: number;
  83037. /** 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 */
  83038. static readonly LEQUAL: number;
  83039. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83040. static readonly GREATER: number;
  83041. /** 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 */
  83042. static readonly GEQUAL: number;
  83043. /** 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 */
  83044. static readonly NOTEQUAL: number;
  83045. /** Passed to stencilOperation to specify that stencil value must be kept */
  83046. static readonly KEEP: number;
  83047. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83048. static readonly REPLACE: number;
  83049. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83050. static readonly INCR: number;
  83051. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83052. static readonly DECR: number;
  83053. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83054. static readonly INVERT: number;
  83055. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83056. static readonly INCR_WRAP: number;
  83057. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83058. static readonly DECR_WRAP: number;
  83059. /** Texture is not repeating outside of 0..1 UVs */
  83060. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83061. /** Texture is repeating outside of 0..1 UVs */
  83062. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83063. /** Texture is repeating and mirrored */
  83064. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83065. /** ALPHA */
  83066. static readonly TEXTUREFORMAT_ALPHA: number;
  83067. /** LUMINANCE */
  83068. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83069. /** LUMINANCE_ALPHA */
  83070. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83071. /** RGB */
  83072. static readonly TEXTUREFORMAT_RGB: number;
  83073. /** RGBA */
  83074. static readonly TEXTUREFORMAT_RGBA: number;
  83075. /** RED */
  83076. static readonly TEXTUREFORMAT_RED: number;
  83077. /** RED (2nd reference) */
  83078. static readonly TEXTUREFORMAT_R: number;
  83079. /** RG */
  83080. static readonly TEXTUREFORMAT_RG: number;
  83081. /** RED_INTEGER */
  83082. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83083. /** RED_INTEGER (2nd reference) */
  83084. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83085. /** RG_INTEGER */
  83086. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83087. /** RGB_INTEGER */
  83088. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83089. /** RGBA_INTEGER */
  83090. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83091. /** UNSIGNED_BYTE */
  83092. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83093. /** UNSIGNED_BYTE (2nd reference) */
  83094. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83095. /** FLOAT */
  83096. static readonly TEXTURETYPE_FLOAT: number;
  83097. /** HALF_FLOAT */
  83098. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83099. /** BYTE */
  83100. static readonly TEXTURETYPE_BYTE: number;
  83101. /** SHORT */
  83102. static readonly TEXTURETYPE_SHORT: number;
  83103. /** UNSIGNED_SHORT */
  83104. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83105. /** INT */
  83106. static readonly TEXTURETYPE_INT: number;
  83107. /** UNSIGNED_INT */
  83108. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83109. /** UNSIGNED_SHORT_4_4_4_4 */
  83110. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83111. /** UNSIGNED_SHORT_5_5_5_1 */
  83112. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83113. /** UNSIGNED_SHORT_5_6_5 */
  83114. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83115. /** UNSIGNED_INT_2_10_10_10_REV */
  83116. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83117. /** UNSIGNED_INT_24_8 */
  83118. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83119. /** UNSIGNED_INT_10F_11F_11F_REV */
  83120. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83121. /** UNSIGNED_INT_5_9_9_9_REV */
  83122. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83123. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83124. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83125. /** nearest is mag = nearest and min = nearest and mip = linear */
  83126. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83127. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83128. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83129. /** Trilinear is mag = linear and min = linear and mip = linear */
  83130. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83131. /** nearest is mag = nearest and min = nearest and mip = linear */
  83132. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83133. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83134. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83135. /** Trilinear is mag = linear and min = linear and mip = linear */
  83136. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83137. /** mag = nearest and min = nearest and mip = nearest */
  83138. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83139. /** mag = nearest and min = linear and mip = nearest */
  83140. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83141. /** mag = nearest and min = linear and mip = linear */
  83142. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83143. /** mag = nearest and min = linear and mip = none */
  83144. static readonly TEXTURE_NEAREST_LINEAR: number;
  83145. /** mag = nearest and min = nearest and mip = none */
  83146. static readonly TEXTURE_NEAREST_NEAREST: number;
  83147. /** mag = linear and min = nearest and mip = nearest */
  83148. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83149. /** mag = linear and min = nearest and mip = linear */
  83150. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83151. /** mag = linear and min = linear and mip = none */
  83152. static readonly TEXTURE_LINEAR_LINEAR: number;
  83153. /** mag = linear and min = nearest and mip = none */
  83154. static readonly TEXTURE_LINEAR_NEAREST: number;
  83155. /** Explicit coordinates mode */
  83156. static readonly TEXTURE_EXPLICIT_MODE: number;
  83157. /** Spherical coordinates mode */
  83158. static readonly TEXTURE_SPHERICAL_MODE: number;
  83159. /** Planar coordinates mode */
  83160. static readonly TEXTURE_PLANAR_MODE: number;
  83161. /** Cubic coordinates mode */
  83162. static readonly TEXTURE_CUBIC_MODE: number;
  83163. /** Projection coordinates mode */
  83164. static readonly TEXTURE_PROJECTION_MODE: number;
  83165. /** Skybox coordinates mode */
  83166. static readonly TEXTURE_SKYBOX_MODE: number;
  83167. /** Inverse Cubic coordinates mode */
  83168. static readonly TEXTURE_INVCUBIC_MODE: number;
  83169. /** Equirectangular coordinates mode */
  83170. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83171. /** Equirectangular Fixed coordinates mode */
  83172. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83173. /** Equirectangular Fixed Mirrored coordinates mode */
  83174. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83175. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83176. static readonly SCALEMODE_FLOOR: number;
  83177. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83178. static readonly SCALEMODE_NEAREST: number;
  83179. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83180. static readonly SCALEMODE_CEILING: number;
  83181. /**
  83182. * Returns the current version of the framework
  83183. */
  83184. static readonly Version: string;
  83185. /**
  83186. * Returns a string describing the current engine
  83187. */
  83188. readonly description: string;
  83189. /**
  83190. * Gets or sets the epsilon value used by collision engine
  83191. */
  83192. static CollisionsEpsilon: number;
  83193. /**
  83194. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83195. */
  83196. static ShadersRepository: string;
  83197. /**
  83198. * Method called to create the default loading screen.
  83199. * This can be overriden in your own app.
  83200. * @param canvas The rendering canvas element
  83201. * @returns The loading screen
  83202. */
  83203. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83204. /**
  83205. * Method called to create the default rescale post process on each engine.
  83206. */
  83207. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83208. /**
  83209. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83210. */
  83211. forcePOTTextures: boolean;
  83212. /**
  83213. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83214. */
  83215. isFullscreen: boolean;
  83216. /**
  83217. * Gets a boolean indicating if the pointer is currently locked
  83218. */
  83219. isPointerLock: boolean;
  83220. /**
  83221. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83222. */
  83223. cullBackFaces: boolean;
  83224. /**
  83225. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83226. */
  83227. renderEvenInBackground: boolean;
  83228. /**
  83229. * Gets or sets a boolean indicating that cache can be kept between frames
  83230. */
  83231. preventCacheWipeBetweenFrames: boolean;
  83232. /**
  83233. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83234. **/
  83235. enableOfflineSupport: boolean;
  83236. /**
  83237. * 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)
  83238. **/
  83239. disableManifestCheck: boolean;
  83240. /**
  83241. * Gets the list of created scenes
  83242. */
  83243. scenes: Scene[];
  83244. /**
  83245. * Event raised when a new scene is created
  83246. */
  83247. onNewSceneAddedObservable: Observable<Scene>;
  83248. /**
  83249. * Gets the list of created postprocesses
  83250. */
  83251. postProcesses: PostProcess[];
  83252. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83253. validateShaderPrograms: boolean;
  83254. /**
  83255. * Observable event triggered each time the rendering canvas is resized
  83256. */
  83257. onResizeObservable: Observable<Engine>;
  83258. /**
  83259. * Observable event triggered each time the canvas loses focus
  83260. */
  83261. onCanvasBlurObservable: Observable<Engine>;
  83262. /**
  83263. * Observable event triggered each time the canvas gains focus
  83264. */
  83265. onCanvasFocusObservable: Observable<Engine>;
  83266. /**
  83267. * Observable event triggered each time the canvas receives pointerout event
  83268. */
  83269. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83270. /**
  83271. * Observable event triggered before each texture is initialized
  83272. */
  83273. onBeforeTextureInitObservable: Observable<Texture>;
  83274. private _vrDisplay;
  83275. private _vrSupported;
  83276. private _oldSize;
  83277. private _oldHardwareScaleFactor;
  83278. private _vrExclusivePointerMode;
  83279. private _webVRInitPromise;
  83280. /**
  83281. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83282. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83283. */
  83284. readonly isInVRExclusivePointerMode: boolean;
  83285. /**
  83286. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83287. */
  83288. disableUniformBuffers: boolean;
  83289. /** @hidden */
  83290. _uniformBuffers: UniformBuffer[];
  83291. /**
  83292. * Gets a boolean indicating that the engine supports uniform buffers
  83293. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83294. */
  83295. readonly supportsUniformBuffers: boolean;
  83296. /**
  83297. * Observable raised when the engine begins a new frame
  83298. */
  83299. onBeginFrameObservable: Observable<Engine>;
  83300. /**
  83301. * If set, will be used to request the next animation frame for the render loop
  83302. */
  83303. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83304. /**
  83305. * Observable raised when the engine ends the current frame
  83306. */
  83307. onEndFrameObservable: Observable<Engine>;
  83308. /**
  83309. * Observable raised when the engine is about to compile a shader
  83310. */
  83311. onBeforeShaderCompilationObservable: Observable<Engine>;
  83312. /**
  83313. * Observable raised when the engine has jsut compiled a shader
  83314. */
  83315. onAfterShaderCompilationObservable: Observable<Engine>;
  83316. /** @hidden */
  83317. _gl: WebGLRenderingContext;
  83318. private _renderingCanvas;
  83319. private _windowIsBackground;
  83320. private _webGLVersion;
  83321. /**
  83322. * Gets a boolean indicating that only power of 2 textures are supported
  83323. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83324. */
  83325. readonly needPOTTextures: boolean;
  83326. /** @hidden */
  83327. _badOS: boolean;
  83328. /** @hidden */
  83329. _badDesktopOS: boolean;
  83330. /**
  83331. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83332. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83333. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83334. */
  83335. disableTextureBindingOptimization: boolean;
  83336. /**
  83337. * Gets the audio engine
  83338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83339. * @ignorenaming
  83340. */
  83341. static audioEngine: IAudioEngine;
  83342. /**
  83343. * Default AudioEngine factory responsible of creating the Audio Engine.
  83344. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83345. */
  83346. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83347. /**
  83348. * Default offline support factory responsible of creating a tool used to store data locally.
  83349. * By default, this will create a Database object if the workload has been embedded.
  83350. */
  83351. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83352. private _onFocus;
  83353. private _onBlur;
  83354. private _onCanvasPointerOut;
  83355. private _onCanvasBlur;
  83356. private _onCanvasFocus;
  83357. private _onFullscreenChange;
  83358. private _onPointerLockChange;
  83359. private _onVRDisplayPointerRestricted;
  83360. private _onVRDisplayPointerUnrestricted;
  83361. private _onVrDisplayConnect;
  83362. private _onVrDisplayDisconnect;
  83363. private _onVrDisplayPresentChange;
  83364. /**
  83365. * Observable signaled when VR display mode changes
  83366. */
  83367. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83368. /**
  83369. * Observable signaled when VR request present is complete
  83370. */
  83371. onVRRequestPresentComplete: Observable<boolean>;
  83372. /**
  83373. * Observable signaled when VR request present starts
  83374. */
  83375. onVRRequestPresentStart: Observable<Engine>;
  83376. private _hardwareScalingLevel;
  83377. /** @hidden */
  83378. protected _caps: EngineCapabilities;
  83379. private _pointerLockRequested;
  83380. private _isStencilEnable;
  83381. private _colorWrite;
  83382. private _loadingScreen;
  83383. /** @hidden */
  83384. _drawCalls: PerfCounter;
  83385. /** @hidden */
  83386. _textureCollisions: PerfCounter;
  83387. private _glVersion;
  83388. private _glRenderer;
  83389. private _glVendor;
  83390. private _videoTextureSupported;
  83391. private _renderingQueueLaunched;
  83392. private _activeRenderLoops;
  83393. private _deterministicLockstep;
  83394. private _lockstepMaxSteps;
  83395. /**
  83396. * Observable signaled when a context lost event is raised
  83397. */
  83398. onContextLostObservable: Observable<Engine>;
  83399. /**
  83400. * Observable signaled when a context restored event is raised
  83401. */
  83402. onContextRestoredObservable: Observable<Engine>;
  83403. private _onContextLost;
  83404. private _onContextRestored;
  83405. private _contextWasLost;
  83406. private _doNotHandleContextLost;
  83407. /**
  83408. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83410. */
  83411. doNotHandleContextLost: boolean;
  83412. private _performanceMonitor;
  83413. private _fps;
  83414. private _deltaTime;
  83415. /**
  83416. * Turn this value on if you want to pause FPS computation when in background
  83417. */
  83418. disablePerformanceMonitorInBackground: boolean;
  83419. /**
  83420. * Gets the performance monitor attached to this engine
  83421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83422. */
  83423. readonly performanceMonitor: PerformanceMonitor;
  83424. /** @hidden */
  83425. protected _depthCullingState: _DepthCullingState;
  83426. /** @hidden */
  83427. protected _stencilState: _StencilState;
  83428. /** @hidden */
  83429. protected _alphaState: _AlphaState;
  83430. /** @hidden */
  83431. protected _alphaMode: number;
  83432. protected _internalTexturesCache: InternalTexture[];
  83433. /** @hidden */
  83434. protected _activeChannel: number;
  83435. private _currentTextureChannel;
  83436. /** @hidden */
  83437. protected _boundTexturesCache: {
  83438. [key: string]: Nullable<InternalTexture>;
  83439. };
  83440. /** @hidden */
  83441. protected _currentEffect: Nullable<Effect>;
  83442. /** @hidden */
  83443. protected _currentProgram: Nullable<WebGLProgram>;
  83444. private _compiledEffects;
  83445. private _vertexAttribArraysEnabled;
  83446. /** @hidden */
  83447. protected _cachedViewport: Nullable<Viewport>;
  83448. private _cachedVertexArrayObject;
  83449. /** @hidden */
  83450. protected _cachedVertexBuffers: any;
  83451. /** @hidden */
  83452. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83453. /** @hidden */
  83454. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83455. /** @hidden */
  83456. protected _currentRenderTarget: Nullable<InternalTexture>;
  83457. private _uintIndicesCurrentlySet;
  83458. private _currentBoundBuffer;
  83459. /** @hidden */
  83460. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83461. private _currentBufferPointers;
  83462. private _currentInstanceLocations;
  83463. private _currentInstanceBuffers;
  83464. private _textureUnits;
  83465. private _firstBoundInternalTextureTracker;
  83466. private _lastBoundInternalTextureTracker;
  83467. private _workingCanvas;
  83468. private _workingContext;
  83469. private _rescalePostProcess;
  83470. private _dummyFramebuffer;
  83471. private _externalData;
  83472. private _bindedRenderFunction;
  83473. private _vaoRecordInProgress;
  83474. private _mustWipeVertexAttributes;
  83475. private _emptyTexture;
  83476. private _emptyCubeTexture;
  83477. private _emptyTexture3D;
  83478. /** @hidden */
  83479. _frameHandler: number;
  83480. private _nextFreeTextureSlots;
  83481. private _maxSimultaneousTextures;
  83482. private _activeRequests;
  83483. private _texturesSupported;
  83484. private _textureFormatInUse;
  83485. /**
  83486. * Gets the list of texture formats supported
  83487. */
  83488. readonly texturesSupported: Array<string>;
  83489. /**
  83490. * Gets the list of texture formats in use
  83491. */
  83492. readonly textureFormatInUse: Nullable<string>;
  83493. /**
  83494. * Gets the current viewport
  83495. */
  83496. readonly currentViewport: Nullable<Viewport>;
  83497. /**
  83498. * Gets the default empty texture
  83499. */
  83500. readonly emptyTexture: InternalTexture;
  83501. /**
  83502. * Gets the default empty 3D texture
  83503. */
  83504. readonly emptyTexture3D: InternalTexture;
  83505. /**
  83506. * Gets the default empty cube texture
  83507. */
  83508. readonly emptyCubeTexture: InternalTexture;
  83509. /**
  83510. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83511. */
  83512. readonly premultipliedAlpha: boolean;
  83513. /**
  83514. * Creates a new engine
  83515. * @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
  83516. * @param antialias defines enable antialiasing (default: false)
  83517. * @param options defines further options to be sent to the getContext() function
  83518. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83519. */
  83520. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83521. private _disableTouchAction;
  83522. private _rebuildInternalTextures;
  83523. private _rebuildEffects;
  83524. /**
  83525. * Gets a boolean indicating if all created effects are ready
  83526. * @returns true if all effects are ready
  83527. */
  83528. areAllEffectsReady(): boolean;
  83529. private _rebuildBuffers;
  83530. private _initGLContext;
  83531. /**
  83532. * Gets version of the current webGL context
  83533. */
  83534. readonly webGLVersion: number;
  83535. /**
  83536. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83537. */
  83538. readonly isStencilEnable: boolean;
  83539. private _prepareWorkingCanvas;
  83540. /**
  83541. * Reset the texture cache to empty state
  83542. */
  83543. resetTextureCache(): void;
  83544. /**
  83545. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83547. * @returns true if engine is in deterministic lock step mode
  83548. */
  83549. isDeterministicLockStep(): boolean;
  83550. /**
  83551. * Gets the max steps when engine is running in deterministic lock step
  83552. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83553. * @returns the max steps
  83554. */
  83555. getLockstepMaxSteps(): number;
  83556. /**
  83557. * Gets an object containing information about the current webGL context
  83558. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83559. */
  83560. getGlInfo(): {
  83561. vendor: string;
  83562. renderer: string;
  83563. version: string;
  83564. };
  83565. /**
  83566. * Gets current aspect ratio
  83567. * @param camera defines the camera to use to get the aspect ratio
  83568. * @param useScreen defines if screen size must be used (or the current render target if any)
  83569. * @returns a number defining the aspect ratio
  83570. */
  83571. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83572. /**
  83573. * Gets current screen aspect ratio
  83574. * @returns a number defining the aspect ratio
  83575. */
  83576. getScreenAspectRatio(): number;
  83577. /**
  83578. * Gets the current render width
  83579. * @param useScreen defines if screen size must be used (or the current render target if any)
  83580. * @returns a number defining the current render width
  83581. */
  83582. getRenderWidth(useScreen?: boolean): number;
  83583. /**
  83584. * Gets the current render height
  83585. * @param useScreen defines if screen size must be used (or the current render target if any)
  83586. * @returns a number defining the current render height
  83587. */
  83588. getRenderHeight(useScreen?: boolean): number;
  83589. /**
  83590. * Gets the HTML canvas attached with the current webGL context
  83591. * @returns a HTML canvas
  83592. */
  83593. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83594. /**
  83595. * Gets the client rect of the HTML canvas attached with the current webGL context
  83596. * @returns a client rectanglee
  83597. */
  83598. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83599. /**
  83600. * Defines the hardware scaling level.
  83601. * By default the hardware scaling level is computed from the window device ratio.
  83602. * 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.
  83603. * @param level defines the level to use
  83604. */
  83605. setHardwareScalingLevel(level: number): void;
  83606. /**
  83607. * Gets the current hardware scaling level.
  83608. * By default the hardware scaling level is computed from the window device ratio.
  83609. * 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.
  83610. * @returns a number indicating the current hardware scaling level
  83611. */
  83612. getHardwareScalingLevel(): number;
  83613. /**
  83614. * Gets the list of loaded textures
  83615. * @returns an array containing all loaded textures
  83616. */
  83617. getLoadedTexturesCache(): InternalTexture[];
  83618. /**
  83619. * Gets the object containing all engine capabilities
  83620. * @returns the EngineCapabilities object
  83621. */
  83622. getCaps(): EngineCapabilities;
  83623. /**
  83624. * Gets the current depth function
  83625. * @returns a number defining the depth function
  83626. */
  83627. getDepthFunction(): Nullable<number>;
  83628. /**
  83629. * Sets the current depth function
  83630. * @param depthFunc defines the function to use
  83631. */
  83632. setDepthFunction(depthFunc: number): void;
  83633. /**
  83634. * Sets the current depth function to GREATER
  83635. */
  83636. setDepthFunctionToGreater(): void;
  83637. /**
  83638. * Sets the current depth function to GEQUAL
  83639. */
  83640. setDepthFunctionToGreaterOrEqual(): void;
  83641. /**
  83642. * Sets the current depth function to LESS
  83643. */
  83644. setDepthFunctionToLess(): void;
  83645. /**
  83646. * Sets the current depth function to LEQUAL
  83647. */
  83648. setDepthFunctionToLessOrEqual(): void;
  83649. /**
  83650. * Gets a boolean indicating if stencil buffer is enabled
  83651. * @returns the current stencil buffer state
  83652. */
  83653. getStencilBuffer(): boolean;
  83654. /**
  83655. * Enable or disable the stencil buffer
  83656. * @param enable defines if the stencil buffer must be enabled or disabled
  83657. */
  83658. setStencilBuffer(enable: boolean): void;
  83659. /**
  83660. * Gets the current stencil mask
  83661. * @returns a number defining the new stencil mask to use
  83662. */
  83663. getStencilMask(): number;
  83664. /**
  83665. * Sets the current stencil mask
  83666. * @param mask defines the new stencil mask to use
  83667. */
  83668. setStencilMask(mask: number): void;
  83669. /**
  83670. * Gets the current stencil function
  83671. * @returns a number defining the stencil function to use
  83672. */
  83673. getStencilFunction(): number;
  83674. /**
  83675. * Gets the current stencil reference value
  83676. * @returns a number defining the stencil reference value to use
  83677. */
  83678. getStencilFunctionReference(): number;
  83679. /**
  83680. * Gets the current stencil mask
  83681. * @returns a number defining the stencil mask to use
  83682. */
  83683. getStencilFunctionMask(): number;
  83684. /**
  83685. * Sets the current stencil function
  83686. * @param stencilFunc defines the new stencil function to use
  83687. */
  83688. setStencilFunction(stencilFunc: number): void;
  83689. /**
  83690. * Sets the current stencil reference
  83691. * @param reference defines the new stencil reference to use
  83692. */
  83693. setStencilFunctionReference(reference: number): void;
  83694. /**
  83695. * Sets the current stencil mask
  83696. * @param mask defines the new stencil mask to use
  83697. */
  83698. setStencilFunctionMask(mask: number): void;
  83699. /**
  83700. * Gets the current stencil operation when stencil fails
  83701. * @returns a number defining stencil operation to use when stencil fails
  83702. */
  83703. getStencilOperationFail(): number;
  83704. /**
  83705. * Gets the current stencil operation when depth fails
  83706. * @returns a number defining stencil operation to use when depth fails
  83707. */
  83708. getStencilOperationDepthFail(): number;
  83709. /**
  83710. * Gets the current stencil operation when stencil passes
  83711. * @returns a number defining stencil operation to use when stencil passes
  83712. */
  83713. getStencilOperationPass(): number;
  83714. /**
  83715. * Sets the stencil operation to use when stencil fails
  83716. * @param operation defines the stencil operation to use when stencil fails
  83717. */
  83718. setStencilOperationFail(operation: number): void;
  83719. /**
  83720. * Sets the stencil operation to use when depth fails
  83721. * @param operation defines the stencil operation to use when depth fails
  83722. */
  83723. setStencilOperationDepthFail(operation: number): void;
  83724. /**
  83725. * Sets the stencil operation to use when stencil passes
  83726. * @param operation defines the stencil operation to use when stencil passes
  83727. */
  83728. setStencilOperationPass(operation: number): void;
  83729. /**
  83730. * Sets a boolean indicating if the dithering state is enabled or disabled
  83731. * @param value defines the dithering state
  83732. */
  83733. setDitheringState(value: boolean): void;
  83734. /**
  83735. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83736. * @param value defines the rasterizer state
  83737. */
  83738. setRasterizerState(value: boolean): void;
  83739. /**
  83740. * stop executing a render loop function and remove it from the execution array
  83741. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83742. */
  83743. stopRenderLoop(renderFunction?: () => void): void;
  83744. /** @hidden */
  83745. _renderLoop(): void;
  83746. /**
  83747. * Register and execute a render loop. The engine can have more than one render function
  83748. * @param renderFunction defines the function to continuously execute
  83749. */
  83750. runRenderLoop(renderFunction: () => void): void;
  83751. /**
  83752. * Toggle full screen mode
  83753. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83754. */
  83755. switchFullscreen(requestPointerLock: boolean): void;
  83756. /**
  83757. * Enters full screen mode
  83758. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83759. */
  83760. enterFullscreen(requestPointerLock: boolean): void;
  83761. /**
  83762. * Exits full screen mode
  83763. */
  83764. exitFullscreen(): void;
  83765. /**
  83766. * Clear the current render buffer or the current render target (if any is set up)
  83767. * @param color defines the color to use
  83768. * @param backBuffer defines if the back buffer must be cleared
  83769. * @param depth defines if the depth buffer must be cleared
  83770. * @param stencil defines if the stencil buffer must be cleared
  83771. */
  83772. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83773. /**
  83774. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83775. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83776. * @param y defines the y-coordinate of the corner of the clear rectangle
  83777. * @param width defines the width of the clear rectangle
  83778. * @param height defines the height of the clear rectangle
  83779. * @param clearColor defines the clear color
  83780. */
  83781. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83782. /**
  83783. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83785. * @param y defines the y-coordinate of the corner of the clear rectangle
  83786. * @param width defines the width of the clear rectangle
  83787. * @param height defines the height of the clear rectangle
  83788. */
  83789. enableScissor(x: number, y: number, width: number, height: number): void;
  83790. /**
  83791. * Disable previously set scissor test rectangle
  83792. */
  83793. disableScissor(): void;
  83794. private _viewportCached;
  83795. /** @hidden */
  83796. _viewport(x: number, y: number, width: number, height: number): void;
  83797. /**
  83798. * Set the WebGL's viewport
  83799. * @param viewport defines the viewport element to be used
  83800. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83801. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83802. */
  83803. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83804. /**
  83805. * Directly set the WebGL Viewport
  83806. * @param x defines the x coordinate of the viewport (in screen space)
  83807. * @param y defines the y coordinate of the viewport (in screen space)
  83808. * @param width defines the width of the viewport (in screen space)
  83809. * @param height defines the height of the viewport (in screen space)
  83810. * @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
  83811. */
  83812. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83813. /**
  83814. * Begin a new frame
  83815. */
  83816. beginFrame(): void;
  83817. /**
  83818. * Enf the current frame
  83819. */
  83820. endFrame(): void;
  83821. /**
  83822. * Resize the view according to the canvas' size
  83823. */
  83824. resize(): void;
  83825. /**
  83826. * Force a specific size of the canvas
  83827. * @param width defines the new canvas' width
  83828. * @param height defines the new canvas' height
  83829. */
  83830. setSize(width: number, height: number): void;
  83831. /**
  83832. * Gets a boolean indicating if a webVR device was detected
  83833. * @returns true if a webVR device was detected
  83834. */
  83835. isVRDevicePresent(): boolean;
  83836. /**
  83837. * Gets the current webVR device
  83838. * @returns the current webVR device (or null)
  83839. */
  83840. getVRDevice(): any;
  83841. /**
  83842. * Initializes a webVR display and starts listening to display change events
  83843. * The onVRDisplayChangedObservable will be notified upon these changes
  83844. * @returns The onVRDisplayChangedObservable
  83845. */
  83846. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83847. /**
  83848. * Initializes a webVR display and starts listening to display change events
  83849. * The onVRDisplayChangedObservable will be notified upon these changes
  83850. * @returns A promise containing a VRDisplay and if vr is supported
  83851. */
  83852. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83853. /**
  83854. * Call this function to switch to webVR mode
  83855. * Will do nothing if webVR is not supported or if there is no webVR device
  83856. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83857. */
  83858. enableVR(): void;
  83859. /**
  83860. * Call this function to leave webVR mode
  83861. * Will do nothing if webVR is not supported or if there is no webVR device
  83862. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83863. */
  83864. disableVR(): void;
  83865. private _onVRFullScreenTriggered;
  83866. private _getVRDisplaysAsync;
  83867. /**
  83868. * Binds the frame buffer to the specified texture.
  83869. * @param texture The texture to render to or null for the default canvas
  83870. * @param faceIndex The face of the texture to render to in case of cube texture
  83871. * @param requiredWidth The width of the target to render to
  83872. * @param requiredHeight The height of the target to render to
  83873. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83874. * @param depthStencilTexture The depth stencil texture to use to render
  83875. * @param lodLevel defines le lod level to bind to the frame buffer
  83876. */
  83877. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83878. private bindUnboundFramebuffer;
  83879. /**
  83880. * Unbind the current render target texture from the webGL context
  83881. * @param texture defines the render target texture to unbind
  83882. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83883. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83884. */
  83885. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83886. /**
  83887. * Unbind a list of render target textures from the webGL context
  83888. * This is used only when drawBuffer extension or webGL2 are active
  83889. * @param textures defines the render target textures to unbind
  83890. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83891. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83892. */
  83893. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83894. /**
  83895. * Force the mipmap generation for the given render target texture
  83896. * @param texture defines the render target texture to use
  83897. */
  83898. generateMipMapsForCubemap(texture: InternalTexture): void;
  83899. /**
  83900. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83901. */
  83902. flushFramebuffer(): void;
  83903. /**
  83904. * Unbind the current render target and bind the default framebuffer
  83905. */
  83906. restoreDefaultFramebuffer(): void;
  83907. /**
  83908. * Create an uniform buffer
  83909. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83910. * @param elements defines the content of the uniform buffer
  83911. * @returns the webGL uniform buffer
  83912. */
  83913. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83914. /**
  83915. * Create a dynamic uniform buffer
  83916. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83917. * @param elements defines the content of the uniform buffer
  83918. * @returns the webGL uniform buffer
  83919. */
  83920. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83921. /**
  83922. * Update an existing uniform buffer
  83923. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83924. * @param uniformBuffer defines the target uniform buffer
  83925. * @param elements defines the content to update
  83926. * @param offset defines the offset in the uniform buffer where update should start
  83927. * @param count defines the size of the data to update
  83928. */
  83929. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83930. private _resetVertexBufferBinding;
  83931. /**
  83932. * Creates a vertex buffer
  83933. * @param data the data for the vertex buffer
  83934. * @returns the new WebGL static buffer
  83935. */
  83936. createVertexBuffer(data: DataArray): WebGLBuffer;
  83937. /**
  83938. * Creates a dynamic vertex buffer
  83939. * @param data the data for the dynamic vertex buffer
  83940. * @returns the new WebGL dynamic buffer
  83941. */
  83942. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83943. /**
  83944. * Update a dynamic index buffer
  83945. * @param indexBuffer defines the target index buffer
  83946. * @param indices defines the data to update
  83947. * @param offset defines the offset in the target index buffer where update should start
  83948. */
  83949. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83950. /**
  83951. * Updates a dynamic vertex buffer.
  83952. * @param vertexBuffer the vertex buffer to update
  83953. * @param data the data used to update the vertex buffer
  83954. * @param byteOffset the byte offset of the data
  83955. * @param byteLength the byte length of the data
  83956. */
  83957. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83958. private _resetIndexBufferBinding;
  83959. /**
  83960. * Creates a new index buffer
  83961. * @param indices defines the content of the index buffer
  83962. * @param updatable defines if the index buffer must be updatable
  83963. * @returns a new webGL buffer
  83964. */
  83965. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83966. /**
  83967. * Bind a webGL buffer to the webGL context
  83968. * @param buffer defines the buffer to bind
  83969. */
  83970. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83971. /**
  83972. * Bind an uniform buffer to the current webGL context
  83973. * @param buffer defines the buffer to bind
  83974. */
  83975. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83976. /**
  83977. * Bind a buffer to the current webGL context at a given location
  83978. * @param buffer defines the buffer to bind
  83979. * @param location defines the index where to bind the buffer
  83980. */
  83981. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83982. /**
  83983. * Bind a specific block at a given index in a specific shader program
  83984. * @param shaderProgram defines the shader program
  83985. * @param blockName defines the block name
  83986. * @param index defines the index where to bind the block
  83987. */
  83988. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83989. private bindIndexBuffer;
  83990. private bindBuffer;
  83991. /**
  83992. * update the bound buffer with the given data
  83993. * @param data defines the data to update
  83994. */
  83995. updateArrayBuffer(data: Float32Array): void;
  83996. private _vertexAttribPointer;
  83997. private _bindIndexBufferWithCache;
  83998. private _bindVertexBuffersAttributes;
  83999. /**
  84000. * Records a vertex array object
  84001. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84002. * @param vertexBuffers defines the list of vertex buffers to store
  84003. * @param indexBuffer defines the index buffer to store
  84004. * @param effect defines the effect to store
  84005. * @returns the new vertex array object
  84006. */
  84007. recordVertexArrayObject(vertexBuffers: {
  84008. [key: string]: VertexBuffer;
  84009. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84010. /**
  84011. * Bind a specific vertex array object
  84012. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84013. * @param vertexArrayObject defines the vertex array object to bind
  84014. * @param indexBuffer defines the index buffer to bind
  84015. */
  84016. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84017. /**
  84018. * Bind webGl buffers directly to the webGL context
  84019. * @param vertexBuffer defines the vertex buffer to bind
  84020. * @param indexBuffer defines the index buffer to bind
  84021. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84022. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84023. * @param effect defines the effect associated with the vertex buffer
  84024. */
  84025. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84026. private _unbindVertexArrayObject;
  84027. /**
  84028. * Bind a list of vertex buffers to the webGL context
  84029. * @param vertexBuffers defines the list of vertex buffers to bind
  84030. * @param indexBuffer defines the index buffer to bind
  84031. * @param effect defines the effect associated with the vertex buffers
  84032. */
  84033. bindBuffers(vertexBuffers: {
  84034. [key: string]: Nullable<VertexBuffer>;
  84035. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84036. /**
  84037. * Unbind all instance attributes
  84038. */
  84039. unbindInstanceAttributes(): void;
  84040. /**
  84041. * Release and free the memory of a vertex array object
  84042. * @param vao defines the vertex array object to delete
  84043. */
  84044. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84045. /** @hidden */
  84046. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84047. /**
  84048. * Creates a webGL buffer to use with instanciation
  84049. * @param capacity defines the size of the buffer
  84050. * @returns the webGL buffer
  84051. */
  84052. createInstancesBuffer(capacity: number): WebGLBuffer;
  84053. /**
  84054. * Delete a webGL buffer used with instanciation
  84055. * @param buffer defines the webGL buffer to delete
  84056. */
  84057. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84058. /**
  84059. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84060. * @param instancesBuffer defines the webGL buffer to update and bind
  84061. * @param data defines the data to store in the buffer
  84062. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84063. */
  84064. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84065. /**
  84066. * Apply all cached states (depth, culling, stencil and alpha)
  84067. */
  84068. applyStates(): void;
  84069. /**
  84070. * Send a draw order
  84071. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84072. * @param indexStart defines the starting index
  84073. * @param indexCount defines the number of index to draw
  84074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84075. */
  84076. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84077. /**
  84078. * Draw a list of points
  84079. * @param verticesStart defines the index of first vertex to draw
  84080. * @param verticesCount defines the count of vertices to draw
  84081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84082. */
  84083. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84084. /**
  84085. * Draw a list of unindexed primitives
  84086. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84087. * @param verticesStart defines the index of first vertex to draw
  84088. * @param verticesCount defines the count of vertices to draw
  84089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84090. */
  84091. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84092. /**
  84093. * Draw a list of indexed primitives
  84094. * @param fillMode defines the primitive to use
  84095. * @param indexStart defines the starting index
  84096. * @param indexCount defines the number of index to draw
  84097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84098. */
  84099. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84100. /**
  84101. * Draw a list of unindexed primitives
  84102. * @param fillMode defines the primitive to use
  84103. * @param verticesStart defines the index of first vertex to draw
  84104. * @param verticesCount defines the count of vertices to draw
  84105. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84106. */
  84107. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84108. private _drawMode;
  84109. /** @hidden */
  84110. _releaseEffect(effect: Effect): void;
  84111. /** @hidden */
  84112. _deleteProgram(program: WebGLProgram): void;
  84113. /**
  84114. * Create a new effect (used to store vertex/fragment shaders)
  84115. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84116. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84117. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84118. * @param samplers defines an array of string used to represent textures
  84119. * @param defines defines the string containing the defines to use to compile the shaders
  84120. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84121. * @param onCompiled defines a function to call when the effect creation is successful
  84122. * @param onError defines a function to call when the effect creation has failed
  84123. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84124. * @returns the new Effect
  84125. */
  84126. 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;
  84127. private _compileShader;
  84128. private _compileRawShader;
  84129. /**
  84130. * Directly creates a webGL program
  84131. * @param vertexCode defines the vertex shader code to use
  84132. * @param fragmentCode defines the fragment shader code to use
  84133. * @param context defines the webGL context to use (if not set, the current one will be used)
  84134. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84135. * @returns the new webGL program
  84136. */
  84137. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84138. /**
  84139. * Creates a webGL program
  84140. * @param vertexCode defines the vertex shader code to use
  84141. * @param fragmentCode defines the fragment shader code to use
  84142. * @param defines defines the string containing the defines to use to compile the shaders
  84143. * @param context defines the webGL context to use (if not set, the current one will be used)
  84144. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84145. * @returns the new webGL program
  84146. */
  84147. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84148. private _createShaderProgram;
  84149. private _finalizeProgram;
  84150. /** @hidden */
  84151. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84152. /** @hidden */
  84153. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84154. /**
  84155. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84156. * @param shaderProgram defines the webGL program to use
  84157. * @param uniformsNames defines the list of uniform names
  84158. * @returns an array of webGL uniform locations
  84159. */
  84160. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84161. /**
  84162. * Gets the lsit of active attributes for a given webGL program
  84163. * @param shaderProgram defines the webGL program to use
  84164. * @param attributesNames defines the list of attribute names to get
  84165. * @returns an array of indices indicating the offset of each attribute
  84166. */
  84167. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84168. /**
  84169. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84170. * @param effect defines the effect to activate
  84171. */
  84172. enableEffect(effect: Nullable<Effect>): void;
  84173. /**
  84174. * Set the value of an uniform to an array of int32
  84175. * @param uniform defines the webGL uniform location where to store the value
  84176. * @param array defines the array of int32 to store
  84177. */
  84178. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84179. /**
  84180. * Set the value of an uniform to an array of int32 (stored as vec2)
  84181. * @param uniform defines the webGL uniform location where to store the value
  84182. * @param array defines the array of int32 to store
  84183. */
  84184. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84185. /**
  84186. * Set the value of an uniform to an array of int32 (stored as vec3)
  84187. * @param uniform defines the webGL uniform location where to store the value
  84188. * @param array defines the array of int32 to store
  84189. */
  84190. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84191. /**
  84192. * Set the value of an uniform to an array of int32 (stored as vec4)
  84193. * @param uniform defines the webGL uniform location where to store the value
  84194. * @param array defines the array of int32 to store
  84195. */
  84196. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84197. /**
  84198. * Set the value of an uniform to an array of float32
  84199. * @param uniform defines the webGL uniform location where to store the value
  84200. * @param array defines the array of float32 to store
  84201. */
  84202. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84203. /**
  84204. * Set the value of an uniform to an array of float32 (stored as vec2)
  84205. * @param uniform defines the webGL uniform location where to store the value
  84206. * @param array defines the array of float32 to store
  84207. */
  84208. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84209. /**
  84210. * Set the value of an uniform to an array of float32 (stored as vec3)
  84211. * @param uniform defines the webGL uniform location where to store the value
  84212. * @param array defines the array of float32 to store
  84213. */
  84214. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84215. /**
  84216. * Set the value of an uniform to an array of float32 (stored as vec4)
  84217. * @param uniform defines the webGL uniform location where to store the value
  84218. * @param array defines the array of float32 to store
  84219. */
  84220. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84221. /**
  84222. * Set the value of an uniform to an array of number
  84223. * @param uniform defines the webGL uniform location where to store the value
  84224. * @param array defines the array of number to store
  84225. */
  84226. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84227. /**
  84228. * Set the value of an uniform to an array of number (stored as vec2)
  84229. * @param uniform defines the webGL uniform location where to store the value
  84230. * @param array defines the array of number to store
  84231. */
  84232. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84233. /**
  84234. * Set the value of an uniform to an array of number (stored as vec3)
  84235. * @param uniform defines the webGL uniform location where to store the value
  84236. * @param array defines the array of number to store
  84237. */
  84238. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84239. /**
  84240. * Set the value of an uniform to an array of number (stored as vec4)
  84241. * @param uniform defines the webGL uniform location where to store the value
  84242. * @param array defines the array of number to store
  84243. */
  84244. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84245. /**
  84246. * Set the value of an uniform to an array of float32 (stored as matrices)
  84247. * @param uniform defines the webGL uniform location where to store the value
  84248. * @param matrices defines the array of float32 to store
  84249. */
  84250. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84251. /**
  84252. * Set the value of an uniform to a matrix
  84253. * @param uniform defines the webGL uniform location where to store the value
  84254. * @param matrix defines the matrix to store
  84255. */
  84256. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84257. /**
  84258. * Set the value of an uniform to a matrix (3x3)
  84259. * @param uniform defines the webGL uniform location where to store the value
  84260. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84261. */
  84262. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84263. /**
  84264. * Set the value of an uniform to a matrix (2x2)
  84265. * @param uniform defines the webGL uniform location where to store the value
  84266. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84267. */
  84268. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84269. /**
  84270. * Set the value of an uniform to a number (int)
  84271. * @param uniform defines the webGL uniform location where to store the value
  84272. * @param value defines the int number to store
  84273. */
  84274. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84275. /**
  84276. * Set the value of an uniform to a number (float)
  84277. * @param uniform defines the webGL uniform location where to store the value
  84278. * @param value defines the float number to store
  84279. */
  84280. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84281. /**
  84282. * Set the value of an uniform to a vec2
  84283. * @param uniform defines the webGL uniform location where to store the value
  84284. * @param x defines the 1st component of the value
  84285. * @param y defines the 2nd component of the value
  84286. */
  84287. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84288. /**
  84289. * Set the value of an uniform to a vec3
  84290. * @param uniform defines the webGL uniform location where to store the value
  84291. * @param x defines the 1st component of the value
  84292. * @param y defines the 2nd component of the value
  84293. * @param z defines the 3rd component of the value
  84294. */
  84295. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84296. /**
  84297. * Set the value of an uniform to a boolean
  84298. * @param uniform defines the webGL uniform location where to store the value
  84299. * @param bool defines the boolean to store
  84300. */
  84301. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84302. /**
  84303. * Set the value of an uniform to a vec4
  84304. * @param uniform defines the webGL uniform location where to store the value
  84305. * @param x defines the 1st component of the value
  84306. * @param y defines the 2nd component of the value
  84307. * @param z defines the 3rd component of the value
  84308. * @param w defines the 4th component of the value
  84309. */
  84310. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84311. /**
  84312. * Set the value of an uniform to a Color3
  84313. * @param uniform defines the webGL uniform location where to store the value
  84314. * @param color3 defines the color to store
  84315. */
  84316. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84317. /**
  84318. * Set the value of an uniform to a Color3 and an alpha value
  84319. * @param uniform defines the webGL uniform location where to store the value
  84320. * @param color3 defines the color to store
  84321. * @param alpha defines the alpha component to store
  84322. */
  84323. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84324. /**
  84325. * Sets a Color4 on a uniform variable
  84326. * @param uniform defines the uniform location
  84327. * @param color4 defines the value to be set
  84328. */
  84329. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84330. /**
  84331. * Set various states to the webGL context
  84332. * @param culling defines backface culling state
  84333. * @param zOffset defines the value to apply to zOffset (0 by default)
  84334. * @param force defines if states must be applied even if cache is up to date
  84335. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84336. */
  84337. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84338. /**
  84339. * Set the z offset to apply to current rendering
  84340. * @param value defines the offset to apply
  84341. */
  84342. setZOffset(value: number): void;
  84343. /**
  84344. * Gets the current value of the zOffset
  84345. * @returns the current zOffset state
  84346. */
  84347. getZOffset(): number;
  84348. /**
  84349. * Enable or disable depth buffering
  84350. * @param enable defines the state to set
  84351. */
  84352. setDepthBuffer(enable: boolean): void;
  84353. /**
  84354. * Gets a boolean indicating if depth writing is enabled
  84355. * @returns the current depth writing state
  84356. */
  84357. getDepthWrite(): boolean;
  84358. /**
  84359. * Enable or disable depth writing
  84360. * @param enable defines the state to set
  84361. */
  84362. setDepthWrite(enable: boolean): void;
  84363. /**
  84364. * Enable or disable color writing
  84365. * @param enable defines the state to set
  84366. */
  84367. setColorWrite(enable: boolean): void;
  84368. /**
  84369. * Gets a boolean indicating if color writing is enabled
  84370. * @returns the current color writing state
  84371. */
  84372. getColorWrite(): boolean;
  84373. /**
  84374. * Sets alpha constants used by some alpha blending modes
  84375. * @param r defines the red component
  84376. * @param g defines the green component
  84377. * @param b defines the blue component
  84378. * @param a defines the alpha component
  84379. */
  84380. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84381. /**
  84382. * Sets the current alpha mode
  84383. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84384. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84386. */
  84387. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84388. /**
  84389. * Gets the current alpha mode
  84390. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84391. * @returns the current alpha mode
  84392. */
  84393. getAlphaMode(): number;
  84394. /**
  84395. * Clears the list of texture accessible through engine.
  84396. * This can help preventing texture load conflict due to name collision.
  84397. */
  84398. clearInternalTexturesCache(): void;
  84399. /**
  84400. * Force the entire cache to be cleared
  84401. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84402. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84403. */
  84404. wipeCaches(bruteForce?: boolean): void;
  84405. /**
  84406. * Set the compressed texture format to use, based on the formats you have, and the formats
  84407. * supported by the hardware / browser.
  84408. *
  84409. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84410. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84411. * to API arguments needed to compressed textures. This puts the burden on the container
  84412. * generator to house the arcane code for determining these for current & future formats.
  84413. *
  84414. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84415. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84416. *
  84417. * Note: The result of this call is not taken into account when a texture is base64.
  84418. *
  84419. * @param formatsAvailable defines the list of those format families you have created
  84420. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84421. *
  84422. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84423. * @returns The extension selected.
  84424. */
  84425. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84426. private _getSamplingParameters;
  84427. private _partialLoadImg;
  84428. private _cascadeLoadImgs;
  84429. /** @hidden */
  84430. _createTexture(): WebGLTexture;
  84431. /**
  84432. * Usually called from Texture.ts.
  84433. * Passed information to create a WebGLTexture
  84434. * @param urlArg defines a value which contains one of the following:
  84435. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84436. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84437. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84438. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84439. * @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)
  84440. * @param scene needed for loading to the correct scene
  84441. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84442. * @param onLoad optional callback to be called upon successful completion
  84443. * @param onError optional callback to be called upon failure
  84444. * @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
  84445. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84446. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84447. * @param forcedExtension defines the extension to use to pick the right loader
  84448. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84449. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84450. */
  84451. 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;
  84452. private _rescaleTexture;
  84453. /**
  84454. * Update a raw texture
  84455. * @param texture defines the texture to update
  84456. * @param data defines the data to store in the texture
  84457. * @param format defines the format of the data
  84458. * @param invertY defines if data must be stored with Y axis inverted
  84459. * @param compression defines the compression used (null by default)
  84460. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84461. */
  84462. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84463. /**
  84464. * Creates a raw texture
  84465. * @param data defines the data to store in the texture
  84466. * @param width defines the width of the texture
  84467. * @param height defines the height of the texture
  84468. * @param format defines the format of the data
  84469. * @param generateMipMaps defines if the engine should generate the mip levels
  84470. * @param invertY defines if data must be stored with Y axis inverted
  84471. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84472. * @param compression defines the compression used (null by default)
  84473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84474. * @returns the raw texture inside an InternalTexture
  84475. */
  84476. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84477. private _unpackFlipYCached;
  84478. /**
  84479. * In case you are sharing the context with other applications, it might
  84480. * be interested to not cache the unpack flip y state to ensure a consistent
  84481. * value would be set.
  84482. */
  84483. enableUnpackFlipYCached: boolean;
  84484. /** @hidden */
  84485. _unpackFlipY(value: boolean): void;
  84486. /** @hidden */
  84487. _getUnpackAlignement(): number;
  84488. /**
  84489. * Creates a dynamic texture
  84490. * @param width defines the width of the texture
  84491. * @param height defines the height of the texture
  84492. * @param generateMipMaps defines if the engine should generate the mip levels
  84493. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84494. * @returns the dynamic texture inside an InternalTexture
  84495. */
  84496. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84497. /**
  84498. * Update the sampling mode of a given texture
  84499. * @param samplingMode defines the required sampling mode
  84500. * @param texture defines the texture to update
  84501. */
  84502. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84503. /**
  84504. * Update the content of a dynamic texture
  84505. * @param texture defines the texture to update
  84506. * @param canvas defines the canvas containing the source
  84507. * @param invertY defines if data must be stored with Y axis inverted
  84508. * @param premulAlpha defines if alpha is stored as premultiplied
  84509. * @param format defines the format of the data
  84510. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84511. */
  84512. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84513. /**
  84514. * Update a video texture
  84515. * @param texture defines the texture to update
  84516. * @param video defines the video element to use
  84517. * @param invertY defines if data must be stored with Y axis inverted
  84518. */
  84519. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84520. /**
  84521. * Updates a depth texture Comparison Mode and Function.
  84522. * If the comparison Function is equal to 0, the mode will be set to none.
  84523. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84524. * @param texture The texture to set the comparison function for
  84525. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84526. */
  84527. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84528. private _setupDepthStencilTexture;
  84529. /**
  84530. * Creates a depth stencil texture.
  84531. * This is only available in WebGL 2 or with the depth texture extension available.
  84532. * @param size The size of face edge in the texture.
  84533. * @param options The options defining the texture.
  84534. * @returns The texture
  84535. */
  84536. createDepthStencilTexture(size: number | {
  84537. width: number;
  84538. height: number;
  84539. }, options: DepthTextureCreationOptions): InternalTexture;
  84540. /**
  84541. * Creates a depth stencil texture.
  84542. * This is only available in WebGL 2 or with the depth texture extension available.
  84543. * @param size The size of face edge in the texture.
  84544. * @param options The options defining the texture.
  84545. * @returns The texture
  84546. */
  84547. private _createDepthStencilTexture;
  84548. /**
  84549. * Creates a depth stencil cube texture.
  84550. * This is only available in WebGL 2.
  84551. * @param size The size of face edge in the cube texture.
  84552. * @param options The options defining the cube texture.
  84553. * @returns The cube texture
  84554. */
  84555. private _createDepthStencilCubeTexture;
  84556. /**
  84557. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84558. * @param renderTarget The render target to set the frame buffer for
  84559. */
  84560. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84561. /**
  84562. * Creates a new render target texture
  84563. * @param size defines the size of the texture
  84564. * @param options defines the options used to create the texture
  84565. * @returns a new render target texture stored in an InternalTexture
  84566. */
  84567. createRenderTargetTexture(size: number | {
  84568. width: number;
  84569. height: number;
  84570. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84571. /**
  84572. * Create a multi render target texture
  84573. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84574. * @param size defines the size of the texture
  84575. * @param options defines the creation options
  84576. * @returns the cube texture as an InternalTexture
  84577. */
  84578. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84579. private _setupFramebufferDepthAttachments;
  84580. /**
  84581. * Updates the sample count of a render target texture
  84582. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84583. * @param texture defines the texture to update
  84584. * @param samples defines the sample count to set
  84585. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84586. */
  84587. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84588. /**
  84589. * Update the sample count for a given multiple render target texture
  84590. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84591. * @param textures defines the textures to update
  84592. * @param samples defines the sample count to set
  84593. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84594. */
  84595. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84596. /** @hidden */
  84597. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84598. /** @hidden */
  84599. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84600. /** @hidden */
  84601. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84602. /** @hidden */
  84603. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84604. /**
  84605. * Creates a new render target cube texture
  84606. * @param size defines the size of the texture
  84607. * @param options defines the options used to create the texture
  84608. * @returns a new render target cube texture stored in an InternalTexture
  84609. */
  84610. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84611. /**
  84612. * Creates a cube texture
  84613. * @param rootUrl defines the url where the files to load is located
  84614. * @param scene defines the current scene
  84615. * @param files defines the list of files to load (1 per face)
  84616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84617. * @param onLoad defines an optional callback raised when the texture is loaded
  84618. * @param onError defines an optional callback raised if there is an issue to load the texture
  84619. * @param format defines the format of the data
  84620. * @param forcedExtension defines the extension to use to pick the right loader
  84621. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84622. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84623. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84624. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84625. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84626. * @returns the cube texture as an InternalTexture
  84627. */
  84628. 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;
  84629. /**
  84630. * @hidden
  84631. */
  84632. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84633. /**
  84634. * Update a raw cube texture
  84635. * @param texture defines the texture to udpdate
  84636. * @param data defines the data to store
  84637. * @param format defines the data format
  84638. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84639. * @param invertY defines if data must be stored with Y axis inverted
  84640. * @param compression defines the compression used (null by default)
  84641. * @param level defines which level of the texture to update
  84642. */
  84643. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84644. /**
  84645. * Creates a new raw cube texture
  84646. * @param data defines the array of data to use to create each face
  84647. * @param size defines the size of the textures
  84648. * @param format defines the format of the data
  84649. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84650. * @param generateMipMaps defines if the engine should generate the mip levels
  84651. * @param invertY defines if data must be stored with Y axis inverted
  84652. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84653. * @param compression defines the compression used (null by default)
  84654. * @returns the cube texture as an InternalTexture
  84655. */
  84656. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84657. /**
  84658. * Creates a new raw cube texture from a specified url
  84659. * @param url defines the url where the data is located
  84660. * @param scene defines the current scene
  84661. * @param size defines the size of the textures
  84662. * @param format defines the format of the data
  84663. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84664. * @param noMipmap defines if the engine should avoid generating the mip levels
  84665. * @param callback defines a callback used to extract texture data from loaded data
  84666. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84667. * @param onLoad defines a callback called when texture is loaded
  84668. * @param onError defines a callback called if there is an error
  84669. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84670. * @param invertY defines if data must be stored with Y axis inverted
  84671. * @returns the cube texture as an InternalTexture
  84672. */
  84673. 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;
  84674. /**
  84675. * Update a raw 3D texture
  84676. * @param texture defines the texture to update
  84677. * @param data defines the data to store
  84678. * @param format defines the data format
  84679. * @param invertY defines if data must be stored with Y axis inverted
  84680. * @param compression defines the used compression (can be null)
  84681. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84682. */
  84683. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84684. /**
  84685. * Creates a new raw 3D texture
  84686. * @param data defines the data used to create the texture
  84687. * @param width defines the width of the texture
  84688. * @param height defines the height of the texture
  84689. * @param depth defines the depth of the texture
  84690. * @param format defines the format of the texture
  84691. * @param generateMipMaps defines if the engine must generate mip levels
  84692. * @param invertY defines if data must be stored with Y axis inverted
  84693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84694. * @param compression defines the compressed used (can be null)
  84695. * @param textureType defines the compressed used (can be null)
  84696. * @returns a new raw 3D texture (stored in an InternalTexture)
  84697. */
  84698. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84699. private _prepareWebGLTextureContinuation;
  84700. private _prepareWebGLTexture;
  84701. private _convertRGBtoRGBATextureData;
  84702. /** @hidden */
  84703. _releaseFramebufferObjects(texture: InternalTexture): void;
  84704. /** @hidden */
  84705. _releaseTexture(texture: InternalTexture): void;
  84706. private setProgram;
  84707. private _boundUniforms;
  84708. /**
  84709. * Binds an effect to the webGL context
  84710. * @param effect defines the effect to bind
  84711. */
  84712. bindSamplers(effect: Effect): void;
  84713. private _moveBoundTextureOnTop;
  84714. private _getCorrectTextureChannel;
  84715. private _linkTrackers;
  84716. private _removeDesignatedSlot;
  84717. private _activateCurrentTexture;
  84718. /** @hidden */
  84719. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84720. /** @hidden */
  84721. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84722. /**
  84723. * Sets a texture to the webGL context from a postprocess
  84724. * @param channel defines the channel to use
  84725. * @param postProcess defines the source postprocess
  84726. */
  84727. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84728. /**
  84729. * Binds the output of the passed in post process to the texture channel specified
  84730. * @param channel The channel the texture should be bound to
  84731. * @param postProcess The post process which's output should be bound
  84732. */
  84733. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84734. /**
  84735. * Unbind all textures from the webGL context
  84736. */
  84737. unbindAllTextures(): void;
  84738. /**
  84739. * Sets a texture to the according uniform.
  84740. * @param channel The texture channel
  84741. * @param uniform The uniform to set
  84742. * @param texture The texture to apply
  84743. */
  84744. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84745. /**
  84746. * Sets a depth stencil texture from a render target to the according uniform.
  84747. * @param channel The texture channel
  84748. * @param uniform The uniform to set
  84749. * @param texture The render target texture containing the depth stencil texture to apply
  84750. */
  84751. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84752. private _bindSamplerUniformToChannel;
  84753. private _getTextureWrapMode;
  84754. private _setTexture;
  84755. /**
  84756. * Sets an array of texture to the webGL context
  84757. * @param channel defines the channel where the texture array must be set
  84758. * @param uniform defines the associated uniform location
  84759. * @param textures defines the array of textures to bind
  84760. */
  84761. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84762. /** @hidden */
  84763. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84764. private _setTextureParameterFloat;
  84765. private _setTextureParameterInteger;
  84766. /**
  84767. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84768. * @param x defines the x coordinate of the rectangle where pixels must be read
  84769. * @param y defines the y coordinate of the rectangle where pixels must be read
  84770. * @param width defines the width of the rectangle where pixels must be read
  84771. * @param height defines the height of the rectangle where pixels must be read
  84772. * @returns a Uint8Array containing RGBA colors
  84773. */
  84774. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84775. /**
  84776. * Add an externaly attached data from its key.
  84777. * This method call will fail and return false, if such key already exists.
  84778. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84779. * @param key the unique key that identifies the data
  84780. * @param data the data object to associate to the key for this Engine instance
  84781. * @return true if no such key were already present and the data was added successfully, false otherwise
  84782. */
  84783. addExternalData<T>(key: string, data: T): boolean;
  84784. /**
  84785. * Get an externaly attached data from its key
  84786. * @param key the unique key that identifies the data
  84787. * @return the associated data, if present (can be null), or undefined if not present
  84788. */
  84789. getExternalData<T>(key: string): T;
  84790. /**
  84791. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84792. * @param key the unique key that identifies the data
  84793. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84794. * @return the associated data, can be null if the factory returned null.
  84795. */
  84796. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84797. /**
  84798. * Remove an externaly attached data from the Engine instance
  84799. * @param key the unique key that identifies the data
  84800. * @return true if the data was successfully removed, false if it doesn't exist
  84801. */
  84802. removeExternalData(key: string): boolean;
  84803. /**
  84804. * Unbind all vertex attributes from the webGL context
  84805. */
  84806. unbindAllAttributes(): void;
  84807. /**
  84808. * 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
  84809. */
  84810. releaseEffects(): void;
  84811. /**
  84812. * Dispose and release all associated resources
  84813. */
  84814. dispose(): void;
  84815. /**
  84816. * Display the loading screen
  84817. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84818. */
  84819. displayLoadingUI(): void;
  84820. /**
  84821. * Hide the loading screen
  84822. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84823. */
  84824. hideLoadingUI(): void;
  84825. /**
  84826. * Gets the current loading screen object
  84827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84828. */
  84829. /**
  84830. * Sets the current loading screen object
  84831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84832. */
  84833. loadingScreen: ILoadingScreen;
  84834. /**
  84835. * Sets the current loading screen text
  84836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84837. */
  84838. loadingUIText: string;
  84839. /**
  84840. * Sets the current loading screen background color
  84841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84842. */
  84843. loadingUIBackgroundColor: string;
  84844. /**
  84845. * Attach a new callback raised when context lost event is fired
  84846. * @param callback defines the callback to call
  84847. */
  84848. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84849. /**
  84850. * Attach a new callback raised when context restored event is fired
  84851. * @param callback defines the callback to call
  84852. */
  84853. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84854. /**
  84855. * Gets the source code of the vertex shader associated with a specific webGL program
  84856. * @param program defines the program to use
  84857. * @returns a string containing the source code of the vertex shader associated with the program
  84858. */
  84859. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84860. /**
  84861. * Gets the source code of the fragment shader associated with a specific webGL program
  84862. * @param program defines the program to use
  84863. * @returns a string containing the source code of the fragment shader associated with the program
  84864. */
  84865. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84866. /**
  84867. * Get the current error code of the webGL context
  84868. * @returns the error code
  84869. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84870. */
  84871. getError(): number;
  84872. /**
  84873. * Gets the current framerate
  84874. * @returns a number representing the framerate
  84875. */
  84876. getFps(): number;
  84877. /**
  84878. * Gets the time spent between current and previous frame
  84879. * @returns a number representing the delta time in ms
  84880. */
  84881. getDeltaTime(): number;
  84882. private _measureFps;
  84883. /** @hidden */
  84884. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84885. private _canRenderToFloatFramebuffer;
  84886. private _canRenderToHalfFloatFramebuffer;
  84887. private _canRenderToFramebuffer;
  84888. /** @hidden */
  84889. _getWebGLTextureType(type: number): number;
  84890. private _getInternalFormat;
  84891. /** @hidden */
  84892. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84893. /** @hidden */
  84894. _getRGBAMultiSampleBufferFormat(type: number): number;
  84895. /** @hidden */
  84896. _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;
  84897. /** @hidden */
  84898. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84899. private _partialLoadFile;
  84900. private _cascadeLoadFiles;
  84901. /**
  84902. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84903. * @returns true if the engine can be created
  84904. * @ignorenaming
  84905. */
  84906. static isSupported(): boolean;
  84907. }
  84908. }
  84909. declare module BABYLON {
  84910. /**
  84911. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84912. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84913. */
  84914. export class EffectFallbacks {
  84915. private _defines;
  84916. private _currentRank;
  84917. private _maxRank;
  84918. private _mesh;
  84919. /**
  84920. * Removes the fallback from the bound mesh.
  84921. */
  84922. unBindMesh(): void;
  84923. /**
  84924. * Adds a fallback on the specified property.
  84925. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84926. * @param define The name of the define in the shader
  84927. */
  84928. addFallback(rank: number, define: string): void;
  84929. /**
  84930. * Sets the mesh to use CPU skinning when needing to fallback.
  84931. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84932. * @param mesh The mesh to use the fallbacks.
  84933. */
  84934. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84935. /**
  84936. * Checks to see if more fallbacks are still availible.
  84937. */
  84938. readonly isMoreFallbacks: boolean;
  84939. /**
  84940. * Removes the defines that shoould be removed when falling back.
  84941. * @param currentDefines defines the current define statements for the shader.
  84942. * @param effect defines the current effect we try to compile
  84943. * @returns The resulting defines with defines of the current rank removed.
  84944. */
  84945. reduce(currentDefines: string, effect: Effect): string;
  84946. }
  84947. /**
  84948. * Options to be used when creating an effect.
  84949. */
  84950. export class EffectCreationOptions {
  84951. /**
  84952. * Atrributes that will be used in the shader.
  84953. */
  84954. attributes: string[];
  84955. /**
  84956. * Uniform varible names that will be set in the shader.
  84957. */
  84958. uniformsNames: string[];
  84959. /**
  84960. * Uniform buffer varible names that will be set in the shader.
  84961. */
  84962. uniformBuffersNames: string[];
  84963. /**
  84964. * Sampler texture variable names that will be set in the shader.
  84965. */
  84966. samplers: string[];
  84967. /**
  84968. * Define statements that will be set in the shader.
  84969. */
  84970. defines: any;
  84971. /**
  84972. * Possible fallbacks for this effect to improve performance when needed.
  84973. */
  84974. fallbacks: Nullable<EffectFallbacks>;
  84975. /**
  84976. * Callback that will be called when the shader is compiled.
  84977. */
  84978. onCompiled: Nullable<(effect: Effect) => void>;
  84979. /**
  84980. * Callback that will be called if an error occurs during shader compilation.
  84981. */
  84982. onError: Nullable<(effect: Effect, errors: string) => void>;
  84983. /**
  84984. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84985. */
  84986. indexParameters: any;
  84987. /**
  84988. * Max number of lights that can be used in the shader.
  84989. */
  84990. maxSimultaneousLights: number;
  84991. /**
  84992. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84993. */
  84994. transformFeedbackVaryings: Nullable<string[]>;
  84995. }
  84996. /**
  84997. * Effect containing vertex and fragment shader that can be executed on an object.
  84998. */
  84999. export class Effect {
  85000. /**
  85001. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85002. */
  85003. static ShadersRepository: string;
  85004. /**
  85005. * Name of the effect.
  85006. */
  85007. name: any;
  85008. /**
  85009. * String container all the define statements that should be set on the shader.
  85010. */
  85011. defines: string;
  85012. /**
  85013. * Callback that will be called when the shader is compiled.
  85014. */
  85015. onCompiled: Nullable<(effect: Effect) => void>;
  85016. /**
  85017. * Callback that will be called if an error occurs during shader compilation.
  85018. */
  85019. onError: Nullable<(effect: Effect, errors: string) => void>;
  85020. /**
  85021. * Callback that will be called when effect is bound.
  85022. */
  85023. onBind: Nullable<(effect: Effect) => void>;
  85024. /**
  85025. * Unique ID of the effect.
  85026. */
  85027. uniqueId: number;
  85028. /**
  85029. * Observable that will be called when the shader is compiled.
  85030. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85031. */
  85032. onCompileObservable: Observable<Effect>;
  85033. /**
  85034. * Observable that will be called if an error occurs during shader compilation.
  85035. */
  85036. onErrorObservable: Observable<Effect>;
  85037. /** @hidden */
  85038. _onBindObservable: Nullable<Observable<Effect>>;
  85039. /**
  85040. * Observable that will be called when effect is bound.
  85041. */
  85042. readonly onBindObservable: Observable<Effect>;
  85043. /** @hidden */
  85044. _bonesComputationForcedToCPU: boolean;
  85045. private static _uniqueIdSeed;
  85046. private _engine;
  85047. private _uniformBuffersNames;
  85048. private _uniformsNames;
  85049. private _samplers;
  85050. private _isReady;
  85051. private _compilationError;
  85052. private _attributesNames;
  85053. private _attributes;
  85054. private _uniforms;
  85055. /**
  85056. * Key for the effect.
  85057. * @hidden
  85058. */
  85059. _key: string;
  85060. private _indexParameters;
  85061. private _fallbacks;
  85062. private _vertexSourceCode;
  85063. private _fragmentSourceCode;
  85064. private _vertexSourceCodeOverride;
  85065. private _fragmentSourceCodeOverride;
  85066. private _transformFeedbackVaryings;
  85067. /**
  85068. * Compiled shader to webGL program.
  85069. * @hidden
  85070. */
  85071. _program: WebGLProgram;
  85072. private _valueCache;
  85073. private static _baseCache;
  85074. /**
  85075. * Instantiates an effect.
  85076. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85077. * @param baseName Name of the effect.
  85078. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85079. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85080. * @param samplers List of sampler variables that will be passed to the shader.
  85081. * @param engine Engine to be used to render the effect
  85082. * @param defines Define statements to be added to the shader.
  85083. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85084. * @param onCompiled Callback that will be called when the shader is compiled.
  85085. * @param onError Callback that will be called if an error occurs during shader compilation.
  85086. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85087. */
  85088. 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);
  85089. /**
  85090. * Unique key for this effect
  85091. */
  85092. readonly key: string;
  85093. /**
  85094. * If the effect has been compiled and prepared.
  85095. * @returns if the effect is compiled and prepared.
  85096. */
  85097. isReady(): boolean;
  85098. /**
  85099. * The engine the effect was initialized with.
  85100. * @returns the engine.
  85101. */
  85102. getEngine(): Engine;
  85103. /**
  85104. * The compiled webGL program for the effect
  85105. * @returns the webGL program.
  85106. */
  85107. getProgram(): WebGLProgram;
  85108. /**
  85109. * The set of names of attribute variables for the shader.
  85110. * @returns An array of attribute names.
  85111. */
  85112. getAttributesNames(): string[];
  85113. /**
  85114. * Returns the attribute at the given index.
  85115. * @param index The index of the attribute.
  85116. * @returns The location of the attribute.
  85117. */
  85118. getAttributeLocation(index: number): number;
  85119. /**
  85120. * Returns the attribute based on the name of the variable.
  85121. * @param name of the attribute to look up.
  85122. * @returns the attribute location.
  85123. */
  85124. getAttributeLocationByName(name: string): number;
  85125. /**
  85126. * The number of attributes.
  85127. * @returns the numnber of attributes.
  85128. */
  85129. getAttributesCount(): number;
  85130. /**
  85131. * Gets the index of a uniform variable.
  85132. * @param uniformName of the uniform to look up.
  85133. * @returns the index.
  85134. */
  85135. getUniformIndex(uniformName: string): number;
  85136. /**
  85137. * Returns the attribute based on the name of the variable.
  85138. * @param uniformName of the uniform to look up.
  85139. * @returns the location of the uniform.
  85140. */
  85141. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85142. /**
  85143. * Returns an array of sampler variable names
  85144. * @returns The array of sampler variable neames.
  85145. */
  85146. getSamplers(): string[];
  85147. /**
  85148. * The error from the last compilation.
  85149. * @returns the error string.
  85150. */
  85151. getCompilationError(): string;
  85152. /**
  85153. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85154. * @param func The callback to be used.
  85155. */
  85156. executeWhenCompiled(func: (effect: Effect) => void): void;
  85157. private _checkIsReady;
  85158. /** @hidden */
  85159. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85160. /** @hidden */
  85161. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85162. /** @hidden */
  85163. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85164. private _processShaderConversion;
  85165. private _processIncludes;
  85166. private _processPrecision;
  85167. /**
  85168. * Recompiles the webGL program
  85169. * @param vertexSourceCode The source code for the vertex shader.
  85170. * @param fragmentSourceCode The source code for the fragment shader.
  85171. * @param onCompiled Callback called when completed.
  85172. * @param onError Callback called on error.
  85173. * @hidden
  85174. */
  85175. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85176. /**
  85177. * Gets the uniform locations of the the specified variable names
  85178. * @param names THe names of the variables to lookup.
  85179. * @returns Array of locations in the same order as variable names.
  85180. */
  85181. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85182. /**
  85183. * Prepares the effect
  85184. * @hidden
  85185. */
  85186. _prepareEffect(): void;
  85187. /**
  85188. * Checks if the effect is supported. (Must be called after compilation)
  85189. */
  85190. readonly isSupported: boolean;
  85191. /**
  85192. * Binds a texture to the engine to be used as output of the shader.
  85193. * @param channel Name of the output variable.
  85194. * @param texture Texture to bind.
  85195. * @hidden
  85196. */
  85197. _bindTexture(channel: string, texture: InternalTexture): void;
  85198. /**
  85199. * Sets a texture on the engine to be used in the shader.
  85200. * @param channel Name of the sampler variable.
  85201. * @param texture Texture to set.
  85202. */
  85203. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85204. /**
  85205. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85206. * @param channel Name of the sampler variable.
  85207. * @param texture Texture to set.
  85208. */
  85209. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85210. /**
  85211. * Sets an array of textures on the engine to be used in the shader.
  85212. * @param channel Name of the variable.
  85213. * @param textures Textures to set.
  85214. */
  85215. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85216. /**
  85217. * 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)
  85218. * @param channel Name of the sampler variable.
  85219. * @param postProcess Post process to get the input texture from.
  85220. */
  85221. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85222. /**
  85223. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85224. * 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)
  85225. * @param channel Name of the sampler variable.
  85226. * @param postProcess Post process to get the output texture from.
  85227. */
  85228. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85229. /** @hidden */
  85230. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85231. /** @hidden */
  85232. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85233. /** @hidden */
  85234. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85235. /** @hidden */
  85236. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85237. /**
  85238. * Binds a buffer to a uniform.
  85239. * @param buffer Buffer to bind.
  85240. * @param name Name of the uniform variable to bind to.
  85241. */
  85242. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85243. /**
  85244. * Binds block to a uniform.
  85245. * @param blockName Name of the block to bind.
  85246. * @param index Index to bind.
  85247. */
  85248. bindUniformBlock(blockName: string, index: number): void;
  85249. /**
  85250. * Sets an interger value on a uniform variable.
  85251. * @param uniformName Name of the variable.
  85252. * @param value Value to be set.
  85253. * @returns this effect.
  85254. */
  85255. setInt(uniformName: string, value: number): Effect;
  85256. /**
  85257. * Sets an int array on a uniform variable.
  85258. * @param uniformName Name of the variable.
  85259. * @param array array to be set.
  85260. * @returns this effect.
  85261. */
  85262. setIntArray(uniformName: string, array: Int32Array): Effect;
  85263. /**
  85264. * 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)
  85265. * @param uniformName Name of the variable.
  85266. * @param array array to be set.
  85267. * @returns this effect.
  85268. */
  85269. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85270. /**
  85271. * 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)
  85272. * @param uniformName Name of the variable.
  85273. * @param array array to be set.
  85274. * @returns this effect.
  85275. */
  85276. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85277. /**
  85278. * 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)
  85279. * @param uniformName Name of the variable.
  85280. * @param array array to be set.
  85281. * @returns this effect.
  85282. */
  85283. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85284. /**
  85285. * Sets an float array on a uniform variable.
  85286. * @param uniformName Name of the variable.
  85287. * @param array array to be set.
  85288. * @returns this effect.
  85289. */
  85290. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85291. /**
  85292. * 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)
  85293. * @param uniformName Name of the variable.
  85294. * @param array array to be set.
  85295. * @returns this effect.
  85296. */
  85297. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85298. /**
  85299. * 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)
  85300. * @param uniformName Name of the variable.
  85301. * @param array array to be set.
  85302. * @returns this effect.
  85303. */
  85304. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85305. /**
  85306. * 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)
  85307. * @param uniformName Name of the variable.
  85308. * @param array array to be set.
  85309. * @returns this effect.
  85310. */
  85311. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85312. /**
  85313. * Sets an array on a uniform variable.
  85314. * @param uniformName Name of the variable.
  85315. * @param array array to be set.
  85316. * @returns this effect.
  85317. */
  85318. setArray(uniformName: string, array: number[]): Effect;
  85319. /**
  85320. * 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)
  85321. * @param uniformName Name of the variable.
  85322. * @param array array to be set.
  85323. * @returns this effect.
  85324. */
  85325. setArray2(uniformName: string, array: number[]): Effect;
  85326. /**
  85327. * 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)
  85328. * @param uniformName Name of the variable.
  85329. * @param array array to be set.
  85330. * @returns this effect.
  85331. */
  85332. setArray3(uniformName: string, array: number[]): Effect;
  85333. /**
  85334. * 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)
  85335. * @param uniformName Name of the variable.
  85336. * @param array array to be set.
  85337. * @returns this effect.
  85338. */
  85339. setArray4(uniformName: string, array: number[]): Effect;
  85340. /**
  85341. * Sets matrices on a uniform variable.
  85342. * @param uniformName Name of the variable.
  85343. * @param matrices matrices to be set.
  85344. * @returns this effect.
  85345. */
  85346. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85347. /**
  85348. * Sets matrix on a uniform variable.
  85349. * @param uniformName Name of the variable.
  85350. * @param matrix matrix to be set.
  85351. * @returns this effect.
  85352. */
  85353. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85354. /**
  85355. * 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)
  85356. * @param uniformName Name of the variable.
  85357. * @param matrix matrix to be set.
  85358. * @returns this effect.
  85359. */
  85360. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85361. /**
  85362. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85363. * @param uniformName Name of the variable.
  85364. * @param matrix matrix to be set.
  85365. * @returns this effect.
  85366. */
  85367. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85368. /**
  85369. * Sets a float on a uniform variable.
  85370. * @param uniformName Name of the variable.
  85371. * @param value value to be set.
  85372. * @returns this effect.
  85373. */
  85374. setFloat(uniformName: string, value: number): Effect;
  85375. /**
  85376. * Sets a boolean on a uniform variable.
  85377. * @param uniformName Name of the variable.
  85378. * @param bool value to be set.
  85379. * @returns this effect.
  85380. */
  85381. setBool(uniformName: string, bool: boolean): Effect;
  85382. /**
  85383. * Sets a Vector2 on a uniform variable.
  85384. * @param uniformName Name of the variable.
  85385. * @param vector2 vector2 to be set.
  85386. * @returns this effect.
  85387. */
  85388. setVector2(uniformName: string, vector2: Vector2): Effect;
  85389. /**
  85390. * Sets a float2 on a uniform variable.
  85391. * @param uniformName Name of the variable.
  85392. * @param x First float in float2.
  85393. * @param y Second float in float2.
  85394. * @returns this effect.
  85395. */
  85396. setFloat2(uniformName: string, x: number, y: number): Effect;
  85397. /**
  85398. * Sets a Vector3 on a uniform variable.
  85399. * @param uniformName Name of the variable.
  85400. * @param vector3 Value to be set.
  85401. * @returns this effect.
  85402. */
  85403. setVector3(uniformName: string, vector3: Vector3): Effect;
  85404. /**
  85405. * Sets a float3 on a uniform variable.
  85406. * @param uniformName Name of the variable.
  85407. * @param x First float in float3.
  85408. * @param y Second float in float3.
  85409. * @param z Third float in float3.
  85410. * @returns this effect.
  85411. */
  85412. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85413. /**
  85414. * Sets a Vector4 on a uniform variable.
  85415. * @param uniformName Name of the variable.
  85416. * @param vector4 Value to be set.
  85417. * @returns this effect.
  85418. */
  85419. setVector4(uniformName: string, vector4: Vector4): Effect;
  85420. /**
  85421. * Sets a float4 on a uniform variable.
  85422. * @param uniformName Name of the variable.
  85423. * @param x First float in float4.
  85424. * @param y Second float in float4.
  85425. * @param z Third float in float4.
  85426. * @param w Fourth float in float4.
  85427. * @returns this effect.
  85428. */
  85429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85430. /**
  85431. * Sets a Color3 on a uniform variable.
  85432. * @param uniformName Name of the variable.
  85433. * @param color3 Value to be set.
  85434. * @returns this effect.
  85435. */
  85436. setColor3(uniformName: string, color3: Color3): Effect;
  85437. /**
  85438. * Sets a Color4 on a uniform variable.
  85439. * @param uniformName Name of the variable.
  85440. * @param color3 Value to be set.
  85441. * @param alpha Alpha value to be set.
  85442. * @returns this effect.
  85443. */
  85444. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85445. /**
  85446. * Sets a Color4 on a uniform variable
  85447. * @param uniformName defines the name of the variable
  85448. * @param color4 defines the value to be set
  85449. * @returns this effect.
  85450. */
  85451. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85452. /**
  85453. * This function will add a new shader to the shader store
  85454. * @param name the name of the shader
  85455. * @param pixelShader optional pixel shader content
  85456. * @param vertexShader optional vertex shader content
  85457. */
  85458. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85459. /**
  85460. * Store of each shader (The can be looked up using effect.key)
  85461. */
  85462. static ShadersStore: {
  85463. [key: string]: string;
  85464. };
  85465. /**
  85466. * Store of each included file for a shader (The can be looked up using effect.key)
  85467. */
  85468. static IncludesShadersStore: {
  85469. [key: string]: string;
  85470. };
  85471. /**
  85472. * Resets the cache of effects.
  85473. */
  85474. static ResetCache(): void;
  85475. }
  85476. }
  85477. declare module BABYLON {
  85478. /**
  85479. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85480. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85481. * 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;
  85482. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85483. */
  85484. export class ColorCurves {
  85485. private _dirty;
  85486. private _tempColor;
  85487. private _globalCurve;
  85488. private _highlightsCurve;
  85489. private _midtonesCurve;
  85490. private _shadowsCurve;
  85491. private _positiveCurve;
  85492. private _negativeCurve;
  85493. private _globalHue;
  85494. private _globalDensity;
  85495. private _globalSaturation;
  85496. private _globalExposure;
  85497. /**
  85498. * Gets the global Hue value.
  85499. * 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).
  85500. */
  85501. /**
  85502. * Sets the global Hue value.
  85503. * 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).
  85504. */
  85505. globalHue: number;
  85506. /**
  85507. * Gets the global Density value.
  85508. * 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.
  85509. * Values less than zero provide a filter of opposite hue.
  85510. */
  85511. /**
  85512. * Sets the global Density value.
  85513. * 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.
  85514. * Values less than zero provide a filter of opposite hue.
  85515. */
  85516. globalDensity: number;
  85517. /**
  85518. * Gets the global Saturation value.
  85519. * 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.
  85520. */
  85521. /**
  85522. * Sets the global Saturation value.
  85523. * 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.
  85524. */
  85525. globalSaturation: number;
  85526. /**
  85527. * Gets the global Exposure value.
  85528. * 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.
  85529. */
  85530. /**
  85531. * Sets the global Exposure value.
  85532. * 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.
  85533. */
  85534. globalExposure: number;
  85535. private _highlightsHue;
  85536. private _highlightsDensity;
  85537. private _highlightsSaturation;
  85538. private _highlightsExposure;
  85539. /**
  85540. * Gets the highlights Hue value.
  85541. * 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).
  85542. */
  85543. /**
  85544. * Sets the highlights Hue value.
  85545. * 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).
  85546. */
  85547. highlightsHue: number;
  85548. /**
  85549. * Gets the highlights Density value.
  85550. * 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.
  85551. * Values less than zero provide a filter of opposite hue.
  85552. */
  85553. /**
  85554. * Sets the highlights Density value.
  85555. * 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.
  85556. * Values less than zero provide a filter of opposite hue.
  85557. */
  85558. highlightsDensity: number;
  85559. /**
  85560. * Gets the highlights Saturation value.
  85561. * 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.
  85562. */
  85563. /**
  85564. * Sets the highlights Saturation value.
  85565. * 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.
  85566. */
  85567. highlightsSaturation: number;
  85568. /**
  85569. * Gets the highlights Exposure value.
  85570. * 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.
  85571. */
  85572. /**
  85573. * Sets the highlights Exposure value.
  85574. * 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.
  85575. */
  85576. highlightsExposure: number;
  85577. private _midtonesHue;
  85578. private _midtonesDensity;
  85579. private _midtonesSaturation;
  85580. private _midtonesExposure;
  85581. /**
  85582. * Gets the midtones Hue value.
  85583. * 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).
  85584. */
  85585. /**
  85586. * Sets the midtones Hue value.
  85587. * 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).
  85588. */
  85589. midtonesHue: number;
  85590. /**
  85591. * Gets the midtones Density value.
  85592. * 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.
  85593. * Values less than zero provide a filter of opposite hue.
  85594. */
  85595. /**
  85596. * Sets the midtones Density value.
  85597. * 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.
  85598. * Values less than zero provide a filter of opposite hue.
  85599. */
  85600. midtonesDensity: number;
  85601. /**
  85602. * Gets the midtones Saturation value.
  85603. * 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.
  85604. */
  85605. /**
  85606. * Sets the midtones Saturation value.
  85607. * 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.
  85608. */
  85609. midtonesSaturation: number;
  85610. /**
  85611. * Gets the midtones Exposure value.
  85612. * 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.
  85613. */
  85614. /**
  85615. * Sets the midtones Exposure value.
  85616. * 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.
  85617. */
  85618. midtonesExposure: number;
  85619. private _shadowsHue;
  85620. private _shadowsDensity;
  85621. private _shadowsSaturation;
  85622. private _shadowsExposure;
  85623. /**
  85624. * Gets the shadows Hue value.
  85625. * 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).
  85626. */
  85627. /**
  85628. * Sets the shadows Hue value.
  85629. * 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).
  85630. */
  85631. shadowsHue: number;
  85632. /**
  85633. * Gets the shadows Density value.
  85634. * 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.
  85635. * Values less than zero provide a filter of opposite hue.
  85636. */
  85637. /**
  85638. * Sets the shadows Density value.
  85639. * 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.
  85640. * Values less than zero provide a filter of opposite hue.
  85641. */
  85642. shadowsDensity: number;
  85643. /**
  85644. * Gets the shadows Saturation value.
  85645. * 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.
  85646. */
  85647. /**
  85648. * Sets the shadows Saturation value.
  85649. * 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.
  85650. */
  85651. shadowsSaturation: number;
  85652. /**
  85653. * Gets the shadows Exposure value.
  85654. * 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.
  85655. */
  85656. /**
  85657. * Sets the shadows Exposure value.
  85658. * 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.
  85659. */
  85660. shadowsExposure: number;
  85661. /**
  85662. * Returns the class name
  85663. * @returns The class name
  85664. */
  85665. getClassName(): string;
  85666. /**
  85667. * Binds the color curves to the shader.
  85668. * @param colorCurves The color curve to bind
  85669. * @param effect The effect to bind to
  85670. * @param positiveUniform The positive uniform shader parameter
  85671. * @param neutralUniform The neutral uniform shader parameter
  85672. * @param negativeUniform The negative uniform shader parameter
  85673. */
  85674. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85675. /**
  85676. * Prepare the list of uniforms associated with the ColorCurves effects.
  85677. * @param uniformsList The list of uniforms used in the effect
  85678. */
  85679. static PrepareUniforms(uniformsList: string[]): void;
  85680. /**
  85681. * Returns color grading data based on a hue, density, saturation and exposure value.
  85682. * @param filterHue The hue of the color filter.
  85683. * @param filterDensity The density of the color filter.
  85684. * @param saturation The saturation.
  85685. * @param exposure The exposure.
  85686. * @param result The result data container.
  85687. */
  85688. private getColorGradingDataToRef;
  85689. /**
  85690. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85691. * @param value The input slider value in range [-100,100].
  85692. * @returns Adjusted value.
  85693. */
  85694. private static applyColorGradingSliderNonlinear;
  85695. /**
  85696. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85697. * @param hue The hue (H) input.
  85698. * @param saturation The saturation (S) input.
  85699. * @param brightness The brightness (B) input.
  85700. * @result An RGBA color represented as Vector4.
  85701. */
  85702. private static fromHSBToRef;
  85703. /**
  85704. * Returns a value clamped between min and max
  85705. * @param value The value to clamp
  85706. * @param min The minimum of value
  85707. * @param max The maximum of value
  85708. * @returns The clamped value.
  85709. */
  85710. private static clamp;
  85711. /**
  85712. * Clones the current color curve instance.
  85713. * @return The cloned curves
  85714. */
  85715. clone(): ColorCurves;
  85716. /**
  85717. * Serializes the current color curve instance to a json representation.
  85718. * @return a JSON representation
  85719. */
  85720. serialize(): any;
  85721. /**
  85722. * Parses the color curve from a json representation.
  85723. * @param source the JSON source to parse
  85724. * @return The parsed curves
  85725. */
  85726. static Parse(source: any): ColorCurves;
  85727. }
  85728. }
  85729. declare module BABYLON {
  85730. /**
  85731. * Interface to follow in your material defines to integrate easily the
  85732. * Image proccessing functions.
  85733. * @hidden
  85734. */
  85735. export interface IImageProcessingConfigurationDefines {
  85736. IMAGEPROCESSING: boolean;
  85737. VIGNETTE: boolean;
  85738. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85739. VIGNETTEBLENDMODEOPAQUE: boolean;
  85740. TONEMAPPING: boolean;
  85741. TONEMAPPING_ACES: boolean;
  85742. CONTRAST: boolean;
  85743. EXPOSURE: boolean;
  85744. COLORCURVES: boolean;
  85745. COLORGRADING: boolean;
  85746. COLORGRADING3D: boolean;
  85747. SAMPLER3DGREENDEPTH: boolean;
  85748. SAMPLER3DBGRMAP: boolean;
  85749. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85750. }
  85751. /**
  85752. * @hidden
  85753. */
  85754. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85755. IMAGEPROCESSING: boolean;
  85756. VIGNETTE: boolean;
  85757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85758. VIGNETTEBLENDMODEOPAQUE: boolean;
  85759. TONEMAPPING: boolean;
  85760. TONEMAPPING_ACES: boolean;
  85761. CONTRAST: boolean;
  85762. COLORCURVES: boolean;
  85763. COLORGRADING: boolean;
  85764. COLORGRADING3D: boolean;
  85765. SAMPLER3DGREENDEPTH: boolean;
  85766. SAMPLER3DBGRMAP: boolean;
  85767. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85768. EXPOSURE: boolean;
  85769. constructor();
  85770. }
  85771. /**
  85772. * This groups together the common properties used for image processing either in direct forward pass
  85773. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85774. * or not.
  85775. */
  85776. export class ImageProcessingConfiguration {
  85777. /**
  85778. * Default tone mapping applied in BabylonJS.
  85779. */
  85780. static readonly TONEMAPPING_STANDARD: number;
  85781. /**
  85782. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85783. * to other engines rendering to increase portability.
  85784. */
  85785. static readonly TONEMAPPING_ACES: number;
  85786. /**
  85787. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85788. */
  85789. colorCurves: Nullable<ColorCurves>;
  85790. private _colorCurvesEnabled;
  85791. /**
  85792. * Gets wether the color curves effect is enabled.
  85793. */
  85794. /**
  85795. * Sets wether the color curves effect is enabled.
  85796. */
  85797. colorCurvesEnabled: boolean;
  85798. private _colorGradingTexture;
  85799. /**
  85800. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85801. */
  85802. /**
  85803. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85804. */
  85805. colorGradingTexture: Nullable<BaseTexture>;
  85806. private _colorGradingEnabled;
  85807. /**
  85808. * Gets wether the color grading effect is enabled.
  85809. */
  85810. /**
  85811. * Sets wether the color grading effect is enabled.
  85812. */
  85813. colorGradingEnabled: boolean;
  85814. private _colorGradingWithGreenDepth;
  85815. /**
  85816. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85817. */
  85818. /**
  85819. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85820. */
  85821. colorGradingWithGreenDepth: boolean;
  85822. private _colorGradingBGR;
  85823. /**
  85824. * Gets wether the color grading texture contains BGR values.
  85825. */
  85826. /**
  85827. * Sets wether the color grading texture contains BGR values.
  85828. */
  85829. colorGradingBGR: boolean;
  85830. /** @hidden */
  85831. _exposure: number;
  85832. /**
  85833. * Gets the Exposure used in the effect.
  85834. */
  85835. /**
  85836. * Sets the Exposure used in the effect.
  85837. */
  85838. exposure: number;
  85839. private _toneMappingEnabled;
  85840. /**
  85841. * Gets wether the tone mapping effect is enabled.
  85842. */
  85843. /**
  85844. * Sets wether the tone mapping effect is enabled.
  85845. */
  85846. toneMappingEnabled: boolean;
  85847. private _toneMappingType;
  85848. /**
  85849. * Gets the type of tone mapping effect.
  85850. */
  85851. /**
  85852. * Sets the type of tone mapping effect used in BabylonJS.
  85853. */
  85854. toneMappingType: number;
  85855. protected _contrast: number;
  85856. /**
  85857. * Gets the contrast used in the effect.
  85858. */
  85859. /**
  85860. * Sets the contrast used in the effect.
  85861. */
  85862. contrast: number;
  85863. /**
  85864. * Vignette stretch size.
  85865. */
  85866. vignetteStretch: number;
  85867. /**
  85868. * Vignette centre X Offset.
  85869. */
  85870. vignetteCentreX: number;
  85871. /**
  85872. * Vignette centre Y Offset.
  85873. */
  85874. vignetteCentreY: number;
  85875. /**
  85876. * Vignette weight or intensity of the vignette effect.
  85877. */
  85878. vignetteWeight: number;
  85879. /**
  85880. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85881. * if vignetteEnabled is set to true.
  85882. */
  85883. vignetteColor: Color4;
  85884. /**
  85885. * Camera field of view used by the Vignette effect.
  85886. */
  85887. vignetteCameraFov: number;
  85888. private _vignetteBlendMode;
  85889. /**
  85890. * Gets the vignette blend mode allowing different kind of effect.
  85891. */
  85892. /**
  85893. * Sets the vignette blend mode allowing different kind of effect.
  85894. */
  85895. vignetteBlendMode: number;
  85896. private _vignetteEnabled;
  85897. /**
  85898. * Gets wether the vignette effect is enabled.
  85899. */
  85900. /**
  85901. * Sets wether the vignette effect is enabled.
  85902. */
  85903. vignetteEnabled: boolean;
  85904. private _applyByPostProcess;
  85905. /**
  85906. * Gets wether the image processing is applied through a post process or not.
  85907. */
  85908. /**
  85909. * Sets wether the image processing is applied through a post process or not.
  85910. */
  85911. applyByPostProcess: boolean;
  85912. private _isEnabled;
  85913. /**
  85914. * Gets wether the image processing is enabled or not.
  85915. */
  85916. /**
  85917. * Sets wether the image processing is enabled or not.
  85918. */
  85919. isEnabled: boolean;
  85920. /**
  85921. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85922. */
  85923. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85924. /**
  85925. * Method called each time the image processing information changes requires to recompile the effect.
  85926. */
  85927. protected _updateParameters(): void;
  85928. /**
  85929. * Gets the current class name.
  85930. * @return "ImageProcessingConfiguration"
  85931. */
  85932. getClassName(): string;
  85933. /**
  85934. * Prepare the list of uniforms associated with the Image Processing effects.
  85935. * @param uniforms The list of uniforms used in the effect
  85936. * @param defines the list of defines currently in use
  85937. */
  85938. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85939. /**
  85940. * Prepare the list of samplers associated with the Image Processing effects.
  85941. * @param samplersList The list of uniforms used in the effect
  85942. * @param defines the list of defines currently in use
  85943. */
  85944. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85945. /**
  85946. * Prepare the list of defines associated to the shader.
  85947. * @param defines the list of defines to complete
  85948. * @param forPostProcess Define if we are currently in post process mode or not
  85949. */
  85950. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85951. /**
  85952. * Returns true if all the image processing information are ready.
  85953. * @returns True if ready, otherwise, false
  85954. */
  85955. isReady(): boolean;
  85956. /**
  85957. * Binds the image processing to the shader.
  85958. * @param effect The effect to bind to
  85959. * @param aspectRatio Define the current aspect ratio of the effect
  85960. */
  85961. bind(effect: Effect, aspectRatio?: number): void;
  85962. /**
  85963. * Clones the current image processing instance.
  85964. * @return The cloned image processing
  85965. */
  85966. clone(): ImageProcessingConfiguration;
  85967. /**
  85968. * Serializes the current image processing instance to a json representation.
  85969. * @return a JSON representation
  85970. */
  85971. serialize(): any;
  85972. /**
  85973. * Parses the image processing from a json representation.
  85974. * @param source the JSON source to parse
  85975. * @return The parsed image processing
  85976. */
  85977. static Parse(source: any): ImageProcessingConfiguration;
  85978. private static _VIGNETTEMODE_MULTIPLY;
  85979. private static _VIGNETTEMODE_OPAQUE;
  85980. /**
  85981. * Used to apply the vignette as a mix with the pixel color.
  85982. */
  85983. static readonly VIGNETTEMODE_MULTIPLY: number;
  85984. /**
  85985. * Used to apply the vignette as a replacement of the pixel color.
  85986. */
  85987. static readonly VIGNETTEMODE_OPAQUE: number;
  85988. }
  85989. }
  85990. declare module BABYLON {
  85991. /**
  85992. * This represents all the required information to add a fresnel effect on a material:
  85993. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85994. */
  85995. export class FresnelParameters {
  85996. private _isEnabled;
  85997. /**
  85998. * Define if the fresnel effect is enable or not.
  85999. */
  86000. isEnabled: boolean;
  86001. /**
  86002. * Define the color used on edges (grazing angle)
  86003. */
  86004. leftColor: Color3;
  86005. /**
  86006. * Define the color used on center
  86007. */
  86008. rightColor: Color3;
  86009. /**
  86010. * Define bias applied to computed fresnel term
  86011. */
  86012. bias: number;
  86013. /**
  86014. * Defined the power exponent applied to fresnel term
  86015. */
  86016. power: number;
  86017. /**
  86018. * Clones the current fresnel and its valuues
  86019. * @returns a clone fresnel configuration
  86020. */
  86021. clone(): FresnelParameters;
  86022. /**
  86023. * Serializes the current fresnel parameters to a JSON representation.
  86024. * @return the JSON serialization
  86025. */
  86026. serialize(): any;
  86027. /**
  86028. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86029. * @param parsedFresnelParameters Define the JSON representation
  86030. * @returns the parsed parameters
  86031. */
  86032. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86033. }
  86034. }
  86035. declare module BABYLON {
  86036. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86037. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86038. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86039. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86040. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86041. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86042. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86043. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86044. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86045. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86046. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86047. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86048. /**
  86049. * Decorator used to define property that can be serialized as reference to a camera
  86050. * @param sourceName defines the name of the property to decorate
  86051. */
  86052. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86053. /**
  86054. * Class used to help serialization objects
  86055. */
  86056. export class SerializationHelper {
  86057. /** hidden */
  86058. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86059. /** hidden */
  86060. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86061. /** hidden */
  86062. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86063. /** hidden */
  86064. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86065. /**
  86066. * Appends the serialized animations from the source animations
  86067. * @param source Source containing the animations
  86068. * @param destination Target to store the animations
  86069. */
  86070. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86071. /**
  86072. * Static function used to serialized a specific entity
  86073. * @param entity defines the entity to serialize
  86074. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86075. * @returns a JSON compatible object representing the serialization of the entity
  86076. */
  86077. static Serialize<T>(entity: T, serializationObject?: any): any;
  86078. /**
  86079. * Creates a new entity from a serialization data object
  86080. * @param creationFunction defines a function used to instanciated the new entity
  86081. * @param source defines the source serialization data
  86082. * @param scene defines the hosting scene
  86083. * @param rootUrl defines the root url for resources
  86084. * @returns a new entity
  86085. */
  86086. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86087. /**
  86088. * Clones an object
  86089. * @param creationFunction defines the function used to instanciate the new object
  86090. * @param source defines the source object
  86091. * @returns the cloned object
  86092. */
  86093. static Clone<T>(creationFunction: () => T, source: T): T;
  86094. /**
  86095. * Instanciates a new object based on a source one (some data will be shared between both object)
  86096. * @param creationFunction defines the function used to instanciate the new object
  86097. * @param source defines the source object
  86098. * @returns the new object
  86099. */
  86100. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86101. }
  86102. }
  86103. declare module BABYLON {
  86104. /**
  86105. * This is the base class of all the camera used in the application.
  86106. * @see http://doc.babylonjs.com/features/cameras
  86107. */
  86108. export class Camera extends Node {
  86109. /** @hidden */
  86110. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86111. /**
  86112. * This is the default projection mode used by the cameras.
  86113. * It helps recreating a feeling of perspective and better appreciate depth.
  86114. * This is the best way to simulate real life cameras.
  86115. */
  86116. static readonly PERSPECTIVE_CAMERA: number;
  86117. /**
  86118. * This helps creating camera with an orthographic mode.
  86119. * 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.
  86120. */
  86121. static readonly ORTHOGRAPHIC_CAMERA: number;
  86122. /**
  86123. * This is the default FOV mode for perspective cameras.
  86124. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86125. */
  86126. static readonly FOVMODE_VERTICAL_FIXED: number;
  86127. /**
  86128. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86129. */
  86130. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86131. /**
  86132. * This specifies ther is no need for a camera rig.
  86133. * Basically only one eye is rendered corresponding to the camera.
  86134. */
  86135. static readonly RIG_MODE_NONE: number;
  86136. /**
  86137. * Simulates a camera Rig with one blue eye and one red eye.
  86138. * This can be use with 3d blue and red glasses.
  86139. */
  86140. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86141. /**
  86142. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86143. */
  86144. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86145. /**
  86146. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86147. */
  86148. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86149. /**
  86150. * Defines that both eyes of the camera will be rendered over under each other.
  86151. */
  86152. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86153. /**
  86154. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86155. */
  86156. static readonly RIG_MODE_VR: number;
  86157. /**
  86158. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86159. */
  86160. static readonly RIG_MODE_WEBVR: number;
  86161. /**
  86162. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86163. */
  86164. static readonly RIG_MODE_CUSTOM: number;
  86165. /**
  86166. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86167. */
  86168. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86169. /**
  86170. * @hidden
  86171. * Might be removed once multiview will be a thing
  86172. */
  86173. static UseAlternateWebVRRendering: boolean;
  86174. /**
  86175. * Define the input manager associated with the camera.
  86176. */
  86177. inputs: CameraInputsManager<Camera>;
  86178. /**
  86179. * Define the current local position of the camera in the scene
  86180. */
  86181. position: Vector3;
  86182. /**
  86183. * The vector the camera should consider as up.
  86184. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86185. */
  86186. upVector: Vector3;
  86187. /**
  86188. * Define the current limit on the left side for an orthographic camera
  86189. * In scene unit
  86190. */
  86191. orthoLeft: Nullable<number>;
  86192. /**
  86193. * Define the current limit on the right side for an orthographic camera
  86194. * In scene unit
  86195. */
  86196. orthoRight: Nullable<number>;
  86197. /**
  86198. * Define the current limit on the bottom side for an orthographic camera
  86199. * In scene unit
  86200. */
  86201. orthoBottom: Nullable<number>;
  86202. /**
  86203. * Define the current limit on the top side for an orthographic camera
  86204. * In scene unit
  86205. */
  86206. orthoTop: Nullable<number>;
  86207. /**
  86208. * Field Of View is set in Radians. (default is 0.8)
  86209. */
  86210. fov: number;
  86211. /**
  86212. * Define the minimum distance the camera can see from.
  86213. * This is important to note that the depth buffer are not infinite and the closer it starts
  86214. * the more your scene might encounter depth fighting issue.
  86215. */
  86216. minZ: number;
  86217. /**
  86218. * Define the maximum distance the camera can see to.
  86219. * This is important to note that the depth buffer are not infinite and the further it end
  86220. * the more your scene might encounter depth fighting issue.
  86221. */
  86222. maxZ: number;
  86223. /**
  86224. * Define the default inertia of the camera.
  86225. * This helps giving a smooth feeling to the camera movement.
  86226. */
  86227. inertia: number;
  86228. /**
  86229. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86230. */
  86231. mode: number;
  86232. /**
  86233. * Define wether the camera is intermediate.
  86234. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86235. */
  86236. isIntermediate: boolean;
  86237. /**
  86238. * Define the viewport of the camera.
  86239. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86240. */
  86241. viewport: Viewport;
  86242. /**
  86243. * Restricts the camera to viewing objects with the same layerMask.
  86244. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86245. */
  86246. layerMask: number;
  86247. /**
  86248. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86249. */
  86250. fovMode: number;
  86251. /**
  86252. * Rig mode of the camera.
  86253. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86254. * This is normally controlled byt the camera themselves as internal use.
  86255. */
  86256. cameraRigMode: number;
  86257. /**
  86258. * Defines the distance between both "eyes" in case of a RIG
  86259. */
  86260. interaxialDistance: number;
  86261. /**
  86262. * Defines if stereoscopic rendering is done side by side or over under.
  86263. */
  86264. isStereoscopicSideBySide: boolean;
  86265. /**
  86266. * 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
  86267. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86268. * else in the scene.
  86269. */
  86270. customRenderTargets: RenderTargetTexture[];
  86271. /**
  86272. * When set, the camera will render to this render target instead of the default canvas
  86273. */
  86274. outputRenderTarget: Nullable<RenderTargetTexture>;
  86275. /**
  86276. * Observable triggered when the camera view matrix has changed.
  86277. */
  86278. onViewMatrixChangedObservable: Observable<Camera>;
  86279. /**
  86280. * Observable triggered when the camera Projection matrix has changed.
  86281. */
  86282. onProjectionMatrixChangedObservable: Observable<Camera>;
  86283. /**
  86284. * Observable triggered when the inputs have been processed.
  86285. */
  86286. onAfterCheckInputsObservable: Observable<Camera>;
  86287. /**
  86288. * Observable triggered when reset has been called and applied to the camera.
  86289. */
  86290. onRestoreStateObservable: Observable<Camera>;
  86291. /** @hidden */
  86292. _cameraRigParams: any;
  86293. /** @hidden */
  86294. _rigCameras: Camera[];
  86295. /** @hidden */
  86296. _rigPostProcess: Nullable<PostProcess>;
  86297. protected _webvrViewMatrix: Matrix;
  86298. /** @hidden */
  86299. _skipRendering: boolean;
  86300. /** @hidden */
  86301. _alternateCamera: Camera;
  86302. /** @hidden */
  86303. _projectionMatrix: Matrix;
  86304. /** @hidden */
  86305. _postProcesses: Nullable<PostProcess>[];
  86306. /** @hidden */
  86307. _activeMeshes: SmartArray<AbstractMesh>;
  86308. protected _globalPosition: Vector3;
  86309. /** hidden */
  86310. _computedViewMatrix: Matrix;
  86311. private _doNotComputeProjectionMatrix;
  86312. private _transformMatrix;
  86313. private _frustumPlanes;
  86314. private _refreshFrustumPlanes;
  86315. private _storedFov;
  86316. private _stateStored;
  86317. /**
  86318. * Instantiates a new camera object.
  86319. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86320. * @see http://doc.babylonjs.com/features/cameras
  86321. * @param name Defines the name of the camera in the scene
  86322. * @param position Defines the position of the camera
  86323. * @param scene Defines the scene the camera belongs too
  86324. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86325. */
  86326. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86327. /**
  86328. * Store current camera state (fov, position, etc..)
  86329. * @returns the camera
  86330. */
  86331. storeState(): Camera;
  86332. /**
  86333. * Restores the camera state values if it has been stored. You must call storeState() first
  86334. */
  86335. protected _restoreStateValues(): boolean;
  86336. /**
  86337. * Restored camera state. You must call storeState() first.
  86338. * @returns true if restored and false otherwise
  86339. */
  86340. restoreState(): boolean;
  86341. /**
  86342. * Gets the class name of the camera.
  86343. * @returns the class name
  86344. */
  86345. getClassName(): string;
  86346. /** @hidden */
  86347. readonly _isCamera: boolean;
  86348. /**
  86349. * Gets a string representation of the camera useful for debug purpose.
  86350. * @param fullDetails Defines that a more verboe level of logging is required
  86351. * @returns the string representation
  86352. */
  86353. toString(fullDetails?: boolean): string;
  86354. /**
  86355. * Gets the current world space position of the camera.
  86356. */
  86357. readonly globalPosition: Vector3;
  86358. /**
  86359. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86360. * @returns the active meshe list
  86361. */
  86362. getActiveMeshes(): SmartArray<AbstractMesh>;
  86363. /**
  86364. * Check wether a mesh is part of the current active mesh list of the camera
  86365. * @param mesh Defines the mesh to check
  86366. * @returns true if active, false otherwise
  86367. */
  86368. isActiveMesh(mesh: Mesh): boolean;
  86369. /**
  86370. * Is this camera ready to be used/rendered
  86371. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86372. * @return true if the camera is ready
  86373. */
  86374. isReady(completeCheck?: boolean): boolean;
  86375. /** @hidden */
  86376. _initCache(): void;
  86377. /** @hidden */
  86378. _updateCache(ignoreParentClass?: boolean): void;
  86379. /** @hidden */
  86380. _isSynchronized(): boolean;
  86381. /** @hidden */
  86382. _isSynchronizedViewMatrix(): boolean;
  86383. /** @hidden */
  86384. _isSynchronizedProjectionMatrix(): boolean;
  86385. /**
  86386. * Attach the input controls to a specific dom element to get the input from.
  86387. * @param element Defines the element the controls should be listened from
  86388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86389. */
  86390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86391. /**
  86392. * Detach the current controls from the specified dom element.
  86393. * @param element Defines the element to stop listening the inputs from
  86394. */
  86395. detachControl(element: HTMLElement): void;
  86396. /**
  86397. * Update the camera state according to the different inputs gathered during the frame.
  86398. */
  86399. update(): void;
  86400. /** @hidden */
  86401. _checkInputs(): void;
  86402. /** @hidden */
  86403. readonly rigCameras: Camera[];
  86404. /**
  86405. * Gets the post process used by the rig cameras
  86406. */
  86407. readonly rigPostProcess: Nullable<PostProcess>;
  86408. /**
  86409. * Internal, gets the first post proces.
  86410. * @returns the first post process to be run on this camera.
  86411. */
  86412. _getFirstPostProcess(): Nullable<PostProcess>;
  86413. private _cascadePostProcessesToRigCams;
  86414. /**
  86415. * Attach a post process to the camera.
  86416. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86417. * @param postProcess The post process to attach to the camera
  86418. * @param insertAt The position of the post process in case several of them are in use in the scene
  86419. * @returns the position the post process has been inserted at
  86420. */
  86421. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86422. /**
  86423. * Detach a post process to the camera.
  86424. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86425. * @param postProcess The post process to detach from the camera
  86426. */
  86427. detachPostProcess(postProcess: PostProcess): void;
  86428. /**
  86429. * Gets the current world matrix of the camera
  86430. */
  86431. getWorldMatrix(): Matrix;
  86432. /** @hidden */
  86433. _getViewMatrix(): Matrix;
  86434. /**
  86435. * Gets the current view matrix of the camera.
  86436. * @param force forces the camera to recompute the matrix without looking at the cached state
  86437. * @returns the view matrix
  86438. */
  86439. getViewMatrix(force?: boolean): Matrix;
  86440. /**
  86441. * Freeze the projection matrix.
  86442. * It will prevent the cache check of the camera projection compute and can speed up perf
  86443. * if no parameter of the camera are meant to change
  86444. * @param projection Defines manually a projection if necessary
  86445. */
  86446. freezeProjectionMatrix(projection?: Matrix): void;
  86447. /**
  86448. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86449. */
  86450. unfreezeProjectionMatrix(): void;
  86451. /**
  86452. * Gets the current projection matrix of the camera.
  86453. * @param force forces the camera to recompute the matrix without looking at the cached state
  86454. * @returns the projection matrix
  86455. */
  86456. getProjectionMatrix(force?: boolean): Matrix;
  86457. /**
  86458. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86459. * @returns a Matrix
  86460. */
  86461. getTransformationMatrix(): Matrix;
  86462. private _updateFrustumPlanes;
  86463. /**
  86464. * Checks if a cullable object (mesh...) is in the camera frustum
  86465. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86466. * @param target The object to check
  86467. * @returns true if the object is in frustum otherwise false
  86468. */
  86469. isInFrustum(target: ICullable): boolean;
  86470. /**
  86471. * Checks if a cullable object (mesh...) is in the camera frustum
  86472. * Unlike isInFrustum this cheks the full bounding box
  86473. * @param target The object to check
  86474. * @returns true if the object is in frustum otherwise false
  86475. */
  86476. isCompletelyInFrustum(target: ICullable): boolean;
  86477. /**
  86478. * Gets a ray in the forward direction from the camera.
  86479. * @param length Defines the length of the ray to create
  86480. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86481. * @param origin Defines the start point of the ray which defaults to the camera position
  86482. * @returns the forward ray
  86483. */
  86484. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86485. /**
  86486. * Releases resources associated with this node.
  86487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86489. */
  86490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86491. /**
  86492. * Gets the left camera of a rig setup in case of Rigged Camera
  86493. */
  86494. readonly leftCamera: Nullable<FreeCamera>;
  86495. /**
  86496. * Gets the right camera of a rig setup in case of Rigged Camera
  86497. */
  86498. readonly rightCamera: Nullable<FreeCamera>;
  86499. /**
  86500. * Gets the left camera target of a rig setup in case of Rigged Camera
  86501. * @returns the target position
  86502. */
  86503. getLeftTarget(): Nullable<Vector3>;
  86504. /**
  86505. * Gets the right camera target of a rig setup in case of Rigged Camera
  86506. * @returns the target position
  86507. */
  86508. getRightTarget(): Nullable<Vector3>;
  86509. /**
  86510. * @hidden
  86511. */
  86512. setCameraRigMode(mode: number, rigParams: any): void;
  86513. /** @hidden */
  86514. static _setStereoscopicRigMode(camera: Camera): void;
  86515. /** @hidden */
  86516. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86517. /** @hidden */
  86518. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86519. /** @hidden */
  86520. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86521. /** @hidden */
  86522. _getVRProjectionMatrix(): Matrix;
  86523. protected _updateCameraRotationMatrix(): void;
  86524. protected _updateWebVRCameraRotationMatrix(): void;
  86525. /**
  86526. * This function MUST be overwritten by the different WebVR cameras available.
  86527. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86528. * @hidden
  86529. */
  86530. _getWebVRProjectionMatrix(): Matrix;
  86531. /**
  86532. * This function MUST be overwritten by the different WebVR cameras available.
  86533. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86534. * @hidden
  86535. */
  86536. _getWebVRViewMatrix(): Matrix;
  86537. /** @hidden */
  86538. setCameraRigParameter(name: string, value: any): void;
  86539. /**
  86540. * needs to be overridden by children so sub has required properties to be copied
  86541. * @hidden
  86542. */
  86543. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86544. /**
  86545. * May need to be overridden by children
  86546. * @hidden
  86547. */
  86548. _updateRigCameras(): void;
  86549. /** @hidden */
  86550. _setupInputs(): void;
  86551. /**
  86552. * Serialiaze the camera setup to a json represention
  86553. * @returns the JSON representation
  86554. */
  86555. serialize(): any;
  86556. /**
  86557. * Clones the current camera.
  86558. * @param name The cloned camera name
  86559. * @returns the cloned camera
  86560. */
  86561. clone(name: string): Camera;
  86562. /**
  86563. * Gets the direction of the camera relative to a given local axis.
  86564. * @param localAxis Defines the reference axis to provide a relative direction.
  86565. * @return the direction
  86566. */
  86567. getDirection(localAxis: Vector3): Vector3;
  86568. /**
  86569. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86570. * @param localAxis Defines the reference axis to provide a relative direction.
  86571. * @param result Defines the vector to store the result in
  86572. */
  86573. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86574. /**
  86575. * Gets a camera constructor for a given camera type
  86576. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86577. * @param name The name of the camera the result will be able to instantiate
  86578. * @param scene The scene the result will construct the camera in
  86579. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86580. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86581. * @returns a factory method to construc the camera
  86582. */
  86583. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86584. /**
  86585. * Compute the world matrix of the camera.
  86586. * @returns the camera workd matrix
  86587. */
  86588. computeWorldMatrix(): Matrix;
  86589. /**
  86590. * Parse a JSON and creates the camera from the parsed information
  86591. * @param parsedCamera The JSON to parse
  86592. * @param scene The scene to instantiate the camera in
  86593. * @returns the newly constructed camera
  86594. */
  86595. static Parse(parsedCamera: any, scene: Scene): Camera;
  86596. }
  86597. }
  86598. declare module BABYLON {
  86599. /**
  86600. * Interface for any object that can request an animation frame
  86601. */
  86602. export interface ICustomAnimationFrameRequester {
  86603. /**
  86604. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86605. */
  86606. renderFunction?: Function;
  86607. /**
  86608. * Called to request the next frame to render to
  86609. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86610. */
  86611. requestAnimationFrame: Function;
  86612. /**
  86613. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86614. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86615. */
  86616. requestID?: number;
  86617. }
  86618. /**
  86619. * Interface containing an array of animations
  86620. */
  86621. export interface IAnimatable {
  86622. /**
  86623. * Array of animations
  86624. */
  86625. animations: Array<Animation>;
  86626. }
  86627. /** Interface used by value gradients (color, factor, ...) */
  86628. export interface IValueGradient {
  86629. /**
  86630. * Gets or sets the gradient value (between 0 and 1)
  86631. */
  86632. gradient: number;
  86633. }
  86634. /** Class used to store color4 gradient */
  86635. export class ColorGradient implements IValueGradient {
  86636. /**
  86637. * Gets or sets the gradient value (between 0 and 1)
  86638. */
  86639. gradient: number;
  86640. /**
  86641. * Gets or sets first associated color
  86642. */
  86643. color1: Color4;
  86644. /**
  86645. * Gets or sets second associated color
  86646. */
  86647. color2?: Color4;
  86648. /**
  86649. * Will get a color picked randomly between color1 and color2.
  86650. * If color2 is undefined then color1 will be used
  86651. * @param result defines the target Color4 to store the result in
  86652. */
  86653. getColorToRef(result: Color4): void;
  86654. }
  86655. /** Class used to store color 3 gradient */
  86656. export class Color3Gradient implements IValueGradient {
  86657. /**
  86658. * Gets or sets the gradient value (between 0 and 1)
  86659. */
  86660. gradient: number;
  86661. /**
  86662. * Gets or sets the associated color
  86663. */
  86664. color: Color3;
  86665. }
  86666. /** Class used to store factor gradient */
  86667. export class FactorGradient implements IValueGradient {
  86668. /**
  86669. * Gets or sets the gradient value (between 0 and 1)
  86670. */
  86671. gradient: number;
  86672. /**
  86673. * Gets or sets first associated factor
  86674. */
  86675. factor1: number;
  86676. /**
  86677. * Gets or sets second associated factor
  86678. */
  86679. factor2?: number;
  86680. /**
  86681. * Will get a number picked randomly between factor1 and factor2.
  86682. * If factor2 is undefined then factor1 will be used
  86683. * @returns the picked number
  86684. */
  86685. getFactor(): number;
  86686. }
  86687. /**
  86688. * @ignore
  86689. * Application error to support additional information when loading a file
  86690. */
  86691. export class LoadFileError extends Error {
  86692. /** defines the optional XHR request */
  86693. request?: XMLHttpRequest | undefined;
  86694. private static _setPrototypeOf;
  86695. /**
  86696. * Creates a new LoadFileError
  86697. * @param message defines the message of the error
  86698. * @param request defines the optional XHR request
  86699. */
  86700. constructor(message: string,
  86701. /** defines the optional XHR request */
  86702. request?: XMLHttpRequest | undefined);
  86703. }
  86704. /**
  86705. * Class used to define a retry strategy when error happens while loading assets
  86706. */
  86707. export class RetryStrategy {
  86708. /**
  86709. * Function used to defines an exponential back off strategy
  86710. * @param maxRetries defines the maximum number of retries (3 by default)
  86711. * @param baseInterval defines the interval between retries
  86712. * @returns the strategy function to use
  86713. */
  86714. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86715. }
  86716. /**
  86717. * File request interface
  86718. */
  86719. export interface IFileRequest {
  86720. /**
  86721. * Raised when the request is complete (success or error).
  86722. */
  86723. onCompleteObservable: Observable<IFileRequest>;
  86724. /**
  86725. * Aborts the request for a file.
  86726. */
  86727. abort: () => void;
  86728. }
  86729. /**
  86730. * Class containing a set of static utilities functions
  86731. */
  86732. export class Tools {
  86733. /**
  86734. * Gets or sets the base URL to use to load assets
  86735. */
  86736. static BaseUrl: string;
  86737. /**
  86738. * Enable/Disable Custom HTTP Request Headers globally.
  86739. * default = false
  86740. * @see CustomRequestHeaders
  86741. */
  86742. static UseCustomRequestHeaders: boolean;
  86743. /**
  86744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86745. * i.e. when loading files, where the server/service expects an Authorization header.
  86746. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86747. */
  86748. static CustomRequestHeaders: {
  86749. [key: string]: string;
  86750. };
  86751. /**
  86752. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86753. */
  86754. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86755. /**
  86756. * Default behaviour for cors in the application.
  86757. * It can be a string if the expected behavior is identical in the entire app.
  86758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86759. */
  86760. static CorsBehavior: string | ((url: string | string[]) => string);
  86761. /**
  86762. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86763. * @ignorenaming
  86764. */
  86765. static UseFallbackTexture: boolean;
  86766. /**
  86767. * Use this object to register external classes like custom textures or material
  86768. * to allow the laoders to instantiate them
  86769. */
  86770. static RegisteredExternalClasses: {
  86771. [key: string]: Object;
  86772. };
  86773. /**
  86774. * Texture content used if a texture cannot loaded
  86775. * @ignorenaming
  86776. */
  86777. static fallbackTexture: string;
  86778. /**
  86779. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86780. * @param u defines the coordinate on X axis
  86781. * @param v defines the coordinate on Y axis
  86782. * @param width defines the width of the source data
  86783. * @param height defines the height of the source data
  86784. * @param pixels defines the source byte array
  86785. * @param color defines the output color
  86786. */
  86787. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86788. /**
  86789. * Interpolates between a and b via alpha
  86790. * @param a The lower value (returned when alpha = 0)
  86791. * @param b The upper value (returned when alpha = 1)
  86792. * @param alpha The interpolation-factor
  86793. * @return The mixed value
  86794. */
  86795. static Mix(a: number, b: number, alpha: number): number;
  86796. /**
  86797. * Tries to instantiate a new object from a given class name
  86798. * @param className defines the class name to instantiate
  86799. * @returns the new object or null if the system was not able to do the instantiation
  86800. */
  86801. static Instantiate(className: string): any;
  86802. /**
  86803. * Provides a slice function that will work even on IE
  86804. * @param data defines the array to slice
  86805. * @param start defines the start of the data (optional)
  86806. * @param end defines the end of the data (optional)
  86807. * @returns the new sliced array
  86808. */
  86809. static Slice<T>(data: T, start?: number, end?: number): T;
  86810. /**
  86811. * Polyfill for setImmediate
  86812. * @param action defines the action to execute after the current execution block
  86813. */
  86814. static SetImmediate(action: () => void): void;
  86815. /**
  86816. * Function indicating if a number is an exponent of 2
  86817. * @param value defines the value to test
  86818. * @returns true if the value is an exponent of 2
  86819. */
  86820. static IsExponentOfTwo(value: number): boolean;
  86821. private static _tmpFloatArray;
  86822. /**
  86823. * Returns the nearest 32-bit single precision float representation of a Number
  86824. * @param value A Number. If the parameter is of a different type, it will get converted
  86825. * to a number or to NaN if it cannot be converted
  86826. * @returns number
  86827. */
  86828. static FloatRound(value: number): number;
  86829. /**
  86830. * Find the next highest power of two.
  86831. * @param x Number to start search from.
  86832. * @return Next highest power of two.
  86833. */
  86834. static CeilingPOT(x: number): number;
  86835. /**
  86836. * Find the next lowest power of two.
  86837. * @param x Number to start search from.
  86838. * @return Next lowest power of two.
  86839. */
  86840. static FloorPOT(x: number): number;
  86841. /**
  86842. * Find the nearest power of two.
  86843. * @param x Number to start search from.
  86844. * @return Next nearest power of two.
  86845. */
  86846. static NearestPOT(x: number): number;
  86847. /**
  86848. * Get the closest exponent of two
  86849. * @param value defines the value to approximate
  86850. * @param max defines the maximum value to return
  86851. * @param mode defines how to define the closest value
  86852. * @returns closest exponent of two of the given value
  86853. */
  86854. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86855. /**
  86856. * Extracts the filename from a path
  86857. * @param path defines the path to use
  86858. * @returns the filename
  86859. */
  86860. static GetFilename(path: string): string;
  86861. /**
  86862. * Extracts the "folder" part of a path (everything before the filename).
  86863. * @param uri The URI to extract the info from
  86864. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86865. * @returns The "folder" part of the path
  86866. */
  86867. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86868. /**
  86869. * Extracts text content from a DOM element hierarchy
  86870. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86871. */
  86872. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86873. /**
  86874. * Convert an angle in radians to degrees
  86875. * @param angle defines the angle to convert
  86876. * @returns the angle in degrees
  86877. */
  86878. static ToDegrees(angle: number): number;
  86879. /**
  86880. * Convert an angle in degrees to radians
  86881. * @param angle defines the angle to convert
  86882. * @returns the angle in radians
  86883. */
  86884. static ToRadians(angle: number): number;
  86885. /**
  86886. * Encode a buffer to a base64 string
  86887. * @param buffer defines the buffer to encode
  86888. * @returns the encoded string
  86889. */
  86890. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86891. /**
  86892. * Extracts minimum and maximum values from a list of indexed positions
  86893. * @param positions defines the positions to use
  86894. * @param indices defines the indices to the positions
  86895. * @param indexStart defines the start index
  86896. * @param indexCount defines the end index
  86897. * @param bias defines bias value to add to the result
  86898. * @return minimum and maximum values
  86899. */
  86900. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86901. minimum: Vector3;
  86902. maximum: Vector3;
  86903. };
  86904. /**
  86905. * Extracts minimum and maximum values from a list of positions
  86906. * @param positions defines the positions to use
  86907. * @param start defines the start index in the positions array
  86908. * @param count defines the number of positions to handle
  86909. * @param bias defines bias value to add to the result
  86910. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86911. * @return minimum and maximum values
  86912. */
  86913. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86914. minimum: Vector3;
  86915. maximum: Vector3;
  86916. };
  86917. /**
  86918. * Returns an array if obj is not an array
  86919. * @param obj defines the object to evaluate as an array
  86920. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86921. * @returns either obj directly if obj is an array or a new array containing obj
  86922. */
  86923. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86924. /**
  86925. * Gets the pointer prefix to use
  86926. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86927. */
  86928. static GetPointerPrefix(): string;
  86929. /**
  86930. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86931. * @param func - the function to be called
  86932. * @param requester - the object that will request the next frame. Falls back to window.
  86933. * @returns frame number
  86934. */
  86935. static QueueNewFrame(func: () => void, requester?: any): number;
  86936. /**
  86937. * Ask the browser to promote the current element to fullscreen rendering mode
  86938. * @param element defines the DOM element to promote
  86939. */
  86940. static RequestFullscreen(element: HTMLElement): void;
  86941. /**
  86942. * Asks the browser to exit fullscreen mode
  86943. */
  86944. static ExitFullscreen(): void;
  86945. /**
  86946. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86947. * @param url define the url we are trying
  86948. * @param element define the dom element where to configure the cors policy
  86949. */
  86950. static SetCorsBehavior(url: string | string[], element: {
  86951. crossOrigin: string | null;
  86952. }): void;
  86953. /**
  86954. * Removes unwanted characters from an url
  86955. * @param url defines the url to clean
  86956. * @returns the cleaned url
  86957. */
  86958. static CleanUrl(url: string): string;
  86959. /**
  86960. * Gets or sets a function used to pre-process url before using them to load assets
  86961. */
  86962. static PreprocessUrl: (url: string) => string;
  86963. /**
  86964. * Loads an image as an HTMLImageElement.
  86965. * @param input url string, ArrayBuffer, or Blob to load
  86966. * @param onLoad callback called when the image successfully loads
  86967. * @param onError callback called when the image fails to load
  86968. * @param offlineProvider offline provider for caching
  86969. * @returns the HTMLImageElement of the loaded image
  86970. */
  86971. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86972. /**
  86973. * Loads a file
  86974. * @param url url string, ArrayBuffer, or Blob to load
  86975. * @param onSuccess callback called when the file successfully loads
  86976. * @param onProgress callback called while file is loading (if the server supports this mode)
  86977. * @param offlineProvider defines the offline provider for caching
  86978. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86979. * @param onError callback called when the file fails to load
  86980. * @returns a file request object
  86981. */
  86982. 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;
  86983. /**
  86984. * Load a script (identified by an url). When the url returns, the
  86985. * content of this file is added into a new script element, attached to the DOM (body element)
  86986. * @param scriptUrl defines the url of the script to laod
  86987. * @param onSuccess defines the callback called when the script is loaded
  86988. * @param onError defines the callback to call if an error occurs
  86989. */
  86990. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86991. /**
  86992. * Loads a file from a blob
  86993. * @param fileToLoad defines the blob to use
  86994. * @param callback defines the callback to call when data is loaded
  86995. * @param progressCallback defines the callback to call during loading process
  86996. * @returns a file request object
  86997. */
  86998. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86999. /**
  87000. * Loads a file
  87001. * @param fileToLoad defines the file to load
  87002. * @param callback defines the callback to call when data is loaded
  87003. * @param progressCallBack defines the callback to call during loading process
  87004. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87005. * @returns a file request object
  87006. */
  87007. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87008. /**
  87009. * Creates a data url from a given string content
  87010. * @param content defines the content to convert
  87011. * @returns the new data url link
  87012. */
  87013. static FileAsURL(content: string): string;
  87014. /**
  87015. * Format the given number to a specific decimal format
  87016. * @param value defines the number to format
  87017. * @param decimals defines the number of decimals to use
  87018. * @returns the formatted string
  87019. */
  87020. static Format(value: number, decimals?: number): string;
  87021. /**
  87022. * Checks if a given vector is inside a specific range
  87023. * @param v defines the vector to test
  87024. * @param min defines the minimum range
  87025. * @param max defines the maximum range
  87026. */
  87027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87028. /**
  87029. * Tries to copy an object by duplicating every property
  87030. * @param source defines the source object
  87031. * @param destination defines the target object
  87032. * @param doNotCopyList defines a list of properties to avoid
  87033. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87034. */
  87035. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87036. /**
  87037. * Gets a boolean indicating if the given object has no own property
  87038. * @param obj defines the object to test
  87039. * @returns true if object has no own property
  87040. */
  87041. static IsEmpty(obj: any): boolean;
  87042. /**
  87043. * Function used to register events at window level
  87044. * @param events defines the events to register
  87045. */
  87046. static RegisterTopRootEvents(events: {
  87047. name: string;
  87048. handler: Nullable<(e: FocusEvent) => any>;
  87049. }[]): void;
  87050. /**
  87051. * Function used to unregister events from window level
  87052. * @param events defines the events to unregister
  87053. */
  87054. static UnregisterTopRootEvents(events: {
  87055. name: string;
  87056. handler: Nullable<(e: FocusEvent) => any>;
  87057. }[]): void;
  87058. /**
  87059. * Dumps the current bound framebuffer
  87060. * @param width defines the rendering width
  87061. * @param height defines the rendering height
  87062. * @param engine defines the hosting engine
  87063. * @param successCallback defines the callback triggered once the data are available
  87064. * @param mimeType defines the mime type of the result
  87065. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87066. */
  87067. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87068. /**
  87069. * Converts the canvas data to blob.
  87070. * This acts as a polyfill for browsers not supporting the to blob function.
  87071. * @param canvas Defines the canvas to extract the data from
  87072. * @param successCallback Defines the callback triggered once the data are available
  87073. * @param mimeType Defines the mime type of the result
  87074. */
  87075. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87076. /**
  87077. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87078. * @param successCallback defines the callback triggered once the data are available
  87079. * @param mimeType defines the mime type of the result
  87080. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87081. */
  87082. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87083. /**
  87084. * Downloads a blob in the browser
  87085. * @param blob defines the blob to download
  87086. * @param fileName defines the name of the downloaded file
  87087. */
  87088. static Download(blob: Blob, fileName: string): void;
  87089. /**
  87090. * Captures a screenshot of the current rendering
  87091. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87092. * @param engine defines the rendering engine
  87093. * @param camera defines the source camera
  87094. * @param size This parameter can be set to a single number or to an object with the
  87095. * following (optional) properties: precision, width, height. If a single number is passed,
  87096. * it will be used for both width and height. If an object is passed, the screenshot size
  87097. * will be derived from the parameters. The precision property is a multiplier allowing
  87098. * rendering at a higher or lower resolution
  87099. * @param successCallback defines the callback receives a single parameter which contains the
  87100. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87101. * src parameter of an <img> to display it
  87102. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87103. * Check your browser for supported MIME types
  87104. */
  87105. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87106. /**
  87107. * Generates an image screenshot from the specified camera.
  87108. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87109. * @param engine The engine to use for rendering
  87110. * @param camera The camera to use for rendering
  87111. * @param size This parameter can be set to a single number or to an object with the
  87112. * following (optional) properties: precision, width, height. If a single number is passed,
  87113. * it will be used for both width and height. If an object is passed, the screenshot size
  87114. * will be derived from the parameters. The precision property is a multiplier allowing
  87115. * rendering at a higher or lower resolution
  87116. * @param successCallback The callback receives a single parameter which contains the
  87117. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87118. * src parameter of an <img> to display it
  87119. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87120. * Check your browser for supported MIME types
  87121. * @param samples Texture samples (default: 1)
  87122. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87123. * @param fileName A name for for the downloaded file.
  87124. */
  87125. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87126. /**
  87127. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87128. * Be aware Math.random() could cause collisions, but:
  87129. * "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"
  87130. * @returns a pseudo random id
  87131. */
  87132. static RandomId(): string;
  87133. /**
  87134. * Test if the given uri is a base64 string
  87135. * @param uri The uri to test
  87136. * @return True if the uri is a base64 string or false otherwise
  87137. */
  87138. static IsBase64(uri: string): boolean;
  87139. /**
  87140. * Decode the given base64 uri.
  87141. * @param uri The uri to decode
  87142. * @return The decoded base64 data.
  87143. */
  87144. static DecodeBase64(uri: string): ArrayBuffer;
  87145. /**
  87146. * No log
  87147. */
  87148. static readonly NoneLogLevel: number;
  87149. /**
  87150. * Only message logs
  87151. */
  87152. static readonly MessageLogLevel: number;
  87153. /**
  87154. * Only warning logs
  87155. */
  87156. static readonly WarningLogLevel: number;
  87157. /**
  87158. * Only error logs
  87159. */
  87160. static readonly ErrorLogLevel: number;
  87161. /**
  87162. * All logs
  87163. */
  87164. static readonly AllLogLevel: number;
  87165. /**
  87166. * Gets a value indicating the number of loading errors
  87167. * @ignorenaming
  87168. */
  87169. static readonly errorsCount: number;
  87170. /**
  87171. * Callback called when a new log is added
  87172. */
  87173. static OnNewCacheEntry: (entry: string) => void;
  87174. /**
  87175. * Log a message to the console
  87176. * @param message defines the message to log
  87177. */
  87178. static Log(message: string): void;
  87179. /**
  87180. * Write a warning message to the console
  87181. * @param message defines the message to log
  87182. */
  87183. static Warn(message: string): void;
  87184. /**
  87185. * Write an error message to the console
  87186. * @param message defines the message to log
  87187. */
  87188. static Error(message: string): void;
  87189. /**
  87190. * Gets current log cache (list of logs)
  87191. */
  87192. static readonly LogCache: string;
  87193. /**
  87194. * Clears the log cache
  87195. */
  87196. static ClearLogCache(): void;
  87197. /**
  87198. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87199. */
  87200. static LogLevels: number;
  87201. /**
  87202. * Checks if the loaded document was accessed via `file:`-Protocol.
  87203. * @returns boolean
  87204. */
  87205. static IsFileURL(): boolean;
  87206. /**
  87207. * Checks if the window object exists
  87208. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87209. */
  87210. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87211. /**
  87212. * No performance log
  87213. */
  87214. static readonly PerformanceNoneLogLevel: number;
  87215. /**
  87216. * Use user marks to log performance
  87217. */
  87218. static readonly PerformanceUserMarkLogLevel: number;
  87219. /**
  87220. * Log performance to the console
  87221. */
  87222. static readonly PerformanceConsoleLogLevel: number;
  87223. private static _performance;
  87224. /**
  87225. * Sets the current performance log level
  87226. */
  87227. static PerformanceLogLevel: number;
  87228. private static _StartPerformanceCounterDisabled;
  87229. private static _EndPerformanceCounterDisabled;
  87230. private static _StartUserMark;
  87231. private static _EndUserMark;
  87232. private static _StartPerformanceConsole;
  87233. private static _EndPerformanceConsole;
  87234. /**
  87235. * Injects the @see CustomRequestHeaders into the given request
  87236. * @param request the request that should be used for injection
  87237. */
  87238. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87239. /**
  87240. * Starts a performance counter
  87241. */
  87242. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87243. /**
  87244. * Ends a specific performance coutner
  87245. */
  87246. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87247. /**
  87248. * Gets either window.performance.now() if supported or Date.now() else
  87249. */
  87250. static readonly Now: number;
  87251. /**
  87252. * This method will return the name of the class used to create the instance of the given object.
  87253. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87254. * @param object the object to get the class name from
  87255. * @param isType defines if the object is actually a type
  87256. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87257. */
  87258. static GetClassName(object: any, isType?: boolean): string;
  87259. /**
  87260. * Gets the first element of an array satisfying a given predicate
  87261. * @param array defines the array to browse
  87262. * @param predicate defines the predicate to use
  87263. * @returns null if not found or the element
  87264. */
  87265. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87266. /**
  87267. * This method will return the name of the full name of the class, including its owning module (if any).
  87268. * 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).
  87269. * @param object the object to get the class name from
  87270. * @param isType defines if the object is actually a type
  87271. * @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.
  87272. * @ignorenaming
  87273. */
  87274. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87275. /**
  87276. * Returns a promise that resolves after the given amount of time.
  87277. * @param delay Number of milliseconds to delay
  87278. * @returns Promise that resolves after the given amount of time
  87279. */
  87280. static DelayAsync(delay: number): Promise<void>;
  87281. /**
  87282. * Gets the current gradient from an array of IValueGradient
  87283. * @param ratio defines the current ratio to get
  87284. * @param gradients defines the array of IValueGradient
  87285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87286. */
  87287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87288. }
  87289. /**
  87290. * This class is used to track a performance counter which is number based.
  87291. * The user has access to many properties which give statistics of different nature.
  87292. *
  87293. * The implementer can track two kinds of Performance Counter: time and count.
  87294. * 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.
  87295. * 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.
  87296. */
  87297. export class PerfCounter {
  87298. /**
  87299. * Gets or sets a global boolean to turn on and off all the counters
  87300. */
  87301. static Enabled: boolean;
  87302. /**
  87303. * Returns the smallest value ever
  87304. */
  87305. readonly min: number;
  87306. /**
  87307. * Returns the biggest value ever
  87308. */
  87309. readonly max: number;
  87310. /**
  87311. * Returns the average value since the performance counter is running
  87312. */
  87313. readonly average: number;
  87314. /**
  87315. * Returns the average value of the last second the counter was monitored
  87316. */
  87317. readonly lastSecAverage: number;
  87318. /**
  87319. * Returns the current value
  87320. */
  87321. readonly current: number;
  87322. /**
  87323. * Gets the accumulated total
  87324. */
  87325. readonly total: number;
  87326. /**
  87327. * Gets the total value count
  87328. */
  87329. readonly count: number;
  87330. /**
  87331. * Creates a new counter
  87332. */
  87333. constructor();
  87334. /**
  87335. * Call this method to start monitoring a new frame.
  87336. * 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.
  87337. */
  87338. fetchNewFrame(): void;
  87339. /**
  87340. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87341. * @param newCount the count value to add to the monitored count
  87342. * @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.
  87343. */
  87344. addCount(newCount: number, fetchResult: boolean): void;
  87345. /**
  87346. * Start monitoring this performance counter
  87347. */
  87348. beginMonitoring(): void;
  87349. /**
  87350. * Compute the time lapsed since the previous beginMonitoring() call.
  87351. * @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
  87352. */
  87353. endMonitoring(newFrame?: boolean): void;
  87354. private _fetchResult;
  87355. private _startMonitoringTime;
  87356. private _min;
  87357. private _max;
  87358. private _average;
  87359. private _current;
  87360. private _totalValueCount;
  87361. private _totalAccumulated;
  87362. private _lastSecAverage;
  87363. private _lastSecAccumulated;
  87364. private _lastSecTime;
  87365. private _lastSecValueCount;
  87366. }
  87367. /**
  87368. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87369. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87370. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87371. * @param name The name of the class, case should be preserved
  87372. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87373. */
  87374. export function className(name: string, module?: string): (target: Object) => void;
  87375. /**
  87376. * An implementation of a loop for asynchronous functions.
  87377. */
  87378. export class AsyncLoop {
  87379. /**
  87380. * Defines the number of iterations for the loop
  87381. */
  87382. iterations: number;
  87383. /**
  87384. * Defines the current index of the loop.
  87385. */
  87386. index: number;
  87387. private _done;
  87388. private _fn;
  87389. private _successCallback;
  87390. /**
  87391. * Constructor.
  87392. * @param iterations the number of iterations.
  87393. * @param func the function to run each iteration
  87394. * @param successCallback the callback that will be called upon succesful execution
  87395. * @param offset starting offset.
  87396. */
  87397. constructor(
  87398. /**
  87399. * Defines the number of iterations for the loop
  87400. */
  87401. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87402. /**
  87403. * Execute the next iteration. Must be called after the last iteration was finished.
  87404. */
  87405. executeNext(): void;
  87406. /**
  87407. * Break the loop and run the success callback.
  87408. */
  87409. breakLoop(): void;
  87410. /**
  87411. * Create and run an async loop.
  87412. * @param iterations the number of iterations.
  87413. * @param fn the function to run each iteration
  87414. * @param successCallback the callback that will be called upon succesful execution
  87415. * @param offset starting offset.
  87416. * @returns the created async loop object
  87417. */
  87418. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87419. /**
  87420. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87421. * @param iterations total number of iterations
  87422. * @param syncedIterations number of synchronous iterations in each async iteration.
  87423. * @param fn the function to call each iteration.
  87424. * @param callback a success call back that will be called when iterating stops.
  87425. * @param breakFunction a break condition (optional)
  87426. * @param timeout timeout settings for the setTimeout function. default - 0.
  87427. * @returns the created async loop object
  87428. */
  87429. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87430. }
  87431. }
  87432. declare module BABYLON {
  87433. /** @hidden */
  87434. export interface ICollisionCoordinator {
  87435. createCollider(): Collider;
  87436. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87437. init(scene: Scene): void;
  87438. }
  87439. /** @hidden */
  87440. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87441. private _scene;
  87442. private _scaledPosition;
  87443. private _scaledVelocity;
  87444. private _finalPosition;
  87445. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87446. createCollider(): Collider;
  87447. init(scene: Scene): void;
  87448. private _collideWithWorld;
  87449. }
  87450. }
  87451. declare module BABYLON {
  87452. /**
  87453. * This class defines the direct association between an animation and a target
  87454. */
  87455. export class TargetedAnimation {
  87456. /**
  87457. * Animation to perform
  87458. */
  87459. animation: Animation;
  87460. /**
  87461. * Target to animate
  87462. */
  87463. target: any;
  87464. }
  87465. /**
  87466. * Use this class to create coordinated animations on multiple targets
  87467. */
  87468. export class AnimationGroup implements IDisposable {
  87469. /** The name of the animation group */
  87470. name: string;
  87471. private _scene;
  87472. private _targetedAnimations;
  87473. private _animatables;
  87474. private _from;
  87475. private _to;
  87476. private _isStarted;
  87477. private _isPaused;
  87478. private _speedRatio;
  87479. /**
  87480. * Gets or sets the unique id of the node
  87481. */
  87482. uniqueId: number;
  87483. /**
  87484. * This observable will notify when one animation have ended
  87485. */
  87486. onAnimationEndObservable: Observable<TargetedAnimation>;
  87487. /**
  87488. * Observer raised when one animation loops
  87489. */
  87490. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87491. /**
  87492. * This observable will notify when all animations have ended.
  87493. */
  87494. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87495. /**
  87496. * This observable will notify when all animations have paused.
  87497. */
  87498. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87499. /**
  87500. * This observable will notify when all animations are playing.
  87501. */
  87502. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87503. /**
  87504. * Gets the first frame
  87505. */
  87506. readonly from: number;
  87507. /**
  87508. * Gets the last frame
  87509. */
  87510. readonly to: number;
  87511. /**
  87512. * Define if the animations are started
  87513. */
  87514. readonly isStarted: boolean;
  87515. /**
  87516. * Gets a value indicating that the current group is playing
  87517. */
  87518. readonly isPlaying: boolean;
  87519. /**
  87520. * Gets or sets the speed ratio to use for all animations
  87521. */
  87522. /**
  87523. * Gets or sets the speed ratio to use for all animations
  87524. */
  87525. speedRatio: number;
  87526. /**
  87527. * Gets the targeted animations for this animation group
  87528. */
  87529. readonly targetedAnimations: Array<TargetedAnimation>;
  87530. /**
  87531. * returning the list of animatables controlled by this animation group.
  87532. */
  87533. readonly animatables: Array<Animatable>;
  87534. /**
  87535. * Instantiates a new Animation Group.
  87536. * This helps managing several animations at once.
  87537. * @see http://doc.babylonjs.com/how_to/group
  87538. * @param name Defines the name of the group
  87539. * @param scene Defines the scene the group belongs to
  87540. */
  87541. constructor(
  87542. /** The name of the animation group */
  87543. name: string, scene?: Nullable<Scene>);
  87544. /**
  87545. * Add an animation (with its target) in the group
  87546. * @param animation defines the animation we want to add
  87547. * @param target defines the target of the animation
  87548. * @returns the TargetedAnimation object
  87549. */
  87550. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87551. /**
  87552. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87553. * It can add constant keys at begin or end
  87554. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87555. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87556. * @returns the animation group
  87557. */
  87558. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87559. /**
  87560. * Start all animations on given targets
  87561. * @param loop defines if animations must loop
  87562. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87563. * @param from defines the from key (optional)
  87564. * @param to defines the to key (optional)
  87565. * @returns the current animation group
  87566. */
  87567. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87568. /**
  87569. * Pause all animations
  87570. * @returns the animation group
  87571. */
  87572. pause(): AnimationGroup;
  87573. /**
  87574. * Play all animations to initial state
  87575. * This function will start() the animations if they were not started or will restart() them if they were paused
  87576. * @param loop defines if animations must loop
  87577. * @returns the animation group
  87578. */
  87579. play(loop?: boolean): AnimationGroup;
  87580. /**
  87581. * Reset all animations to initial state
  87582. * @returns the animation group
  87583. */
  87584. reset(): AnimationGroup;
  87585. /**
  87586. * Restart animations from key 0
  87587. * @returns the animation group
  87588. */
  87589. restart(): AnimationGroup;
  87590. /**
  87591. * Stop all animations
  87592. * @returns the animation group
  87593. */
  87594. stop(): AnimationGroup;
  87595. /**
  87596. * Set animation weight for all animatables
  87597. * @param weight defines the weight to use
  87598. * @return the animationGroup
  87599. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87600. */
  87601. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87602. /**
  87603. * Synchronize and normalize all animatables with a source animatable
  87604. * @param root defines the root animatable to synchronize with
  87605. * @return the animationGroup
  87606. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87607. */
  87608. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87609. /**
  87610. * Goes to a specific frame in this animation group
  87611. * @param frame the frame number to go to
  87612. * @return the animationGroup
  87613. */
  87614. goToFrame(frame: number): AnimationGroup;
  87615. /**
  87616. * Dispose all associated resources
  87617. */
  87618. dispose(): void;
  87619. private _checkAnimationGroupEnded;
  87620. /**
  87621. * Clone the current animation group and returns a copy
  87622. * @param newName defines the name of the new group
  87623. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  87624. * @returns the new aniamtion group
  87625. */
  87626. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  87627. /**
  87628. * Returns a new AnimationGroup object parsed from the source provided.
  87629. * @param parsedAnimationGroup defines the source
  87630. * @param scene defines the scene that will receive the animationGroup
  87631. * @returns a new AnimationGroup
  87632. */
  87633. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87634. /**
  87635. * Returns the string "AnimationGroup"
  87636. * @returns "AnimationGroup"
  87637. */
  87638. getClassName(): string;
  87639. /**
  87640. * Creates a detailled string about the object
  87641. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87642. * @returns a string representing the object
  87643. */
  87644. toString(fullDetails?: boolean): string;
  87645. }
  87646. }
  87647. declare module BABYLON {
  87648. /**
  87649. * Define an interface for all classes that will hold resources
  87650. */
  87651. export interface IDisposable {
  87652. /**
  87653. * Releases all held resources
  87654. */
  87655. dispose(): void;
  87656. }
  87657. /** Interface defining initialization parameters for Scene class */
  87658. export interface SceneOptions {
  87659. /**
  87660. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87661. * It will improve performance when the number of geometries becomes important.
  87662. */
  87663. useGeometryUniqueIdsMap?: boolean;
  87664. /**
  87665. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87666. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87667. */
  87668. useMaterialMeshMap?: boolean;
  87669. /**
  87670. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87671. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87672. */
  87673. useClonedMeshhMap?: boolean;
  87674. }
  87675. /**
  87676. * Represents a scene to be rendered by the engine.
  87677. * @see http://doc.babylonjs.com/features/scene
  87678. */
  87679. export class Scene extends AbstractScene implements IAnimatable {
  87680. private static _uniqueIdCounter;
  87681. /** The fog is deactivated */
  87682. static readonly FOGMODE_NONE: number;
  87683. /** The fog density is following an exponential function */
  87684. static readonly FOGMODE_EXP: number;
  87685. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87686. static readonly FOGMODE_EXP2: number;
  87687. /** The fog density is following a linear function. */
  87688. static readonly FOGMODE_LINEAR: number;
  87689. /**
  87690. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87691. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87692. */
  87693. static MinDeltaTime: number;
  87694. /**
  87695. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87697. */
  87698. static MaxDeltaTime: number;
  87699. /**
  87700. * Factory used to create the default material.
  87701. * @param name The name of the material to create
  87702. * @param scene The scene to create the material for
  87703. * @returns The default material
  87704. */
  87705. static DefaultMaterialFactory(scene: Scene): Material;
  87706. /**
  87707. * Factory used to create the a collision coordinator.
  87708. * @returns The collision coordinator
  87709. */
  87710. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87711. /** @hidden */
  87712. readonly _isScene: boolean;
  87713. /**
  87714. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87715. */
  87716. autoClear: boolean;
  87717. /**
  87718. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87719. */
  87720. autoClearDepthAndStencil: boolean;
  87721. /**
  87722. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87723. */
  87724. clearColor: Color4;
  87725. /**
  87726. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87727. */
  87728. ambientColor: Color3;
  87729. /** @hidden */
  87730. _environmentBRDFTexture: BaseTexture;
  87731. /** @hidden */
  87732. protected _environmentTexture: Nullable<BaseTexture>;
  87733. /**
  87734. * Texture used in all pbr material as the reflection texture.
  87735. * As in the majority of the scene they are the same (exception for multi room and so on),
  87736. * this is easier to reference from here than from all the materials.
  87737. */
  87738. /**
  87739. * Texture used in all pbr material as the reflection texture.
  87740. * As in the majority of the scene they are the same (exception for multi room and so on),
  87741. * this is easier to set here than in all the materials.
  87742. */
  87743. environmentTexture: Nullable<BaseTexture>;
  87744. /** @hidden */
  87745. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87746. /**
  87747. * Default image processing configuration used either in the rendering
  87748. * Forward main pass or through the imageProcessingPostProcess if present.
  87749. * As in the majority of the scene they are the same (exception for multi camera),
  87750. * this is easier to reference from here than from all the materials and post process.
  87751. *
  87752. * No setter as we it is a shared configuration, you can set the values instead.
  87753. */
  87754. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87755. private _forceWireframe;
  87756. /**
  87757. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87758. */
  87759. forceWireframe: boolean;
  87760. private _forcePointsCloud;
  87761. /**
  87762. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87763. */
  87764. forcePointsCloud: boolean;
  87765. /**
  87766. * Gets or sets the active clipplane 1
  87767. */
  87768. clipPlane: Nullable<Plane>;
  87769. /**
  87770. * Gets or sets the active clipplane 2
  87771. */
  87772. clipPlane2: Nullable<Plane>;
  87773. /**
  87774. * Gets or sets the active clipplane 3
  87775. */
  87776. clipPlane3: Nullable<Plane>;
  87777. /**
  87778. * Gets or sets the active clipplane 4
  87779. */
  87780. clipPlane4: Nullable<Plane>;
  87781. /**
  87782. * Gets or sets a boolean indicating if animations are enabled
  87783. */
  87784. animationsEnabled: boolean;
  87785. private _animationPropertiesOverride;
  87786. /**
  87787. * Gets or sets the animation properties override
  87788. */
  87789. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87790. /**
  87791. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87792. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87793. */
  87794. useConstantAnimationDeltaTime: boolean;
  87795. /**
  87796. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87797. * Please note that it requires to run a ray cast through the scene on every frame
  87798. */
  87799. constantlyUpdateMeshUnderPointer: boolean;
  87800. /**
  87801. * Defines the HTML cursor to use when hovering over interactive elements
  87802. */
  87803. hoverCursor: string;
  87804. /**
  87805. * Defines the HTML default cursor to use (empty by default)
  87806. */
  87807. defaultCursor: string;
  87808. /**
  87809. * This is used to call preventDefault() on pointer down
  87810. * in order to block unwanted artifacts like system double clicks
  87811. */
  87812. preventDefaultOnPointerDown: boolean;
  87813. /**
  87814. * This is used to call preventDefault() on pointer up
  87815. * in order to block unwanted artifacts like system double clicks
  87816. */
  87817. preventDefaultOnPointerUp: boolean;
  87818. /**
  87819. * Gets or sets user defined metadata
  87820. */
  87821. metadata: any;
  87822. /**
  87823. * For internal use only. Please do not use.
  87824. */
  87825. reservedDataStore: any;
  87826. /**
  87827. * Gets the name of the plugin used to load this scene (null by default)
  87828. */
  87829. loadingPluginName: string;
  87830. /**
  87831. * Use this array to add regular expressions used to disable offline support for specific urls
  87832. */
  87833. disableOfflineSupportExceptionRules: RegExp[];
  87834. /**
  87835. * An event triggered when the scene is disposed.
  87836. */
  87837. onDisposeObservable: Observable<Scene>;
  87838. private _onDisposeObserver;
  87839. /** Sets a function to be executed when this scene is disposed. */
  87840. onDispose: () => void;
  87841. /**
  87842. * An event triggered before rendering the scene (right after animations and physics)
  87843. */
  87844. onBeforeRenderObservable: Observable<Scene>;
  87845. private _onBeforeRenderObserver;
  87846. /** Sets a function to be executed before rendering this scene */
  87847. beforeRender: Nullable<() => void>;
  87848. /**
  87849. * An event triggered after rendering the scene
  87850. */
  87851. onAfterRenderObservable: Observable<Scene>;
  87852. private _onAfterRenderObserver;
  87853. /** Sets a function to be executed after rendering this scene */
  87854. afterRender: Nullable<() => void>;
  87855. /**
  87856. * An event triggered before animating the scene
  87857. */
  87858. onBeforeAnimationsObservable: Observable<Scene>;
  87859. /**
  87860. * An event triggered after animations processing
  87861. */
  87862. onAfterAnimationsObservable: Observable<Scene>;
  87863. /**
  87864. * An event triggered before draw calls are ready to be sent
  87865. */
  87866. onBeforeDrawPhaseObservable: Observable<Scene>;
  87867. /**
  87868. * An event triggered after draw calls have been sent
  87869. */
  87870. onAfterDrawPhaseObservable: Observable<Scene>;
  87871. /**
  87872. * An event triggered when the scene is ready
  87873. */
  87874. onReadyObservable: Observable<Scene>;
  87875. /**
  87876. * An event triggered before rendering a camera
  87877. */
  87878. onBeforeCameraRenderObservable: Observable<Camera>;
  87879. private _onBeforeCameraRenderObserver;
  87880. /** Sets a function to be executed before rendering a camera*/
  87881. beforeCameraRender: () => void;
  87882. /**
  87883. * An event triggered after rendering a camera
  87884. */
  87885. onAfterCameraRenderObservable: Observable<Camera>;
  87886. private _onAfterCameraRenderObserver;
  87887. /** Sets a function to be executed after rendering a camera*/
  87888. afterCameraRender: () => void;
  87889. /**
  87890. * An event triggered when active meshes evaluation is about to start
  87891. */
  87892. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87893. /**
  87894. * An event triggered when active meshes evaluation is done
  87895. */
  87896. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87897. /**
  87898. * An event triggered when particles rendering is about to start
  87899. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87900. */
  87901. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87902. /**
  87903. * An event triggered when particles rendering is done
  87904. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87905. */
  87906. onAfterParticlesRenderingObservable: Observable<Scene>;
  87907. /**
  87908. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87909. */
  87910. onDataLoadedObservable: Observable<Scene>;
  87911. /**
  87912. * An event triggered when a camera is created
  87913. */
  87914. onNewCameraAddedObservable: Observable<Camera>;
  87915. /**
  87916. * An event triggered when a camera is removed
  87917. */
  87918. onCameraRemovedObservable: Observable<Camera>;
  87919. /**
  87920. * An event triggered when a light is created
  87921. */
  87922. onNewLightAddedObservable: Observable<Light>;
  87923. /**
  87924. * An event triggered when a light is removed
  87925. */
  87926. onLightRemovedObservable: Observable<Light>;
  87927. /**
  87928. * An event triggered when a geometry is created
  87929. */
  87930. onNewGeometryAddedObservable: Observable<Geometry>;
  87931. /**
  87932. * An event triggered when a geometry is removed
  87933. */
  87934. onGeometryRemovedObservable: Observable<Geometry>;
  87935. /**
  87936. * An event triggered when a transform node is created
  87937. */
  87938. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87939. /**
  87940. * An event triggered when a transform node is removed
  87941. */
  87942. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87943. /**
  87944. * An event triggered when a mesh is created
  87945. */
  87946. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87947. /**
  87948. * An event triggered when a mesh is removed
  87949. */
  87950. onMeshRemovedObservable: Observable<AbstractMesh>;
  87951. /**
  87952. * An event triggered when a material is created
  87953. */
  87954. onNewMaterialAddedObservable: Observable<Material>;
  87955. /**
  87956. * An event triggered when a material is removed
  87957. */
  87958. onMaterialRemovedObservable: Observable<Material>;
  87959. /**
  87960. * An event triggered when a texture is created
  87961. */
  87962. onNewTextureAddedObservable: Observable<BaseTexture>;
  87963. /**
  87964. * An event triggered when a texture is removed
  87965. */
  87966. onTextureRemovedObservable: Observable<BaseTexture>;
  87967. /**
  87968. * An event triggered when render targets are about to be rendered
  87969. * Can happen multiple times per frame.
  87970. */
  87971. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87972. /**
  87973. * An event triggered when render targets were rendered.
  87974. * Can happen multiple times per frame.
  87975. */
  87976. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87977. /**
  87978. * An event triggered before calculating deterministic simulation step
  87979. */
  87980. onBeforeStepObservable: Observable<Scene>;
  87981. /**
  87982. * An event triggered after calculating deterministic simulation step
  87983. */
  87984. onAfterStepObservable: Observable<Scene>;
  87985. /**
  87986. * An event triggered when the activeCamera property is updated
  87987. */
  87988. onActiveCameraChanged: Observable<Scene>;
  87989. /**
  87990. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87991. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87992. * 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)
  87993. */
  87994. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87995. /**
  87996. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87997. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87998. * 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)
  87999. */
  88000. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88001. /**
  88002. * This Observable will when a mesh has been imported into the scene.
  88003. */
  88004. onMeshImportedObservable: Observable<AbstractMesh>;
  88005. /** @hidden */
  88006. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88007. /**
  88008. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88009. */
  88010. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88011. /**
  88012. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88013. */
  88014. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88015. /**
  88016. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88017. */
  88018. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88019. private _onPointerMove;
  88020. private _onPointerDown;
  88021. private _onPointerUp;
  88022. /** Callback called when a pointer move is detected */
  88023. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88024. /** Callback called when a pointer down is detected */
  88025. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88026. /** Callback called when a pointer up is detected */
  88027. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88028. /** Callback called when a pointer pick is detected */
  88029. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88030. /**
  88031. * 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).
  88032. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88033. */
  88034. onPrePointerObservable: Observable<PointerInfoPre>;
  88035. /**
  88036. * Observable event triggered each time an input event is received from the rendering canvas
  88037. */
  88038. onPointerObservable: Observable<PointerInfo>;
  88039. /**
  88040. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88041. */
  88042. readonly unTranslatedPointer: Vector2;
  88043. /** The distance in pixel that you have to move to prevent some events */
  88044. static DragMovementThreshold: number;
  88045. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88046. static LongPressDelay: number;
  88047. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88048. static DoubleClickDelay: number;
  88049. /** If you need to check double click without raising a single click at first click, enable this flag */
  88050. static ExclusiveDoubleClickMode: boolean;
  88051. private _initClickEvent;
  88052. private _initActionManager;
  88053. private _delayedSimpleClick;
  88054. private _delayedSimpleClickTimeout;
  88055. private _previousDelayedSimpleClickTimeout;
  88056. private _meshPickProceed;
  88057. private _previousButtonPressed;
  88058. private _currentPickResult;
  88059. private _previousPickResult;
  88060. private _totalPointersPressed;
  88061. private _doubleClickOccured;
  88062. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88063. cameraToUseForPointers: Nullable<Camera>;
  88064. private _pointerX;
  88065. private _pointerY;
  88066. private _unTranslatedPointerX;
  88067. private _unTranslatedPointerY;
  88068. private _startingPointerPosition;
  88069. private _previousStartingPointerPosition;
  88070. private _startingPointerTime;
  88071. private _previousStartingPointerTime;
  88072. private _pointerCaptures;
  88073. private _timeAccumulator;
  88074. private _currentStepId;
  88075. private _currentInternalStep;
  88076. /** @hidden */
  88077. _mirroredCameraPosition: Nullable<Vector3>;
  88078. /**
  88079. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88080. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88081. */
  88082. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88083. /**
  88084. * Observable event triggered each time an keyboard event is received from the hosting window
  88085. */
  88086. onKeyboardObservable: Observable<KeyboardInfo>;
  88087. private _onKeyDown;
  88088. private _onKeyUp;
  88089. private _onCanvasFocusObserver;
  88090. private _onCanvasBlurObserver;
  88091. private _useRightHandedSystem;
  88092. /**
  88093. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88094. */
  88095. useRightHandedSystem: boolean;
  88096. /**
  88097. * Sets the step Id used by deterministic lock step
  88098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88099. * @param newStepId defines the step Id
  88100. */
  88101. setStepId(newStepId: number): void;
  88102. /**
  88103. * Gets the step Id used by deterministic lock step
  88104. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88105. * @returns the step Id
  88106. */
  88107. getStepId(): number;
  88108. /**
  88109. * Gets the internal step used by deterministic lock step
  88110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88111. * @returns the internal step
  88112. */
  88113. getInternalStep(): number;
  88114. private _fogEnabled;
  88115. /**
  88116. * Gets or sets a boolean indicating if fog is enabled on this scene
  88117. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88118. * (Default is true)
  88119. */
  88120. fogEnabled: boolean;
  88121. private _fogMode;
  88122. /**
  88123. * Gets or sets the fog mode to use
  88124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88125. * | mode | value |
  88126. * | --- | --- |
  88127. * | FOGMODE_NONE | 0 |
  88128. * | FOGMODE_EXP | 1 |
  88129. * | FOGMODE_EXP2 | 2 |
  88130. * | FOGMODE_LINEAR | 3 |
  88131. */
  88132. fogMode: number;
  88133. /**
  88134. * Gets or sets the fog color to use
  88135. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88136. * (Default is Color3(0.2, 0.2, 0.3))
  88137. */
  88138. fogColor: Color3;
  88139. /**
  88140. * Gets or sets the fog density to use
  88141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88142. * (Default is 0.1)
  88143. */
  88144. fogDensity: number;
  88145. /**
  88146. * Gets or sets the fog start distance to use
  88147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88148. * (Default is 0)
  88149. */
  88150. fogStart: number;
  88151. /**
  88152. * Gets or sets the fog end distance to use
  88153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88154. * (Default is 1000)
  88155. */
  88156. fogEnd: number;
  88157. private _shadowsEnabled;
  88158. /**
  88159. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88160. */
  88161. shadowsEnabled: boolean;
  88162. private _lightsEnabled;
  88163. /**
  88164. * Gets or sets a boolean indicating if lights are enabled on this scene
  88165. */
  88166. lightsEnabled: boolean;
  88167. /** All of the active cameras added to this scene. */
  88168. activeCameras: Camera[];
  88169. private _activeCamera;
  88170. /** Gets or sets the current active camera */
  88171. activeCamera: Nullable<Camera>;
  88172. private _defaultMaterial;
  88173. /** The default material used on meshes when no material is affected */
  88174. /** The default material used on meshes when no material is affected */
  88175. defaultMaterial: Material;
  88176. private _texturesEnabled;
  88177. /**
  88178. * Gets or sets a boolean indicating if textures are enabled on this scene
  88179. */
  88180. texturesEnabled: boolean;
  88181. /**
  88182. * Gets or sets a boolean indicating if particles are enabled on this scene
  88183. */
  88184. particlesEnabled: boolean;
  88185. /**
  88186. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88187. */
  88188. spritesEnabled: boolean;
  88189. private _skeletonsEnabled;
  88190. /**
  88191. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88192. */
  88193. skeletonsEnabled: boolean;
  88194. /**
  88195. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88196. */
  88197. lensFlaresEnabled: boolean;
  88198. /**
  88199. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88201. */
  88202. collisionsEnabled: boolean;
  88203. private _collisionCoordinator;
  88204. /** @hidden */
  88205. readonly collisionCoordinator: ICollisionCoordinator;
  88206. /**
  88207. * Defines the gravity applied to this scene (used only for collisions)
  88208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88209. */
  88210. gravity: Vector3;
  88211. /**
  88212. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88213. */
  88214. postProcessesEnabled: boolean;
  88215. /**
  88216. * The list of postprocesses added to the scene
  88217. */
  88218. postProcesses: PostProcess[];
  88219. /**
  88220. * Gets the current postprocess manager
  88221. */
  88222. postProcessManager: PostProcessManager;
  88223. /**
  88224. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88225. */
  88226. renderTargetsEnabled: boolean;
  88227. /**
  88228. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88229. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88230. */
  88231. dumpNextRenderTargets: boolean;
  88232. /**
  88233. * The list of user defined render targets added to the scene
  88234. */
  88235. customRenderTargets: RenderTargetTexture[];
  88236. /**
  88237. * Defines if texture loading must be delayed
  88238. * If true, textures will only be loaded when they need to be rendered
  88239. */
  88240. useDelayedTextureLoading: boolean;
  88241. /**
  88242. * Gets the list of meshes imported to the scene through SceneLoader
  88243. */
  88244. importedMeshesFiles: String[];
  88245. /**
  88246. * Gets or sets a boolean indicating if probes are enabled on this scene
  88247. */
  88248. probesEnabled: boolean;
  88249. /**
  88250. * Gets or sets the current offline provider to use to store scene data
  88251. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88252. */
  88253. offlineProvider: IOfflineProvider;
  88254. /**
  88255. * Gets or sets the action manager associated with the scene
  88256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88257. */
  88258. actionManager: AbstractActionManager;
  88259. private _meshesForIntersections;
  88260. /**
  88261. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88262. */
  88263. proceduralTexturesEnabled: boolean;
  88264. private _engine;
  88265. private _totalVertices;
  88266. /** @hidden */
  88267. _activeIndices: PerfCounter;
  88268. /** @hidden */
  88269. _activeParticles: PerfCounter;
  88270. /** @hidden */
  88271. _activeBones: PerfCounter;
  88272. private _animationRatio;
  88273. /** @hidden */
  88274. _animationTimeLast: number;
  88275. /** @hidden */
  88276. _animationTime: number;
  88277. /**
  88278. * Gets or sets a general scale for animation speed
  88279. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88280. */
  88281. animationTimeScale: number;
  88282. /** @hidden */
  88283. _cachedMaterial: Nullable<Material>;
  88284. /** @hidden */
  88285. _cachedEffect: Nullable<Effect>;
  88286. /** @hidden */
  88287. _cachedVisibility: Nullable<number>;
  88288. private _renderId;
  88289. private _frameId;
  88290. private _executeWhenReadyTimeoutId;
  88291. private _intermediateRendering;
  88292. private _viewUpdateFlag;
  88293. private _projectionUpdateFlag;
  88294. private _alternateViewUpdateFlag;
  88295. private _alternateProjectionUpdateFlag;
  88296. /** @hidden */
  88297. _toBeDisposed: Nullable<IDisposable>[];
  88298. private _activeRequests;
  88299. /** @hidden */
  88300. _pendingData: any[];
  88301. private _isDisposed;
  88302. /**
  88303. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88304. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88305. */
  88306. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88307. private _activeMeshes;
  88308. private _processedMaterials;
  88309. private _renderTargets;
  88310. /** @hidden */
  88311. _activeParticleSystems: SmartArray<IParticleSystem>;
  88312. private _activeSkeletons;
  88313. private _softwareSkinnedMeshes;
  88314. private _renderingManager;
  88315. /** @hidden */
  88316. _activeAnimatables: Animatable[];
  88317. private _transformMatrix;
  88318. private _sceneUbo;
  88319. private _alternateSceneUbo;
  88320. private _viewMatrix;
  88321. private _projectionMatrix;
  88322. private _alternateViewMatrix;
  88323. private _alternateProjectionMatrix;
  88324. private _alternateTransformMatrix;
  88325. private _useAlternateCameraConfiguration;
  88326. private _alternateRendering;
  88327. private _wheelEventName;
  88328. /** @hidden */
  88329. _forcedViewPosition: Nullable<Vector3>;
  88330. /** @hidden */
  88331. readonly _isAlternateRenderingEnabled: boolean;
  88332. private _frustumPlanes;
  88333. /**
  88334. * Gets the list of frustum planes (built from the active camera)
  88335. */
  88336. readonly frustumPlanes: Plane[];
  88337. /**
  88338. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88339. * This is useful if there are more lights that the maximum simulteanous authorized
  88340. */
  88341. requireLightSorting: boolean;
  88342. /** @hidden */
  88343. readonly useMaterialMeshMap: boolean;
  88344. /** @hidden */
  88345. readonly useClonedMeshhMap: boolean;
  88346. private _pointerOverMesh;
  88347. private _pickedDownMesh;
  88348. private _pickedUpMesh;
  88349. private _externalData;
  88350. private _uid;
  88351. /**
  88352. * @hidden
  88353. * Backing store of defined scene components.
  88354. */
  88355. _components: ISceneComponent[];
  88356. /**
  88357. * @hidden
  88358. * Backing store of defined scene components.
  88359. */
  88360. _serializableComponents: ISceneSerializableComponent[];
  88361. /**
  88362. * List of components to register on the next registration step.
  88363. */
  88364. private _transientComponents;
  88365. /**
  88366. * Registers the transient components if needed.
  88367. */
  88368. private _registerTransientComponents;
  88369. /**
  88370. * @hidden
  88371. * Add a component to the scene.
  88372. * Note that the ccomponent could be registered on th next frame if this is called after
  88373. * the register component stage.
  88374. * @param component Defines the component to add to the scene
  88375. */
  88376. _addComponent(component: ISceneComponent): void;
  88377. /**
  88378. * @hidden
  88379. * Gets a component from the scene.
  88380. * @param name defines the name of the component to retrieve
  88381. * @returns the component or null if not present
  88382. */
  88383. _getComponent(name: string): Nullable<ISceneComponent>;
  88384. /**
  88385. * @hidden
  88386. * Defines the actions happening before camera updates.
  88387. */
  88388. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88389. /**
  88390. * @hidden
  88391. * Defines the actions happening before clear the canvas.
  88392. */
  88393. _beforeClearStage: Stage<SimpleStageAction>;
  88394. /**
  88395. * @hidden
  88396. * Defines the actions when collecting render targets for the frame.
  88397. */
  88398. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88399. /**
  88400. * @hidden
  88401. * Defines the actions happening for one camera in the frame.
  88402. */
  88403. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88404. /**
  88405. * @hidden
  88406. * Defines the actions happening during the per mesh ready checks.
  88407. */
  88408. _isReadyForMeshStage: Stage<MeshStageAction>;
  88409. /**
  88410. * @hidden
  88411. * Defines the actions happening before evaluate active mesh checks.
  88412. */
  88413. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88414. /**
  88415. * @hidden
  88416. * Defines the actions happening during the evaluate sub mesh checks.
  88417. */
  88418. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88419. /**
  88420. * @hidden
  88421. * Defines the actions happening during the active mesh stage.
  88422. */
  88423. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88424. /**
  88425. * @hidden
  88426. * Defines the actions happening during the per camera render target step.
  88427. */
  88428. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88429. /**
  88430. * @hidden
  88431. * Defines the actions happening just before the active camera is drawing.
  88432. */
  88433. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88434. /**
  88435. * @hidden
  88436. * Defines the actions happening just before a render target is drawing.
  88437. */
  88438. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88439. /**
  88440. * @hidden
  88441. * Defines the actions happening just before a rendering group is drawing.
  88442. */
  88443. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88444. /**
  88445. * @hidden
  88446. * Defines the actions happening just before a mesh is drawing.
  88447. */
  88448. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88449. /**
  88450. * @hidden
  88451. * Defines the actions happening just after a mesh has been drawn.
  88452. */
  88453. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88454. /**
  88455. * @hidden
  88456. * Defines the actions happening just after a rendering group has been drawn.
  88457. */
  88458. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88459. /**
  88460. * @hidden
  88461. * Defines the actions happening just after the active camera has been drawn.
  88462. */
  88463. _afterCameraDrawStage: Stage<CameraStageAction>;
  88464. /**
  88465. * @hidden
  88466. * Defines the actions happening just after a render target has been drawn.
  88467. */
  88468. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88469. /**
  88470. * @hidden
  88471. * Defines the actions happening just after rendering all cameras and computing intersections.
  88472. */
  88473. _afterRenderStage: Stage<SimpleStageAction>;
  88474. /**
  88475. * @hidden
  88476. * Defines the actions happening when a pointer move event happens.
  88477. */
  88478. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88479. /**
  88480. * @hidden
  88481. * Defines the actions happening when a pointer down event happens.
  88482. */
  88483. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88484. /**
  88485. * @hidden
  88486. * Defines the actions happening when a pointer up event happens.
  88487. */
  88488. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88489. /**
  88490. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88491. */
  88492. private geometriesByUniqueId;
  88493. /**
  88494. * Creates a new Scene
  88495. * @param engine defines the engine to use to render this scene
  88496. * @param options defines the scene options
  88497. */
  88498. constructor(engine: Engine, options?: SceneOptions);
  88499. private _defaultMeshCandidates;
  88500. /**
  88501. * @hidden
  88502. */
  88503. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88504. private _defaultSubMeshCandidates;
  88505. /**
  88506. * @hidden
  88507. */
  88508. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88509. /**
  88510. * Sets the default candidate providers for the scene.
  88511. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88512. * and getCollidingSubMeshCandidates to their default function
  88513. */
  88514. setDefaultCandidateProviders(): void;
  88515. /**
  88516. * Gets the mesh that is currently under the pointer
  88517. */
  88518. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88519. /**
  88520. * Gets or sets the current on-screen X position of the pointer
  88521. */
  88522. pointerX: number;
  88523. /**
  88524. * Gets or sets the current on-screen Y position of the pointer
  88525. */
  88526. pointerY: number;
  88527. /**
  88528. * Gets the cached material (ie. the latest rendered one)
  88529. * @returns the cached material
  88530. */
  88531. getCachedMaterial(): Nullable<Material>;
  88532. /**
  88533. * Gets the cached effect (ie. the latest rendered one)
  88534. * @returns the cached effect
  88535. */
  88536. getCachedEffect(): Nullable<Effect>;
  88537. /**
  88538. * Gets the cached visibility state (ie. the latest rendered one)
  88539. * @returns the cached visibility state
  88540. */
  88541. getCachedVisibility(): Nullable<number>;
  88542. /**
  88543. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88544. * @param material defines the current material
  88545. * @param effect defines the current effect
  88546. * @param visibility defines the current visibility state
  88547. * @returns true if one parameter is not cached
  88548. */
  88549. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88550. /**
  88551. * Gets the engine associated with the scene
  88552. * @returns an Engine
  88553. */
  88554. getEngine(): Engine;
  88555. /**
  88556. * Gets the total number of vertices rendered per frame
  88557. * @returns the total number of vertices rendered per frame
  88558. */
  88559. getTotalVertices(): number;
  88560. /**
  88561. * Gets the performance counter for total vertices
  88562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88563. */
  88564. readonly totalVerticesPerfCounter: PerfCounter;
  88565. /**
  88566. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88567. * @returns the total number of active indices rendered per frame
  88568. */
  88569. getActiveIndices(): number;
  88570. /**
  88571. * Gets the performance counter for active indices
  88572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88573. */
  88574. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88575. /**
  88576. * Gets the total number of active particles rendered per frame
  88577. * @returns the total number of active particles rendered per frame
  88578. */
  88579. getActiveParticles(): number;
  88580. /**
  88581. * Gets the performance counter for active particles
  88582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88583. */
  88584. readonly activeParticlesPerfCounter: PerfCounter;
  88585. /**
  88586. * Gets the total number of active bones rendered per frame
  88587. * @returns the total number of active bones rendered per frame
  88588. */
  88589. getActiveBones(): number;
  88590. /**
  88591. * Gets the performance counter for active bones
  88592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88593. */
  88594. readonly activeBonesPerfCounter: PerfCounter;
  88595. /**
  88596. * Gets the array of active meshes
  88597. * @returns an array of AbstractMesh
  88598. */
  88599. getActiveMeshes(): SmartArray<AbstractMesh>;
  88600. /**
  88601. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88602. * @returns a number
  88603. */
  88604. getAnimationRatio(): number;
  88605. /**
  88606. * Gets an unique Id for the current render phase
  88607. * @returns a number
  88608. */
  88609. getRenderId(): number;
  88610. /**
  88611. * Gets an unique Id for the current frame
  88612. * @returns a number
  88613. */
  88614. getFrameId(): number;
  88615. /** Call this function if you want to manually increment the render Id*/
  88616. incrementRenderId(): void;
  88617. private _updatePointerPosition;
  88618. private _createUbo;
  88619. private _createAlternateUbo;
  88620. private _setRayOnPointerInfo;
  88621. /**
  88622. * Use this method to simulate a pointer move on a mesh
  88623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88626. * @returns the current scene
  88627. */
  88628. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88629. private _processPointerMove;
  88630. private _checkPrePointerObservable;
  88631. /**
  88632. * Use this method to simulate a pointer down on a mesh
  88633. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88634. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88635. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88636. * @returns the current scene
  88637. */
  88638. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88639. private _processPointerDown;
  88640. /**
  88641. * Use this method to simulate a pointer up on a mesh
  88642. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88643. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88644. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88645. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88646. * @returns the current scene
  88647. */
  88648. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88649. private _processPointerUp;
  88650. /**
  88651. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88652. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88653. * @returns true if the pointer was captured
  88654. */
  88655. isPointerCaptured(pointerId?: number): boolean;
  88656. /** @hidden */
  88657. _isPointerSwiping(): boolean;
  88658. /**
  88659. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88660. * @param attachUp defines if you want to attach events to pointerup
  88661. * @param attachDown defines if you want to attach events to pointerdown
  88662. * @param attachMove defines if you want to attach events to pointermove
  88663. */
  88664. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88665. /** Detaches all event handlers*/
  88666. detachControl(): void;
  88667. /**
  88668. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88669. * Delay loaded resources are not taking in account
  88670. * @return true if all required resources are ready
  88671. */
  88672. isReady(): boolean;
  88673. /** Resets all cached information relative to material (including effect and visibility) */
  88674. resetCachedMaterial(): void;
  88675. /**
  88676. * Registers a function to be called before every frame render
  88677. * @param func defines the function to register
  88678. */
  88679. registerBeforeRender(func: () => void): void;
  88680. /**
  88681. * Unregisters a function called before every frame render
  88682. * @param func defines the function to unregister
  88683. */
  88684. unregisterBeforeRender(func: () => void): void;
  88685. /**
  88686. * Registers a function to be called after every frame render
  88687. * @param func defines the function to register
  88688. */
  88689. registerAfterRender(func: () => void): void;
  88690. /**
  88691. * Unregisters a function called after every frame render
  88692. * @param func defines the function to unregister
  88693. */
  88694. unregisterAfterRender(func: () => void): void;
  88695. private _executeOnceBeforeRender;
  88696. /**
  88697. * The provided function will run before render once and will be disposed afterwards.
  88698. * A timeout delay can be provided so that the function will be executed in N ms.
  88699. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88700. * @param func The function to be executed.
  88701. * @param timeout optional delay in ms
  88702. */
  88703. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88704. /** @hidden */
  88705. _addPendingData(data: any): void;
  88706. /** @hidden */
  88707. _removePendingData(data: any): void;
  88708. /**
  88709. * Returns the number of items waiting to be loaded
  88710. * @returns the number of items waiting to be loaded
  88711. */
  88712. getWaitingItemsCount(): number;
  88713. /**
  88714. * Returns a boolean indicating if the scene is still loading data
  88715. */
  88716. readonly isLoading: boolean;
  88717. /**
  88718. * Registers a function to be executed when the scene is ready
  88719. * @param {Function} func - the function to be executed
  88720. */
  88721. executeWhenReady(func: () => void): void;
  88722. /**
  88723. * Returns a promise that resolves when the scene is ready
  88724. * @returns A promise that resolves when the scene is ready
  88725. */
  88726. whenReadyAsync(): Promise<void>;
  88727. /** @hidden */
  88728. _checkIsReady(): void;
  88729. /**
  88730. * Gets all animatable attached to the scene
  88731. */
  88732. readonly animatables: Animatable[];
  88733. /**
  88734. * Resets the last animation time frame.
  88735. * Useful to override when animations start running when loading a scene for the first time.
  88736. */
  88737. resetLastAnimationTimeFrame(): void;
  88738. /** @hidden */
  88739. _switchToAlternateCameraConfiguration(active: boolean): void;
  88740. /**
  88741. * Gets the current view matrix
  88742. * @returns a Matrix
  88743. */
  88744. getViewMatrix(): Matrix;
  88745. /**
  88746. * Gets the current projection matrix
  88747. * @returns a Matrix
  88748. */
  88749. getProjectionMatrix(): Matrix;
  88750. /**
  88751. * Gets the current transform matrix
  88752. * @returns a Matrix made of View * Projection
  88753. */
  88754. getTransformMatrix(): Matrix;
  88755. /**
  88756. * Sets the current transform matrix
  88757. * @param view defines the View matrix to use
  88758. * @param projection defines the Projection matrix to use
  88759. */
  88760. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88761. /** @hidden */
  88762. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88763. /**
  88764. * Gets the uniform buffer used to store scene data
  88765. * @returns a UniformBuffer
  88766. */
  88767. getSceneUniformBuffer(): UniformBuffer;
  88768. /**
  88769. * Gets an unique (relatively to the current scene) Id
  88770. * @returns an unique number for the scene
  88771. */
  88772. getUniqueId(): number;
  88773. /**
  88774. * Add a mesh to the list of scene's meshes
  88775. * @param newMesh defines the mesh to add
  88776. * @param recursive if all child meshes should also be added to the scene
  88777. */
  88778. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88779. /**
  88780. * Remove a mesh for the list of scene's meshes
  88781. * @param toRemove defines the mesh to remove
  88782. * @param recursive if all child meshes should also be removed from the scene
  88783. * @returns the index where the mesh was in the mesh list
  88784. */
  88785. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88786. /**
  88787. * Add a transform node to the list of scene's transform nodes
  88788. * @param newTransformNode defines the transform node to add
  88789. */
  88790. addTransformNode(newTransformNode: TransformNode): void;
  88791. /**
  88792. * Remove a transform node for the list of scene's transform nodes
  88793. * @param toRemove defines the transform node to remove
  88794. * @returns the index where the transform node was in the transform node list
  88795. */
  88796. removeTransformNode(toRemove: TransformNode): number;
  88797. /**
  88798. * Remove a skeleton for the list of scene's skeletons
  88799. * @param toRemove defines the skeleton to remove
  88800. * @returns the index where the skeleton was in the skeleton list
  88801. */
  88802. removeSkeleton(toRemove: Skeleton): number;
  88803. /**
  88804. * Remove a morph target for the list of scene's morph targets
  88805. * @param toRemove defines the morph target to remove
  88806. * @returns the index where the morph target was in the morph target list
  88807. */
  88808. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88809. /**
  88810. * Remove a light for the list of scene's lights
  88811. * @param toRemove defines the light to remove
  88812. * @returns the index where the light was in the light list
  88813. */
  88814. removeLight(toRemove: Light): number;
  88815. /**
  88816. * Remove a camera for the list of scene's cameras
  88817. * @param toRemove defines the camera to remove
  88818. * @returns the index where the camera was in the camera list
  88819. */
  88820. removeCamera(toRemove: Camera): number;
  88821. /**
  88822. * Remove a particle system for the list of scene's particle systems
  88823. * @param toRemove defines the particle system to remove
  88824. * @returns the index where the particle system was in the particle system list
  88825. */
  88826. removeParticleSystem(toRemove: IParticleSystem): number;
  88827. /**
  88828. * Remove a animation for the list of scene's animations
  88829. * @param toRemove defines the animation to remove
  88830. * @returns the index where the animation was in the animation list
  88831. */
  88832. removeAnimation(toRemove: Animation): number;
  88833. /**
  88834. * Removes the given animation group from this scene.
  88835. * @param toRemove The animation group to remove
  88836. * @returns The index of the removed animation group
  88837. */
  88838. removeAnimationGroup(toRemove: AnimationGroup): number;
  88839. /**
  88840. * Removes the given multi-material from this scene.
  88841. * @param toRemove The multi-material to remove
  88842. * @returns The index of the removed multi-material
  88843. */
  88844. removeMultiMaterial(toRemove: MultiMaterial): number;
  88845. /**
  88846. * Removes the given material from this scene.
  88847. * @param toRemove The material to remove
  88848. * @returns The index of the removed material
  88849. */
  88850. removeMaterial(toRemove: Material): number;
  88851. /**
  88852. * Removes the given action manager from this scene.
  88853. * @param toRemove The action manager to remove
  88854. * @returns The index of the removed action manager
  88855. */
  88856. removeActionManager(toRemove: AbstractActionManager): number;
  88857. /**
  88858. * Removes the given texture from this scene.
  88859. * @param toRemove The texture to remove
  88860. * @returns The index of the removed texture
  88861. */
  88862. removeTexture(toRemove: BaseTexture): number;
  88863. /**
  88864. * Adds the given light to this scene
  88865. * @param newLight The light to add
  88866. */
  88867. addLight(newLight: Light): void;
  88868. /**
  88869. * Sorts the list list based on light priorities
  88870. */
  88871. sortLightsByPriority(): void;
  88872. /**
  88873. * Adds the given camera to this scene
  88874. * @param newCamera The camera to add
  88875. */
  88876. addCamera(newCamera: Camera): void;
  88877. /**
  88878. * Adds the given skeleton to this scene
  88879. * @param newSkeleton The skeleton to add
  88880. */
  88881. addSkeleton(newSkeleton: Skeleton): void;
  88882. /**
  88883. * Adds the given particle system to this scene
  88884. * @param newParticleSystem The particle system to add
  88885. */
  88886. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88887. /**
  88888. * Adds the given animation to this scene
  88889. * @param newAnimation The animation to add
  88890. */
  88891. addAnimation(newAnimation: Animation): void;
  88892. /**
  88893. * Adds the given animation group to this scene.
  88894. * @param newAnimationGroup The animation group to add
  88895. */
  88896. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88897. /**
  88898. * Adds the given multi-material to this scene
  88899. * @param newMultiMaterial The multi-material to add
  88900. */
  88901. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88902. /**
  88903. * Adds the given material to this scene
  88904. * @param newMaterial The material to add
  88905. */
  88906. addMaterial(newMaterial: Material): void;
  88907. /**
  88908. * Adds the given morph target to this scene
  88909. * @param newMorphTargetManager The morph target to add
  88910. */
  88911. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88912. /**
  88913. * Adds the given geometry to this scene
  88914. * @param newGeometry The geometry to add
  88915. */
  88916. addGeometry(newGeometry: Geometry): void;
  88917. /**
  88918. * Adds the given action manager to this scene
  88919. * @param newActionManager The action manager to add
  88920. */
  88921. addActionManager(newActionManager: AbstractActionManager): void;
  88922. /**
  88923. * Adds the given texture to this scene.
  88924. * @param newTexture The texture to add
  88925. */
  88926. addTexture(newTexture: BaseTexture): void;
  88927. /**
  88928. * Switch active camera
  88929. * @param newCamera defines the new active camera
  88930. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88931. */
  88932. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88933. /**
  88934. * sets the active camera of the scene using its ID
  88935. * @param id defines the camera's ID
  88936. * @return the new active camera or null if none found.
  88937. */
  88938. setActiveCameraByID(id: string): Nullable<Camera>;
  88939. /**
  88940. * sets the active camera of the scene using its name
  88941. * @param name defines the camera's name
  88942. * @returns the new active camera or null if none found.
  88943. */
  88944. setActiveCameraByName(name: string): Nullable<Camera>;
  88945. /**
  88946. * get an animation group using its name
  88947. * @param name defines the material's name
  88948. * @return the animation group or null if none found.
  88949. */
  88950. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88951. /**
  88952. * get a material using its id
  88953. * @param id defines the material's ID
  88954. * @return the material or null if none found.
  88955. */
  88956. getMaterialByID(id: string): Nullable<Material>;
  88957. /**
  88958. * Gets a material using its name
  88959. * @param name defines the material's name
  88960. * @return the material or null if none found.
  88961. */
  88962. getMaterialByName(name: string): Nullable<Material>;
  88963. /**
  88964. * Gets a camera using its id
  88965. * @param id defines the id to look for
  88966. * @returns the camera or null if not found
  88967. */
  88968. getCameraByID(id: string): Nullable<Camera>;
  88969. /**
  88970. * Gets a camera using its unique id
  88971. * @param uniqueId defines the unique id to look for
  88972. * @returns the camera or null if not found
  88973. */
  88974. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88975. /**
  88976. * Gets a camera using its name
  88977. * @param name defines the camera's name
  88978. * @return the camera or null if none found.
  88979. */
  88980. getCameraByName(name: string): Nullable<Camera>;
  88981. /**
  88982. * Gets a bone using its id
  88983. * @param id defines the bone's id
  88984. * @return the bone or null if not found
  88985. */
  88986. getBoneByID(id: string): Nullable<Bone>;
  88987. /**
  88988. * Gets a bone using its id
  88989. * @param name defines the bone's name
  88990. * @return the bone or null if not found
  88991. */
  88992. getBoneByName(name: string): Nullable<Bone>;
  88993. /**
  88994. * Gets a light node using its name
  88995. * @param name defines the the light's name
  88996. * @return the light or null if none found.
  88997. */
  88998. getLightByName(name: string): Nullable<Light>;
  88999. /**
  89000. * Gets a light node using its id
  89001. * @param id defines the light's id
  89002. * @return the light or null if none found.
  89003. */
  89004. getLightByID(id: string): Nullable<Light>;
  89005. /**
  89006. * Gets a light node using its scene-generated unique ID
  89007. * @param uniqueId defines the light's unique id
  89008. * @return the light or null if none found.
  89009. */
  89010. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89011. /**
  89012. * Gets a particle system by id
  89013. * @param id defines the particle system id
  89014. * @return the corresponding system or null if none found
  89015. */
  89016. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89017. /**
  89018. * Gets a geometry using its ID
  89019. * @param id defines the geometry's id
  89020. * @return the geometry or null if none found.
  89021. */
  89022. getGeometryByID(id: string): Nullable<Geometry>;
  89023. private _getGeometryByUniqueID;
  89024. /**
  89025. * Add a new geometry to this scene
  89026. * @param geometry defines the geometry to be added to the scene.
  89027. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89028. * @return a boolean defining if the geometry was added or not
  89029. */
  89030. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89031. /**
  89032. * Removes an existing geometry
  89033. * @param geometry defines the geometry to be removed from the scene
  89034. * @return a boolean defining if the geometry was removed or not
  89035. */
  89036. removeGeometry(geometry: Geometry): boolean;
  89037. /**
  89038. * Gets the list of geometries attached to the scene
  89039. * @returns an array of Geometry
  89040. */
  89041. getGeometries(): Geometry[];
  89042. /**
  89043. * Gets the first added mesh found of a given ID
  89044. * @param id defines the id to search for
  89045. * @return the mesh found or null if not found at all
  89046. */
  89047. getMeshByID(id: string): Nullable<AbstractMesh>;
  89048. /**
  89049. * Gets a list of meshes using their id
  89050. * @param id defines the id to search for
  89051. * @returns a list of meshes
  89052. */
  89053. getMeshesByID(id: string): Array<AbstractMesh>;
  89054. /**
  89055. * Gets the first added transform node found of a given ID
  89056. * @param id defines the id to search for
  89057. * @return the found transform node or null if not found at all.
  89058. */
  89059. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89060. /**
  89061. * Gets a list of transform nodes using their id
  89062. * @param id defines the id to search for
  89063. * @returns a list of transform nodes
  89064. */
  89065. getTransformNodesByID(id: string): Array<TransformNode>;
  89066. /**
  89067. * Gets a mesh with its auto-generated unique id
  89068. * @param uniqueId defines the unique id to search for
  89069. * @return the found mesh or null if not found at all.
  89070. */
  89071. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89072. /**
  89073. * Gets a the last added mesh using a given id
  89074. * @param id defines the id to search for
  89075. * @return the found mesh or null if not found at all.
  89076. */
  89077. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89078. /**
  89079. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89080. * @param id defines the id to search for
  89081. * @return the found node or null if not found at all
  89082. */
  89083. getLastEntryByID(id: string): Nullable<Node>;
  89084. /**
  89085. * Gets a node (Mesh, Camera, Light) using a given id
  89086. * @param id defines the id to search for
  89087. * @return the found node or null if not found at all
  89088. */
  89089. getNodeByID(id: string): Nullable<Node>;
  89090. /**
  89091. * Gets a node (Mesh, Camera, Light) using a given name
  89092. * @param name defines the name to search for
  89093. * @return the found node or null if not found at all.
  89094. */
  89095. getNodeByName(name: string): Nullable<Node>;
  89096. /**
  89097. * Gets a mesh using a given name
  89098. * @param name defines the name to search for
  89099. * @return the found mesh or null if not found at all.
  89100. */
  89101. getMeshByName(name: string): Nullable<AbstractMesh>;
  89102. /**
  89103. * Gets a transform node using a given name
  89104. * @param name defines the name to search for
  89105. * @return the found transform node or null if not found at all.
  89106. */
  89107. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89108. /**
  89109. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89110. * @param id defines the id to search for
  89111. * @return the found skeleton or null if not found at all.
  89112. */
  89113. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89114. /**
  89115. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89116. * @param id defines the id to search for
  89117. * @return the found skeleton or null if not found at all.
  89118. */
  89119. getSkeletonById(id: string): Nullable<Skeleton>;
  89120. /**
  89121. * Gets a skeleton using a given name
  89122. * @param name defines the name to search for
  89123. * @return the found skeleton or null if not found at all.
  89124. */
  89125. getSkeletonByName(name: string): Nullable<Skeleton>;
  89126. /**
  89127. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89128. * @param id defines the id to search for
  89129. * @return the found morph target manager or null if not found at all.
  89130. */
  89131. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89132. /**
  89133. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89134. * @param id defines the id to search for
  89135. * @return the found morph target or null if not found at all.
  89136. */
  89137. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89138. /**
  89139. * Gets a boolean indicating if the given mesh is active
  89140. * @param mesh defines the mesh to look for
  89141. * @returns true if the mesh is in the active list
  89142. */
  89143. isActiveMesh(mesh: AbstractMesh): boolean;
  89144. /**
  89145. * Return a unique id as a string which can serve as an identifier for the scene
  89146. */
  89147. readonly uid: string;
  89148. /**
  89149. * Add an externaly attached data from its key.
  89150. * This method call will fail and return false, if such key already exists.
  89151. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89152. * @param key the unique key that identifies the data
  89153. * @param data the data object to associate to the key for this Engine instance
  89154. * @return true if no such key were already present and the data was added successfully, false otherwise
  89155. */
  89156. addExternalData<T>(key: string, data: T): boolean;
  89157. /**
  89158. * Get an externaly attached data from its key
  89159. * @param key the unique key that identifies the data
  89160. * @return the associated data, if present (can be null), or undefined if not present
  89161. */
  89162. getExternalData<T>(key: string): Nullable<T>;
  89163. /**
  89164. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89165. * @param key the unique key that identifies the data
  89166. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89167. * @return the associated data, can be null if the factory returned null.
  89168. */
  89169. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89170. /**
  89171. * Remove an externaly attached data from the Engine instance
  89172. * @param key the unique key that identifies the data
  89173. * @return true if the data was successfully removed, false if it doesn't exist
  89174. */
  89175. removeExternalData(key: string): boolean;
  89176. private _evaluateSubMesh;
  89177. /**
  89178. * Clear the processed materials smart array preventing retention point in material dispose.
  89179. */
  89180. freeProcessedMaterials(): void;
  89181. private _preventFreeActiveMeshesAndRenderingGroups;
  89182. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89183. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89184. * when disposing several meshes in a row or a hierarchy of meshes.
  89185. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89186. */
  89187. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89188. /**
  89189. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89190. */
  89191. freeActiveMeshes(): void;
  89192. /**
  89193. * Clear the info related to rendering groups preventing retention points during dispose.
  89194. */
  89195. freeRenderingGroups(): void;
  89196. /** @hidden */
  89197. _isInIntermediateRendering(): boolean;
  89198. /**
  89199. * Lambda returning the list of potentially active meshes.
  89200. */
  89201. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89202. /**
  89203. * Lambda returning the list of potentially active sub meshes.
  89204. */
  89205. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89206. /**
  89207. * Lambda returning the list of potentially intersecting sub meshes.
  89208. */
  89209. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89210. /**
  89211. * Lambda returning the list of potentially colliding sub meshes.
  89212. */
  89213. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89214. private _activeMeshesFrozen;
  89215. /**
  89216. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89217. * @returns the current scene
  89218. */
  89219. freezeActiveMeshes(): Scene;
  89220. /**
  89221. * Use this function to restart evaluating active meshes on every frame
  89222. * @returns the current scene
  89223. */
  89224. unfreezeActiveMeshes(): Scene;
  89225. private _evaluateActiveMeshes;
  89226. private _activeMesh;
  89227. /**
  89228. * Update the transform matrix to update from the current active camera
  89229. * @param force defines a boolean used to force the update even if cache is up to date
  89230. */
  89231. updateTransformMatrix(force?: boolean): void;
  89232. /**
  89233. * 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)
  89234. * @param alternateCamera defines the camera to use
  89235. */
  89236. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89237. /** @hidden */
  89238. _allowPostProcessClearColor: boolean;
  89239. private _renderForCamera;
  89240. private _processSubCameras;
  89241. private _checkIntersections;
  89242. /** @hidden */
  89243. _advancePhysicsEngineStep(step: number): void;
  89244. /**
  89245. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89246. */
  89247. getDeterministicFrameTime: () => number;
  89248. /** @hidden */
  89249. _animate(): void;
  89250. /**
  89251. * Render the scene
  89252. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89253. */
  89254. render(updateCameras?: boolean): void;
  89255. /**
  89256. * Freeze all materials
  89257. * A frozen material will not be updatable but should be faster to render
  89258. */
  89259. freezeMaterials(): void;
  89260. /**
  89261. * Unfreeze all materials
  89262. * A frozen material will not be updatable but should be faster to render
  89263. */
  89264. unfreezeMaterials(): void;
  89265. /**
  89266. * Releases all held ressources
  89267. */
  89268. dispose(): void;
  89269. /**
  89270. * Gets if the scene is already disposed
  89271. */
  89272. readonly isDisposed: boolean;
  89273. /**
  89274. * Call this function to reduce memory footprint of the scene.
  89275. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89276. */
  89277. clearCachedVertexData(): void;
  89278. /**
  89279. * This function will remove the local cached buffer data from texture.
  89280. * It will save memory but will prevent the texture from being rebuilt
  89281. */
  89282. cleanCachedTextureBuffer(): void;
  89283. /**
  89284. * Get the world extend vectors with an optional filter
  89285. *
  89286. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89287. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89288. */
  89289. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89290. min: Vector3;
  89291. max: Vector3;
  89292. };
  89293. /**
  89294. * Creates a ray that can be used to pick in the scene
  89295. * @param x defines the x coordinate of the origin (on-screen)
  89296. * @param y defines the y coordinate of the origin (on-screen)
  89297. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89298. * @param camera defines the camera to use for the picking
  89299. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89300. * @returns a Ray
  89301. */
  89302. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89303. /**
  89304. * Creates a ray that can be used to pick in the scene
  89305. * @param x defines the x coordinate of the origin (on-screen)
  89306. * @param y defines the y coordinate of the origin (on-screen)
  89307. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89308. * @param result defines the ray where to store the picking ray
  89309. * @param camera defines the camera to use for the picking
  89310. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89311. * @returns the current scene
  89312. */
  89313. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89314. /**
  89315. * Creates a ray that can be used to pick in the scene
  89316. * @param x defines the x coordinate of the origin (on-screen)
  89317. * @param y defines the y coordinate of the origin (on-screen)
  89318. * @param camera defines the camera to use for the picking
  89319. * @returns a Ray
  89320. */
  89321. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89322. /**
  89323. * Creates a ray that can be used to pick in the scene
  89324. * @param x defines the x coordinate of the origin (on-screen)
  89325. * @param y defines the y coordinate of the origin (on-screen)
  89326. * @param result defines the ray where to store the picking ray
  89327. * @param camera defines the camera to use for the picking
  89328. * @returns the current scene
  89329. */
  89330. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89331. /** Launch a ray to try to pick a mesh in the scene
  89332. * @param x position on screen
  89333. * @param y position on screen
  89334. * @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
  89335. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89336. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89337. * @returns a PickingInfo
  89338. */
  89339. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89340. /** Use the given ray to pick a mesh in the scene
  89341. * @param ray The ray to use to pick meshes
  89342. * @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
  89343. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89344. * @returns a PickingInfo
  89345. */
  89346. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89347. /**
  89348. * Launch a ray to try to pick a mesh in the scene
  89349. * @param x X position on screen
  89350. * @param y Y position on screen
  89351. * @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
  89352. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89353. * @returns an array of PickingInfo
  89354. */
  89355. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89356. /**
  89357. * Launch a ray to try to pick a mesh in the scene
  89358. * @param ray Ray to use
  89359. * @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
  89360. * @returns an array of PickingInfo
  89361. */
  89362. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89363. /**
  89364. * Force the value of meshUnderPointer
  89365. * @param mesh defines the mesh to use
  89366. */
  89367. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89368. /**
  89369. * Gets the mesh under the pointer
  89370. * @returns a Mesh or null if no mesh is under the pointer
  89371. */
  89372. getPointerOverMesh(): Nullable<AbstractMesh>;
  89373. /** @hidden */
  89374. _rebuildGeometries(): void;
  89375. /** @hidden */
  89376. _rebuildTextures(): void;
  89377. private _getByTags;
  89378. /**
  89379. * Get a list of meshes by tags
  89380. * @param tagsQuery defines the tags query to use
  89381. * @param forEach defines a predicate used to filter results
  89382. * @returns an array of Mesh
  89383. */
  89384. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89385. /**
  89386. * Get a list of cameras by tags
  89387. * @param tagsQuery defines the tags query to use
  89388. * @param forEach defines a predicate used to filter results
  89389. * @returns an array of Camera
  89390. */
  89391. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89392. /**
  89393. * Get a list of lights by tags
  89394. * @param tagsQuery defines the tags query to use
  89395. * @param forEach defines a predicate used to filter results
  89396. * @returns an array of Light
  89397. */
  89398. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89399. /**
  89400. * Get a list of materials by tags
  89401. * @param tagsQuery defines the tags query to use
  89402. * @param forEach defines a predicate used to filter results
  89403. * @returns an array of Material
  89404. */
  89405. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89406. /**
  89407. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89408. * This allowed control for front to back rendering or reversly depending of the special needs.
  89409. *
  89410. * @param renderingGroupId The rendering group id corresponding to its index
  89411. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89412. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89413. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89414. */
  89415. 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;
  89416. /**
  89417. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89418. *
  89419. * @param renderingGroupId The rendering group id corresponding to its index
  89420. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89421. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89422. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89423. */
  89424. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89425. /**
  89426. * Gets the current auto clear configuration for one rendering group of the rendering
  89427. * manager.
  89428. * @param index the rendering group index to get the information for
  89429. * @returns The auto clear setup for the requested rendering group
  89430. */
  89431. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89432. private _blockMaterialDirtyMechanism;
  89433. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89434. blockMaterialDirtyMechanism: boolean;
  89435. /**
  89436. * Will flag all materials as dirty to trigger new shader compilation
  89437. * @param flag defines the flag used to specify which material part must be marked as dirty
  89438. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89439. */
  89440. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89441. /** @hidden */
  89442. _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;
  89443. /** @hidden */
  89444. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89445. }
  89446. }
  89447. declare module BABYLON {
  89448. /**
  89449. * Set of assets to keep when moving a scene into an asset container.
  89450. */
  89451. export class KeepAssets extends AbstractScene {
  89452. }
  89453. /**
  89454. * Container with a set of assets that can be added or removed from a scene.
  89455. */
  89456. export class AssetContainer extends AbstractScene {
  89457. /**
  89458. * The scene the AssetContainer belongs to.
  89459. */
  89460. scene: Scene;
  89461. /**
  89462. * Instantiates an AssetContainer.
  89463. * @param scene The scene the AssetContainer belongs to.
  89464. */
  89465. constructor(scene: Scene);
  89466. /**
  89467. * Adds all the assets from the container to the scene.
  89468. */
  89469. addAllToScene(): void;
  89470. /**
  89471. * Removes all the assets in the container from the scene
  89472. */
  89473. removeAllFromScene(): void;
  89474. /**
  89475. * Disposes all the assets in the container
  89476. */
  89477. dispose(): void;
  89478. private _moveAssets;
  89479. /**
  89480. * Removes all the assets contained in the scene and adds them to the container.
  89481. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89482. */
  89483. moveAllFromScene(keepAssets?: KeepAssets): void;
  89484. /**
  89485. * 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.
  89486. * @returns the root mesh
  89487. */
  89488. createRootMesh(): Mesh;
  89489. }
  89490. }
  89491. declare module BABYLON {
  89492. /**
  89493. * Defines how the parser contract is defined.
  89494. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89495. */
  89496. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89497. /**
  89498. * Defines how the individual parser contract is defined.
  89499. * These parser can parse an individual asset
  89500. */
  89501. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89502. /**
  89503. * Base class of the scene acting as a container for the different elements composing a scene.
  89504. * This class is dynamically extended by the different components of the scene increasing
  89505. * flexibility and reducing coupling
  89506. */
  89507. export abstract class AbstractScene {
  89508. /**
  89509. * Stores the list of available parsers in the application.
  89510. */
  89511. private static _BabylonFileParsers;
  89512. /**
  89513. * Stores the list of available individual parsers in the application.
  89514. */
  89515. private static _IndividualBabylonFileParsers;
  89516. /**
  89517. * Adds a parser in the list of available ones
  89518. * @param name Defines the name of the parser
  89519. * @param parser Defines the parser to add
  89520. */
  89521. static AddParser(name: string, parser: BabylonFileParser): void;
  89522. /**
  89523. * Gets a general parser from the list of avaialble ones
  89524. * @param name Defines the name of the parser
  89525. * @returns the requested parser or null
  89526. */
  89527. static GetParser(name: string): Nullable<BabylonFileParser>;
  89528. /**
  89529. * Adds n individual parser in the list of available ones
  89530. * @param name Defines the name of the parser
  89531. * @param parser Defines the parser to add
  89532. */
  89533. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89534. /**
  89535. * Gets an individual parser from the list of avaialble ones
  89536. * @param name Defines the name of the parser
  89537. * @returns the requested parser or null
  89538. */
  89539. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89540. /**
  89541. * Parser json data and populate both a scene and its associated container object
  89542. * @param jsonData Defines the data to parse
  89543. * @param scene Defines the scene to parse the data for
  89544. * @param container Defines the container attached to the parsing sequence
  89545. * @param rootUrl Defines the root url of the data
  89546. */
  89547. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89548. /**
  89549. * Gets the list of root nodes (ie. nodes with no parent)
  89550. */
  89551. rootNodes: Node[];
  89552. /** All of the cameras added to this scene
  89553. * @see http://doc.babylonjs.com/babylon101/cameras
  89554. */
  89555. cameras: Camera[];
  89556. /**
  89557. * All of the lights added to this scene
  89558. * @see http://doc.babylonjs.com/babylon101/lights
  89559. */
  89560. lights: Light[];
  89561. /**
  89562. * All of the (abstract) meshes added to this scene
  89563. */
  89564. meshes: AbstractMesh[];
  89565. /**
  89566. * The list of skeletons added to the scene
  89567. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89568. */
  89569. skeletons: Skeleton[];
  89570. /**
  89571. * All of the particle systems added to this scene
  89572. * @see http://doc.babylonjs.com/babylon101/particles
  89573. */
  89574. particleSystems: IParticleSystem[];
  89575. /**
  89576. * Gets a list of Animations associated with the scene
  89577. */
  89578. animations: Animation[];
  89579. /**
  89580. * All of the animation groups added to this scene
  89581. * @see http://doc.babylonjs.com/how_to/group
  89582. */
  89583. animationGroups: AnimationGroup[];
  89584. /**
  89585. * All of the multi-materials added to this scene
  89586. * @see http://doc.babylonjs.com/how_to/multi_materials
  89587. */
  89588. multiMaterials: MultiMaterial[];
  89589. /**
  89590. * All of the materials added to this scene
  89591. * In the context of a Scene, it is not supposed to be modified manually.
  89592. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89593. * Note also that the order of the Material wihin the array is not significant and might change.
  89594. * @see http://doc.babylonjs.com/babylon101/materials
  89595. */
  89596. materials: Material[];
  89597. /**
  89598. * The list of morph target managers added to the scene
  89599. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89600. */
  89601. morphTargetManagers: MorphTargetManager[];
  89602. /**
  89603. * The list of geometries used in the scene.
  89604. */
  89605. geometries: Geometry[];
  89606. /**
  89607. * All of the tranform nodes added to this scene
  89608. * In the context of a Scene, it is not supposed to be modified manually.
  89609. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89610. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89611. * @see http://doc.babylonjs.com/how_to/transformnode
  89612. */
  89613. transformNodes: TransformNode[];
  89614. /**
  89615. * ActionManagers available on the scene.
  89616. */
  89617. actionManagers: AbstractActionManager[];
  89618. /**
  89619. * Textures to keep.
  89620. */
  89621. textures: BaseTexture[];
  89622. }
  89623. }
  89624. declare module BABYLON {
  89625. /**
  89626. * Defines a sound that can be played in the application.
  89627. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89629. */
  89630. export class Sound {
  89631. /**
  89632. * The name of the sound in the scene.
  89633. */
  89634. name: string;
  89635. /**
  89636. * Does the sound autoplay once loaded.
  89637. */
  89638. autoplay: boolean;
  89639. /**
  89640. * Does the sound loop after it finishes playing once.
  89641. */
  89642. loop: boolean;
  89643. /**
  89644. * Does the sound use a custom attenuation curve to simulate the falloff
  89645. * happening when the source gets further away from the camera.
  89646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89647. */
  89648. useCustomAttenuation: boolean;
  89649. /**
  89650. * The sound track id this sound belongs to.
  89651. */
  89652. soundTrackId: number;
  89653. /**
  89654. * Is this sound currently played.
  89655. */
  89656. isPlaying: boolean;
  89657. /**
  89658. * Is this sound currently paused.
  89659. */
  89660. isPaused: boolean;
  89661. /**
  89662. * Does this sound enables spatial sound.
  89663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89664. */
  89665. spatialSound: boolean;
  89666. /**
  89667. * Define the reference distance the sound should be heard perfectly.
  89668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89669. */
  89670. refDistance: number;
  89671. /**
  89672. * Define the roll off factor of spatial sounds.
  89673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89674. */
  89675. rolloffFactor: number;
  89676. /**
  89677. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89679. */
  89680. maxDistance: number;
  89681. /**
  89682. * Define the distance attenuation model the sound will follow.
  89683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89684. */
  89685. distanceModel: string;
  89686. /**
  89687. * @hidden
  89688. * Back Compat
  89689. **/
  89690. onended: () => any;
  89691. /**
  89692. * Observable event when the current playing sound finishes.
  89693. */
  89694. onEndedObservable: Observable<Sound>;
  89695. private _panningModel;
  89696. private _playbackRate;
  89697. private _streaming;
  89698. private _startTime;
  89699. private _startOffset;
  89700. private _position;
  89701. /** @hidden */
  89702. _positionInEmitterSpace: boolean;
  89703. private _localDirection;
  89704. private _volume;
  89705. private _isReadyToPlay;
  89706. private _isDirectional;
  89707. private _readyToPlayCallback;
  89708. private _audioBuffer;
  89709. private _soundSource;
  89710. private _streamingSource;
  89711. private _soundPanner;
  89712. private _soundGain;
  89713. private _inputAudioNode;
  89714. private _outputAudioNode;
  89715. private _coneInnerAngle;
  89716. private _coneOuterAngle;
  89717. private _coneOuterGain;
  89718. private _scene;
  89719. private _connectedTransformNode;
  89720. private _customAttenuationFunction;
  89721. private _registerFunc;
  89722. private _isOutputConnected;
  89723. private _htmlAudioElement;
  89724. private _urlType;
  89725. /** @hidden */
  89726. static _SceneComponentInitialization: (scene: Scene) => void;
  89727. /**
  89728. * Create a sound and attach it to a scene
  89729. * @param name Name of your sound
  89730. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89731. * @param scene defines the scene the sound belongs to
  89732. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89733. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89734. */
  89735. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89736. /**
  89737. * Release the sound and its associated resources
  89738. */
  89739. dispose(): void;
  89740. /**
  89741. * Gets if the sounds is ready to be played or not.
  89742. * @returns true if ready, otherwise false
  89743. */
  89744. isReady(): boolean;
  89745. private _soundLoaded;
  89746. /**
  89747. * Sets the data of the sound from an audiobuffer
  89748. * @param audioBuffer The audioBuffer containing the data
  89749. */
  89750. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89751. /**
  89752. * Updates the current sounds options such as maxdistance, loop...
  89753. * @param options A JSON object containing values named as the object properties
  89754. */
  89755. updateOptions(options: any): void;
  89756. private _createSpatialParameters;
  89757. private _updateSpatialParameters;
  89758. /**
  89759. * Switch the panning model to HRTF:
  89760. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89762. */
  89763. switchPanningModelToHRTF(): void;
  89764. /**
  89765. * Switch the panning model to Equal Power:
  89766. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89768. */
  89769. switchPanningModelToEqualPower(): void;
  89770. private _switchPanningModel;
  89771. /**
  89772. * Connect this sound to a sound track audio node like gain...
  89773. * @param soundTrackAudioNode the sound track audio node to connect to
  89774. */
  89775. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89776. /**
  89777. * Transform this sound into a directional source
  89778. * @param coneInnerAngle Size of the inner cone in degree
  89779. * @param coneOuterAngle Size of the outer cone in degree
  89780. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89781. */
  89782. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89783. /**
  89784. * Gets or sets the inner angle for the directional cone.
  89785. */
  89786. /**
  89787. * Gets or sets the inner angle for the directional cone.
  89788. */
  89789. directionalConeInnerAngle: number;
  89790. /**
  89791. * Gets or sets the outer angle for the directional cone.
  89792. */
  89793. /**
  89794. * Gets or sets the outer angle for the directional cone.
  89795. */
  89796. directionalConeOuterAngle: number;
  89797. /**
  89798. * Sets the position of the emitter if spatial sound is enabled
  89799. * @param newPosition Defines the new posisiton
  89800. */
  89801. setPosition(newPosition: Vector3): void;
  89802. /**
  89803. * Sets the local direction of the emitter if spatial sound is enabled
  89804. * @param newLocalDirection Defines the new local direction
  89805. */
  89806. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89807. private _updateDirection;
  89808. /** @hidden */
  89809. updateDistanceFromListener(): void;
  89810. /**
  89811. * Sets a new custom attenuation function for the sound.
  89812. * @param callback Defines the function used for the attenuation
  89813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89814. */
  89815. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89816. /**
  89817. * Play the sound
  89818. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89819. * @param offset (optional) Start the sound setting it at a specific time
  89820. */
  89821. play(time?: number, offset?: number): void;
  89822. private _onended;
  89823. /**
  89824. * Stop the sound
  89825. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89826. */
  89827. stop(time?: number): void;
  89828. /**
  89829. * Put the sound in pause
  89830. */
  89831. pause(): void;
  89832. /**
  89833. * Sets a dedicated volume for this sounds
  89834. * @param newVolume Define the new volume of the sound
  89835. * @param time Define in how long the sound should be at this value
  89836. */
  89837. setVolume(newVolume: number, time?: number): void;
  89838. /**
  89839. * Set the sound play back rate
  89840. * @param newPlaybackRate Define the playback rate the sound should be played at
  89841. */
  89842. setPlaybackRate(newPlaybackRate: number): void;
  89843. /**
  89844. * Gets the volume of the sound.
  89845. * @returns the volume of the sound
  89846. */
  89847. getVolume(): number;
  89848. /**
  89849. * Attach the sound to a dedicated mesh
  89850. * @param transformNode The transform node to connect the sound with
  89851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89852. */
  89853. attachToMesh(transformNode: TransformNode): void;
  89854. /**
  89855. * Detach the sound from the previously attached mesh
  89856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89857. */
  89858. detachFromMesh(): void;
  89859. private _onRegisterAfterWorldMatrixUpdate;
  89860. /**
  89861. * Clone the current sound in the scene.
  89862. * @returns the new sound clone
  89863. */
  89864. clone(): Nullable<Sound>;
  89865. /**
  89866. * Gets the current underlying audio buffer containing the data
  89867. * @returns the audio buffer
  89868. */
  89869. getAudioBuffer(): Nullable<AudioBuffer>;
  89870. /**
  89871. * Serializes the Sound in a JSON representation
  89872. * @returns the JSON representation of the sound
  89873. */
  89874. serialize(): any;
  89875. /**
  89876. * Parse a JSON representation of a sound to innstantiate in a given scene
  89877. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89878. * @param scene Define the scene the new parsed sound should be created in
  89879. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89880. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89881. * @returns the newly parsed sound
  89882. */
  89883. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89884. }
  89885. }
  89886. declare module BABYLON {
  89887. /**
  89888. * This defines an action helpful to play a defined sound on a triggered action.
  89889. */
  89890. export class PlaySoundAction extends Action {
  89891. private _sound;
  89892. /**
  89893. * Instantiate the action
  89894. * @param triggerOptions defines the trigger options
  89895. * @param sound defines the sound to play
  89896. * @param condition defines the trigger related conditions
  89897. */
  89898. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89899. /** @hidden */
  89900. _prepare(): void;
  89901. /**
  89902. * Execute the action and play the sound.
  89903. */
  89904. execute(): void;
  89905. /**
  89906. * Serializes the actions and its related information.
  89907. * @param parent defines the object to serialize in
  89908. * @returns the serialized object
  89909. */
  89910. serialize(parent: any): any;
  89911. }
  89912. /**
  89913. * This defines an action helpful to stop a defined sound on a triggered action.
  89914. */
  89915. export class StopSoundAction extends Action {
  89916. private _sound;
  89917. /**
  89918. * Instantiate the action
  89919. * @param triggerOptions defines the trigger options
  89920. * @param sound defines the sound to stop
  89921. * @param condition defines the trigger related conditions
  89922. */
  89923. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89924. /** @hidden */
  89925. _prepare(): void;
  89926. /**
  89927. * Execute the action and stop the sound.
  89928. */
  89929. execute(): void;
  89930. /**
  89931. * Serializes the actions and its related information.
  89932. * @param parent defines the object to serialize in
  89933. * @returns the serialized object
  89934. */
  89935. serialize(parent: any): any;
  89936. }
  89937. }
  89938. declare module BABYLON {
  89939. /**
  89940. * This defines an action responsible to change the value of a property
  89941. * by interpolating between its current value and the newly set one once triggered.
  89942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89943. */
  89944. export class InterpolateValueAction extends Action {
  89945. /**
  89946. * Defines the path of the property where the value should be interpolated
  89947. */
  89948. propertyPath: string;
  89949. /**
  89950. * Defines the target value at the end of the interpolation.
  89951. */
  89952. value: any;
  89953. /**
  89954. * Defines the time it will take for the property to interpolate to the value.
  89955. */
  89956. duration: number;
  89957. /**
  89958. * Defines if the other scene animations should be stopped when the action has been triggered
  89959. */
  89960. stopOtherAnimations?: boolean;
  89961. /**
  89962. * Defines a callback raised once the interpolation animation has been done.
  89963. */
  89964. onInterpolationDone?: () => void;
  89965. /**
  89966. * Observable triggered once the interpolation animation has been done.
  89967. */
  89968. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89969. private _target;
  89970. private _effectiveTarget;
  89971. private _property;
  89972. /**
  89973. * Instantiate the action
  89974. * @param triggerOptions defines the trigger options
  89975. * @param target defines the object containing the value to interpolate
  89976. * @param propertyPath defines the path to the property in the target object
  89977. * @param value defines the target value at the end of the interpolation
  89978. * @param duration deines the time it will take for the property to interpolate to the value.
  89979. * @param condition defines the trigger related conditions
  89980. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89981. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89982. */
  89983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89984. /** @hidden */
  89985. _prepare(): void;
  89986. /**
  89987. * Execute the action starts the value interpolation.
  89988. */
  89989. execute(): void;
  89990. /**
  89991. * Serializes the actions and its related information.
  89992. * @param parent defines the object to serialize in
  89993. * @returns the serialized object
  89994. */
  89995. serialize(parent: any): any;
  89996. }
  89997. }
  89998. declare module BABYLON {
  89999. /**
  90000. * Options allowed during the creation of a sound track.
  90001. */
  90002. export interface ISoundTrackOptions {
  90003. /**
  90004. * The volume the sound track should take during creation
  90005. */
  90006. volume?: number;
  90007. /**
  90008. * Define if the sound track is the main sound track of the scene
  90009. */
  90010. mainTrack?: boolean;
  90011. }
  90012. /**
  90013. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90014. * It will be also used in a future release to apply effects on a specific track.
  90015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90016. */
  90017. export class SoundTrack {
  90018. /**
  90019. * The unique identifier of the sound track in the scene.
  90020. */
  90021. id: number;
  90022. /**
  90023. * The list of sounds included in the sound track.
  90024. */
  90025. soundCollection: Array<Sound>;
  90026. private _outputAudioNode;
  90027. private _scene;
  90028. private _isMainTrack;
  90029. private _connectedAnalyser;
  90030. private _options;
  90031. private _isInitialized;
  90032. /**
  90033. * Creates a new sound track.
  90034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90035. * @param scene Define the scene the sound track belongs to
  90036. * @param options
  90037. */
  90038. constructor(scene: Scene, options?: ISoundTrackOptions);
  90039. private _initializeSoundTrackAudioGraph;
  90040. /**
  90041. * Release the sound track and its associated resources
  90042. */
  90043. dispose(): void;
  90044. /**
  90045. * Adds a sound to this sound track
  90046. * @param sound define the cound to add
  90047. * @ignoreNaming
  90048. */
  90049. AddSound(sound: Sound): void;
  90050. /**
  90051. * Removes a sound to this sound track
  90052. * @param sound define the cound to remove
  90053. * @ignoreNaming
  90054. */
  90055. RemoveSound(sound: Sound): void;
  90056. /**
  90057. * Set a global volume for the full sound track.
  90058. * @param newVolume Define the new volume of the sound track
  90059. */
  90060. setVolume(newVolume: number): void;
  90061. /**
  90062. * Switch the panning model to HRTF:
  90063. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90065. */
  90066. switchPanningModelToHRTF(): void;
  90067. /**
  90068. * Switch the panning model to Equal Power:
  90069. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90071. */
  90072. switchPanningModelToEqualPower(): void;
  90073. /**
  90074. * Connect the sound track to an audio analyser allowing some amazing
  90075. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90077. * @param analyser The analyser to connect to the engine
  90078. */
  90079. connectToAnalyser(analyser: Analyser): void;
  90080. }
  90081. }
  90082. declare module BABYLON {
  90083. interface AbstractScene {
  90084. /**
  90085. * The list of sounds used in the scene.
  90086. */
  90087. sounds: Nullable<Array<Sound>>;
  90088. }
  90089. interface Scene {
  90090. /**
  90091. * @hidden
  90092. * Backing field
  90093. */
  90094. _mainSoundTrack: SoundTrack;
  90095. /**
  90096. * The main sound track played by the scene.
  90097. * It cotains your primary collection of sounds.
  90098. */
  90099. mainSoundTrack: SoundTrack;
  90100. /**
  90101. * The list of sound tracks added to the scene
  90102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90103. */
  90104. soundTracks: Nullable<Array<SoundTrack>>;
  90105. /**
  90106. * Gets a sound using a given name
  90107. * @param name defines the name to search for
  90108. * @return the found sound or null if not found at all.
  90109. */
  90110. getSoundByName(name: string): Nullable<Sound>;
  90111. /**
  90112. * Gets or sets if audio support is enabled
  90113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90114. */
  90115. audioEnabled: boolean;
  90116. /**
  90117. * Gets or sets if audio will be output to headphones
  90118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90119. */
  90120. headphone: boolean;
  90121. }
  90122. /**
  90123. * Defines the sound scene component responsible to manage any sounds
  90124. * in a given scene.
  90125. */
  90126. export class AudioSceneComponent implements ISceneSerializableComponent {
  90127. /**
  90128. * The component name helpfull to identify the component in the list of scene components.
  90129. */
  90130. readonly name: string;
  90131. /**
  90132. * The scene the component belongs to.
  90133. */
  90134. scene: Scene;
  90135. private _audioEnabled;
  90136. /**
  90137. * Gets whether audio is enabled or not.
  90138. * Please use related enable/disable method to switch state.
  90139. */
  90140. readonly audioEnabled: boolean;
  90141. private _headphone;
  90142. /**
  90143. * Gets whether audio is outputing to headphone or not.
  90144. * Please use the according Switch methods to change output.
  90145. */
  90146. readonly headphone: boolean;
  90147. /**
  90148. * Creates a new instance of the component for the given scene
  90149. * @param scene Defines the scene to register the component in
  90150. */
  90151. constructor(scene: Scene);
  90152. /**
  90153. * Registers the component in a given scene
  90154. */
  90155. register(): void;
  90156. /**
  90157. * Rebuilds the elements related to this component in case of
  90158. * context lost for instance.
  90159. */
  90160. rebuild(): void;
  90161. /**
  90162. * Serializes the component data to the specified json object
  90163. * @param serializationObject The object to serialize to
  90164. */
  90165. serialize(serializationObject: any): void;
  90166. /**
  90167. * Adds all the element from the container to the scene
  90168. * @param container the container holding the elements
  90169. */
  90170. addFromContainer(container: AbstractScene): void;
  90171. /**
  90172. * Removes all the elements in the container from the scene
  90173. * @param container contains the elements to remove
  90174. */
  90175. removeFromContainer(container: AbstractScene): void;
  90176. /**
  90177. * Disposes the component and the associated ressources.
  90178. */
  90179. dispose(): void;
  90180. /**
  90181. * Disables audio in the associated scene.
  90182. */
  90183. disableAudio(): void;
  90184. /**
  90185. * Enables audio in the associated scene.
  90186. */
  90187. enableAudio(): void;
  90188. /**
  90189. * Switch audio to headphone output.
  90190. */
  90191. switchAudioModeForHeadphones(): void;
  90192. /**
  90193. * Switch audio to normal speakers.
  90194. */
  90195. switchAudioModeForNormalSpeakers(): void;
  90196. private _afterRender;
  90197. }
  90198. }
  90199. declare module BABYLON {
  90200. /**
  90201. * Wraps one or more Sound objects and selects one with random weight for playback.
  90202. */
  90203. export class WeightedSound {
  90204. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90205. loop: boolean;
  90206. private _coneInnerAngle;
  90207. private _coneOuterAngle;
  90208. private _volume;
  90209. /** A Sound is currently playing. */
  90210. isPlaying: boolean;
  90211. /** A Sound is currently paused. */
  90212. isPaused: boolean;
  90213. private _sounds;
  90214. private _weights;
  90215. private _currentIndex?;
  90216. /**
  90217. * Creates a new WeightedSound from the list of sounds given.
  90218. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90219. * @param sounds Array of Sounds that will be selected from.
  90220. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90221. */
  90222. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90223. /**
  90224. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90225. */
  90226. /**
  90227. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90228. */
  90229. directionalConeInnerAngle: number;
  90230. /**
  90231. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90232. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90233. */
  90234. /**
  90235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90237. */
  90238. directionalConeOuterAngle: number;
  90239. /**
  90240. * Playback volume.
  90241. */
  90242. /**
  90243. * Playback volume.
  90244. */
  90245. volume: number;
  90246. private _onended;
  90247. /**
  90248. * Suspend playback
  90249. */
  90250. pause(): void;
  90251. /**
  90252. * Stop playback
  90253. */
  90254. stop(): void;
  90255. /**
  90256. * Start playback.
  90257. * @param startOffset Position the clip head at a specific time in seconds.
  90258. */
  90259. play(startOffset?: number): void;
  90260. }
  90261. }
  90262. declare module BABYLON {
  90263. /**
  90264. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90266. */
  90267. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90268. /**
  90269. * Gets the name of the behavior.
  90270. */
  90271. readonly name: string;
  90272. /**
  90273. * The easing function used by animations
  90274. */
  90275. static EasingFunction: BackEase;
  90276. /**
  90277. * The easing mode used by animations
  90278. */
  90279. static EasingMode: number;
  90280. /**
  90281. * The duration of the animation, in milliseconds
  90282. */
  90283. transitionDuration: number;
  90284. /**
  90285. * Length of the distance animated by the transition when lower radius is reached
  90286. */
  90287. lowerRadiusTransitionRange: number;
  90288. /**
  90289. * Length of the distance animated by the transition when upper radius is reached
  90290. */
  90291. upperRadiusTransitionRange: number;
  90292. private _autoTransitionRange;
  90293. /**
  90294. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90295. */
  90296. /**
  90297. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90298. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90299. */
  90300. autoTransitionRange: boolean;
  90301. private _attachedCamera;
  90302. private _onAfterCheckInputsObserver;
  90303. private _onMeshTargetChangedObserver;
  90304. /**
  90305. * Initializes the behavior.
  90306. */
  90307. init(): void;
  90308. /**
  90309. * Attaches the behavior to its arc rotate camera.
  90310. * @param camera Defines the camera to attach the behavior to
  90311. */
  90312. attach(camera: ArcRotateCamera): void;
  90313. /**
  90314. * Detaches the behavior from its current arc rotate camera.
  90315. */
  90316. detach(): void;
  90317. private _radiusIsAnimating;
  90318. private _radiusBounceTransition;
  90319. private _animatables;
  90320. private _cachedWheelPrecision;
  90321. /**
  90322. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90323. * @param radiusLimit The limit to check against.
  90324. * @return Bool to indicate if at limit.
  90325. */
  90326. private _isRadiusAtLimit;
  90327. /**
  90328. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90329. * @param radiusDelta The delta by which to animate to. Can be negative.
  90330. */
  90331. private _applyBoundRadiusAnimation;
  90332. /**
  90333. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90334. */
  90335. protected _clearAnimationLocks(): void;
  90336. /**
  90337. * Stops and removes all animations that have been applied to the camera
  90338. */
  90339. stopAllAnimations(): void;
  90340. }
  90341. }
  90342. declare module BABYLON {
  90343. /**
  90344. * 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.
  90345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90346. */
  90347. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90348. /**
  90349. * Gets the name of the behavior.
  90350. */
  90351. readonly name: string;
  90352. private _mode;
  90353. private _radiusScale;
  90354. private _positionScale;
  90355. private _defaultElevation;
  90356. private _elevationReturnTime;
  90357. private _elevationReturnWaitTime;
  90358. private _zoomStopsAnimation;
  90359. private _framingTime;
  90360. /**
  90361. * The easing function used by animations
  90362. */
  90363. static EasingFunction: ExponentialEase;
  90364. /**
  90365. * The easing mode used by animations
  90366. */
  90367. static EasingMode: number;
  90368. /**
  90369. * Sets the current mode used by the behavior
  90370. */
  90371. /**
  90372. * Gets current mode used by the behavior.
  90373. */
  90374. mode: number;
  90375. /**
  90376. * Sets the scale applied to the radius (1 by default)
  90377. */
  90378. /**
  90379. * Gets the scale applied to the radius
  90380. */
  90381. radiusScale: number;
  90382. /**
  90383. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90384. */
  90385. /**
  90386. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90387. */
  90388. positionScale: number;
  90389. /**
  90390. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90391. * behaviour is triggered, in radians.
  90392. */
  90393. /**
  90394. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90395. * behaviour is triggered, in radians.
  90396. */
  90397. defaultElevation: number;
  90398. /**
  90399. * Sets the time (in milliseconds) taken to return to the default beta position.
  90400. * Negative value indicates camera should not return to default.
  90401. */
  90402. /**
  90403. * Gets the time (in milliseconds) taken to return to the default beta position.
  90404. * Negative value indicates camera should not return to default.
  90405. */
  90406. elevationReturnTime: number;
  90407. /**
  90408. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90409. */
  90410. /**
  90411. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90412. */
  90413. elevationReturnWaitTime: number;
  90414. /**
  90415. * Sets the flag that indicates if user zooming should stop animation.
  90416. */
  90417. /**
  90418. * Gets the flag that indicates if user zooming should stop animation.
  90419. */
  90420. zoomStopsAnimation: boolean;
  90421. /**
  90422. * Sets the transition time when framing the mesh, in milliseconds
  90423. */
  90424. /**
  90425. * Gets the transition time when framing the mesh, in milliseconds
  90426. */
  90427. framingTime: number;
  90428. /**
  90429. * Define if the behavior should automatically change the configured
  90430. * camera limits and sensibilities.
  90431. */
  90432. autoCorrectCameraLimitsAndSensibility: boolean;
  90433. private _onPrePointerObservableObserver;
  90434. private _onAfterCheckInputsObserver;
  90435. private _onMeshTargetChangedObserver;
  90436. private _attachedCamera;
  90437. private _isPointerDown;
  90438. private _lastInteractionTime;
  90439. /**
  90440. * Initializes the behavior.
  90441. */
  90442. init(): void;
  90443. /**
  90444. * Attaches the behavior to its arc rotate camera.
  90445. * @param camera Defines the camera to attach the behavior to
  90446. */
  90447. attach(camera: ArcRotateCamera): void;
  90448. /**
  90449. * Detaches the behavior from its current arc rotate camera.
  90450. */
  90451. detach(): void;
  90452. private _animatables;
  90453. private _betaIsAnimating;
  90454. private _betaTransition;
  90455. private _radiusTransition;
  90456. private _vectorTransition;
  90457. /**
  90458. * Targets the given mesh and updates zoom level accordingly.
  90459. * @param mesh The mesh to target.
  90460. * @param radius Optional. If a cached radius position already exists, overrides default.
  90461. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90462. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90463. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90464. */
  90465. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90466. /**
  90467. * Targets the given mesh with its children and updates zoom level accordingly.
  90468. * @param mesh The mesh to target.
  90469. * @param radius Optional. If a cached radius position already exists, overrides default.
  90470. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90473. */
  90474. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90475. /**
  90476. * Targets the given meshes with their children and updates zoom level accordingly.
  90477. * @param meshes The mesh to target.
  90478. * @param radius Optional. If a cached radius position already exists, overrides default.
  90479. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90482. */
  90483. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90484. /**
  90485. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90486. * @param minimumWorld Determines the smaller position of the bounding box extend
  90487. * @param maximumWorld Determines the bigger position of the bounding box extend
  90488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90490. */
  90491. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90492. /**
  90493. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90494. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90495. * frustum width.
  90496. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90497. * to fully enclose the mesh in the viewing frustum.
  90498. */
  90499. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90500. /**
  90501. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90502. * is automatically returned to its default position (expected to be above ground plane).
  90503. */
  90504. private _maintainCameraAboveGround;
  90505. /**
  90506. * Returns the frustum slope based on the canvas ratio and camera FOV
  90507. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90508. */
  90509. private _getFrustumSlope;
  90510. /**
  90511. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90512. */
  90513. private _clearAnimationLocks;
  90514. /**
  90515. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90516. */
  90517. private _applyUserInteraction;
  90518. /**
  90519. * Stops and removes all animations that have been applied to the camera
  90520. */
  90521. stopAllAnimations(): void;
  90522. /**
  90523. * Gets a value indicating if the user is moving the camera
  90524. */
  90525. readonly isUserIsMoving: boolean;
  90526. /**
  90527. * The camera can move all the way towards the mesh.
  90528. */
  90529. static IgnoreBoundsSizeMode: number;
  90530. /**
  90531. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90532. */
  90533. static FitFrustumSidesMode: number;
  90534. }
  90535. }
  90536. declare module BABYLON {
  90537. /**
  90538. * Manage the pointers inputs to control an arc rotate camera.
  90539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90540. */
  90541. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90542. /**
  90543. * Defines the camera the input is attached to.
  90544. */
  90545. camera: ArcRotateCamera;
  90546. /**
  90547. * Defines the buttons associated with the input to handle camera move.
  90548. */
  90549. buttons: number[];
  90550. /**
  90551. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90552. */
  90553. angularSensibilityX: number;
  90554. /**
  90555. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90556. */
  90557. angularSensibilityY: number;
  90558. /**
  90559. * Defines the pointer pinch precision or how fast is the camera zooming.
  90560. */
  90561. pinchPrecision: number;
  90562. /**
  90563. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90564. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90565. */
  90566. pinchDeltaPercentage: number;
  90567. /**
  90568. * Defines the pointer panning sensibility or how fast is the camera moving.
  90569. */
  90570. panningSensibility: number;
  90571. /**
  90572. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90573. */
  90574. multiTouchPanning: boolean;
  90575. /**
  90576. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90577. */
  90578. multiTouchPanAndZoom: boolean;
  90579. /**
  90580. * Revers pinch action direction.
  90581. */
  90582. pinchInwards: boolean;
  90583. private _isPanClick;
  90584. private _pointerInput;
  90585. private _observer;
  90586. private _onMouseMove;
  90587. private _onGestureStart;
  90588. private _onGesture;
  90589. private _MSGestureHandler;
  90590. private _onLostFocus;
  90591. private _onContextMenu;
  90592. /**
  90593. * Attach the input controls to a specific dom element to get the input from.
  90594. * @param element Defines the element the controls should be listened from
  90595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90596. */
  90597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90598. /**
  90599. * Detach the current controls from the specified dom element.
  90600. * @param element Defines the element to stop listening the inputs from
  90601. */
  90602. detachControl(element: Nullable<HTMLElement>): void;
  90603. /**
  90604. * Gets the class name of the current intput.
  90605. * @returns the class name
  90606. */
  90607. getClassName(): string;
  90608. /**
  90609. * Get the friendly name associated with the input class.
  90610. * @returns the input friendly name
  90611. */
  90612. getSimpleName(): string;
  90613. }
  90614. }
  90615. declare module BABYLON {
  90616. /**
  90617. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90619. */
  90620. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90621. /**
  90622. * Defines the camera the input is attached to.
  90623. */
  90624. camera: ArcRotateCamera;
  90625. /**
  90626. * Defines the list of key codes associated with the up action (increase alpha)
  90627. */
  90628. keysUp: number[];
  90629. /**
  90630. * Defines the list of key codes associated with the down action (decrease alpha)
  90631. */
  90632. keysDown: number[];
  90633. /**
  90634. * Defines the list of key codes associated with the left action (increase beta)
  90635. */
  90636. keysLeft: number[];
  90637. /**
  90638. * Defines the list of key codes associated with the right action (decrease beta)
  90639. */
  90640. keysRight: number[];
  90641. /**
  90642. * Defines the list of key codes associated with the reset action.
  90643. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90644. */
  90645. keysReset: number[];
  90646. /**
  90647. * Defines the panning sensibility of the inputs.
  90648. * (How fast is the camera paning)
  90649. */
  90650. panningSensibility: number;
  90651. /**
  90652. * Defines the zooming sensibility of the inputs.
  90653. * (How fast is the camera zooming)
  90654. */
  90655. zoomingSensibility: number;
  90656. /**
  90657. * Defines wether maintaining the alt key down switch the movement mode from
  90658. * orientation to zoom.
  90659. */
  90660. useAltToZoom: boolean;
  90661. /**
  90662. * Rotation speed of the camera
  90663. */
  90664. angularSpeed: number;
  90665. private _keys;
  90666. private _ctrlPressed;
  90667. private _altPressed;
  90668. private _onCanvasBlurObserver;
  90669. private _onKeyboardObserver;
  90670. private _engine;
  90671. private _scene;
  90672. /**
  90673. * Attach the input controls to a specific dom element to get the input from.
  90674. * @param element Defines the element the controls should be listened from
  90675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90676. */
  90677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90678. /**
  90679. * Detach the current controls from the specified dom element.
  90680. * @param element Defines the element to stop listening the inputs from
  90681. */
  90682. detachControl(element: Nullable<HTMLElement>): void;
  90683. /**
  90684. * Update the current camera state depending on the inputs that have been used this frame.
  90685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90686. */
  90687. checkInputs(): void;
  90688. /**
  90689. * Gets the class name of the current intput.
  90690. * @returns the class name
  90691. */
  90692. getClassName(): string;
  90693. /**
  90694. * Get the friendly name associated with the input class.
  90695. * @returns the input friendly name
  90696. */
  90697. getSimpleName(): string;
  90698. }
  90699. }
  90700. declare module BABYLON {
  90701. /**
  90702. * Manage the mouse wheel inputs to control an arc rotate camera.
  90703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90704. */
  90705. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90706. /**
  90707. * Defines the camera the input is attached to.
  90708. */
  90709. camera: ArcRotateCamera;
  90710. /**
  90711. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90712. */
  90713. wheelPrecision: number;
  90714. /**
  90715. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90716. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90717. */
  90718. wheelDeltaPercentage: number;
  90719. private _wheel;
  90720. private _observer;
  90721. /**
  90722. * Attach the input controls to a specific dom element to get the input from.
  90723. * @param element Defines the element the controls should be listened from
  90724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90725. */
  90726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90727. /**
  90728. * Detach the current controls from the specified dom element.
  90729. * @param element Defines the element to stop listening the inputs from
  90730. */
  90731. detachControl(element: Nullable<HTMLElement>): void;
  90732. /**
  90733. * Gets the class name of the current intput.
  90734. * @returns the class name
  90735. */
  90736. getClassName(): string;
  90737. /**
  90738. * Get the friendly name associated with the input class.
  90739. * @returns the input friendly name
  90740. */
  90741. getSimpleName(): string;
  90742. }
  90743. }
  90744. declare module BABYLON {
  90745. /**
  90746. * Default Inputs manager for the ArcRotateCamera.
  90747. * It groups all the default supported inputs for ease of use.
  90748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90749. */
  90750. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90751. /**
  90752. * Instantiates a new ArcRotateCameraInputsManager.
  90753. * @param camera Defines the camera the inputs belong to
  90754. */
  90755. constructor(camera: ArcRotateCamera);
  90756. /**
  90757. * Add mouse wheel input support to the input manager.
  90758. * @returns the current input manager
  90759. */
  90760. addMouseWheel(): ArcRotateCameraInputsManager;
  90761. /**
  90762. * Add pointers input support to the input manager.
  90763. * @returns the current input manager
  90764. */
  90765. addPointers(): ArcRotateCameraInputsManager;
  90766. /**
  90767. * Add keyboard input support to the input manager.
  90768. * @returns the current input manager
  90769. */
  90770. addKeyboard(): ArcRotateCameraInputsManager;
  90771. }
  90772. }
  90773. declare module BABYLON {
  90774. /**
  90775. * This represents an orbital type of camera.
  90776. *
  90777. * 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.
  90778. * 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.
  90779. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90780. */
  90781. export class ArcRotateCamera extends TargetCamera {
  90782. /**
  90783. * Defines the rotation angle of the camera along the longitudinal axis.
  90784. */
  90785. alpha: number;
  90786. /**
  90787. * Defines the rotation angle of the camera along the latitudinal axis.
  90788. */
  90789. beta: number;
  90790. /**
  90791. * Defines the radius of the camera from it s target point.
  90792. */
  90793. radius: number;
  90794. protected _target: Vector3;
  90795. protected _targetHost: Nullable<AbstractMesh>;
  90796. /**
  90797. * Defines the target point of the camera.
  90798. * The camera looks towards it form the radius distance.
  90799. */
  90800. target: Vector3;
  90801. /**
  90802. * Current inertia value on the longitudinal axis.
  90803. * The bigger this number the longer it will take for the camera to stop.
  90804. */
  90805. inertialAlphaOffset: number;
  90806. /**
  90807. * Current inertia value on the latitudinal axis.
  90808. * The bigger this number the longer it will take for the camera to stop.
  90809. */
  90810. inertialBetaOffset: number;
  90811. /**
  90812. * Current inertia value on the radius axis.
  90813. * The bigger this number the longer it will take for the camera to stop.
  90814. */
  90815. inertialRadiusOffset: number;
  90816. /**
  90817. * Minimum allowed angle on the longitudinal axis.
  90818. * This can help limiting how the Camera is able to move in the scene.
  90819. */
  90820. lowerAlphaLimit: Nullable<number>;
  90821. /**
  90822. * Maximum allowed angle on the longitudinal axis.
  90823. * This can help limiting how the Camera is able to move in the scene.
  90824. */
  90825. upperAlphaLimit: Nullable<number>;
  90826. /**
  90827. * Minimum allowed angle on the latitudinal axis.
  90828. * This can help limiting how the Camera is able to move in the scene.
  90829. */
  90830. lowerBetaLimit: number;
  90831. /**
  90832. * Maximum allowed angle on the latitudinal axis.
  90833. * This can help limiting how the Camera is able to move in the scene.
  90834. */
  90835. upperBetaLimit: number;
  90836. /**
  90837. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90838. * This can help limiting how the Camera is able to move in the scene.
  90839. */
  90840. lowerRadiusLimit: Nullable<number>;
  90841. /**
  90842. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90843. * This can help limiting how the Camera is able to move in the scene.
  90844. */
  90845. upperRadiusLimit: Nullable<number>;
  90846. /**
  90847. * Defines the current inertia value used during panning of the camera along the X axis.
  90848. */
  90849. inertialPanningX: number;
  90850. /**
  90851. * Defines the current inertia value used during panning of the camera along the Y axis.
  90852. */
  90853. inertialPanningY: number;
  90854. /**
  90855. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90856. * Basically if your fingers moves away from more than this distance you will be considered
  90857. * in pinch mode.
  90858. */
  90859. pinchToPanMaxDistance: number;
  90860. /**
  90861. * Defines the maximum distance the camera can pan.
  90862. * This could help keeping the cammera always in your scene.
  90863. */
  90864. panningDistanceLimit: Nullable<number>;
  90865. /**
  90866. * Defines the target of the camera before paning.
  90867. */
  90868. panningOriginTarget: Vector3;
  90869. /**
  90870. * Defines the value of the inertia used during panning.
  90871. * 0 would mean stop inertia and one would mean no decelleration at all.
  90872. */
  90873. panningInertia: number;
  90874. /**
  90875. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90876. */
  90877. angularSensibilityX: number;
  90878. /**
  90879. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90880. */
  90881. angularSensibilityY: number;
  90882. /**
  90883. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90884. */
  90885. pinchPrecision: number;
  90886. /**
  90887. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90888. * It will be used instead of pinchDeltaPrecision if different from 0.
  90889. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90890. */
  90891. pinchDeltaPercentage: number;
  90892. /**
  90893. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90894. */
  90895. panningSensibility: number;
  90896. /**
  90897. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90898. */
  90899. keysUp: number[];
  90900. /**
  90901. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90902. */
  90903. keysDown: number[];
  90904. /**
  90905. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90906. */
  90907. keysLeft: number[];
  90908. /**
  90909. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90910. */
  90911. keysRight: number[];
  90912. /**
  90913. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90914. */
  90915. wheelPrecision: number;
  90916. /**
  90917. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90918. * It will be used instead of pinchDeltaPrecision if different from 0.
  90919. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90920. */
  90921. wheelDeltaPercentage: number;
  90922. /**
  90923. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90924. */
  90925. zoomOnFactor: number;
  90926. /**
  90927. * Defines a screen offset for the camera position.
  90928. */
  90929. targetScreenOffset: Vector2;
  90930. /**
  90931. * Allows the camera to be completely reversed.
  90932. * If false the camera can not arrive upside down.
  90933. */
  90934. allowUpsideDown: boolean;
  90935. /**
  90936. * Define if double tap/click is used to restore the previously saved state of the camera.
  90937. */
  90938. useInputToRestoreState: boolean;
  90939. /** @hidden */
  90940. _viewMatrix: Matrix;
  90941. /** @hidden */
  90942. _useCtrlForPanning: boolean;
  90943. /** @hidden */
  90944. _panningMouseButton: number;
  90945. /**
  90946. * Defines the input associated to the camera.
  90947. */
  90948. inputs: ArcRotateCameraInputsManager;
  90949. /** @hidden */
  90950. _reset: () => void;
  90951. /**
  90952. * Defines the allowed panning axis.
  90953. */
  90954. panningAxis: Vector3;
  90955. protected _localDirection: Vector3;
  90956. protected _transformedDirection: Vector3;
  90957. private _bouncingBehavior;
  90958. /**
  90959. * Gets the bouncing behavior of the camera if it has been enabled.
  90960. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90961. */
  90962. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90963. /**
  90964. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90966. */
  90967. useBouncingBehavior: boolean;
  90968. private _framingBehavior;
  90969. /**
  90970. * Gets the framing behavior of the camera if it has been enabled.
  90971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90972. */
  90973. readonly framingBehavior: Nullable<FramingBehavior>;
  90974. /**
  90975. * Defines if the framing behavior of the camera is enabled on the camera.
  90976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90977. */
  90978. useFramingBehavior: boolean;
  90979. private _autoRotationBehavior;
  90980. /**
  90981. * Gets the auto rotation behavior of the camera if it has been enabled.
  90982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90983. */
  90984. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90985. /**
  90986. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90988. */
  90989. useAutoRotationBehavior: boolean;
  90990. /**
  90991. * Observable triggered when the mesh target has been changed on the camera.
  90992. */
  90993. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90994. /**
  90995. * Event raised when the camera is colliding with a mesh.
  90996. */
  90997. onCollide: (collidedMesh: AbstractMesh) => void;
  90998. /**
  90999. * Defines whether the camera should check collision with the objects oh the scene.
  91000. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91001. */
  91002. checkCollisions: boolean;
  91003. /**
  91004. * Defines the collision radius of the camera.
  91005. * This simulates a sphere around the camera.
  91006. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91007. */
  91008. collisionRadius: Vector3;
  91009. protected _collider: Collider;
  91010. protected _previousPosition: Vector3;
  91011. protected _collisionVelocity: Vector3;
  91012. protected _newPosition: Vector3;
  91013. protected _previousAlpha: number;
  91014. protected _previousBeta: number;
  91015. protected _previousRadius: number;
  91016. protected _collisionTriggered: boolean;
  91017. protected _targetBoundingCenter: Nullable<Vector3>;
  91018. private _computationVector;
  91019. private _tempAxisVector;
  91020. private _tempAxisRotationMatrix;
  91021. /**
  91022. * Instantiates a new ArcRotateCamera in a given scene
  91023. * @param name Defines the name of the camera
  91024. * @param alpha Defines the camera rotation along the logitudinal axis
  91025. * @param beta Defines the camera rotation along the latitudinal axis
  91026. * @param radius Defines the camera distance from its target
  91027. * @param target Defines the camera target
  91028. * @param scene Defines the scene the camera belongs to
  91029. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91030. */
  91031. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91032. /** @hidden */
  91033. _initCache(): void;
  91034. /** @hidden */
  91035. _updateCache(ignoreParentClass?: boolean): void;
  91036. protected _getTargetPosition(): Vector3;
  91037. private _storedAlpha;
  91038. private _storedBeta;
  91039. private _storedRadius;
  91040. private _storedTarget;
  91041. /**
  91042. * Stores the current state of the camera (alpha, beta, radius and target)
  91043. * @returns the camera itself
  91044. */
  91045. storeState(): Camera;
  91046. /**
  91047. * @hidden
  91048. * Restored camera state. You must call storeState() first
  91049. */
  91050. _restoreStateValues(): boolean;
  91051. /** @hidden */
  91052. _isSynchronizedViewMatrix(): boolean;
  91053. /**
  91054. * Attached controls to the current camera.
  91055. * @param element Defines the element the controls should be listened from
  91056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91057. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91058. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91059. */
  91060. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91061. /**
  91062. * Detach the current controls from the camera.
  91063. * The camera will stop reacting to inputs.
  91064. * @param element Defines the element to stop listening the inputs from
  91065. */
  91066. detachControl(element: HTMLElement): void;
  91067. /** @hidden */
  91068. _checkInputs(): void;
  91069. protected _checkLimits(): void;
  91070. /**
  91071. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  91072. */
  91073. rebuildAnglesAndRadius(): void;
  91074. /**
  91075. * Use a position to define the current camera related information like aplha, beta and radius
  91076. * @param position Defines the position to set the camera at
  91077. */
  91078. setPosition(position: Vector3): void;
  91079. /**
  91080. * Defines the target the camera should look at.
  91081. * This will automatically adapt alpha beta and radius to fit within the new target.
  91082. * @param target Defines the new target as a Vector or a mesh
  91083. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91084. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91085. */
  91086. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91087. /** @hidden */
  91088. _getViewMatrix(): Matrix;
  91089. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91090. /**
  91091. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91092. * @param meshes Defines the mesh to zoom on
  91093. * @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)
  91094. */
  91095. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91096. /**
  91097. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91098. * The target will be changed but the radius
  91099. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91100. * @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)
  91101. */
  91102. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91103. min: Vector3;
  91104. max: Vector3;
  91105. distance: number;
  91106. }, doNotUpdateMaxZ?: boolean): void;
  91107. /**
  91108. * @override
  91109. * Override Camera.createRigCamera
  91110. */
  91111. createRigCamera(name: string, cameraIndex: number): Camera;
  91112. /**
  91113. * @hidden
  91114. * @override
  91115. * Override Camera._updateRigCameras
  91116. */
  91117. _updateRigCameras(): void;
  91118. /**
  91119. * Destroy the camera and release the current resources hold by it.
  91120. */
  91121. dispose(): void;
  91122. /**
  91123. * Gets the current object class name.
  91124. * @return the class name
  91125. */
  91126. getClassName(): string;
  91127. }
  91128. }
  91129. declare module BABYLON {
  91130. /**
  91131. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91133. */
  91134. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91135. /**
  91136. * Gets the name of the behavior.
  91137. */
  91138. readonly name: string;
  91139. private _zoomStopsAnimation;
  91140. private _idleRotationSpeed;
  91141. private _idleRotationWaitTime;
  91142. private _idleRotationSpinupTime;
  91143. /**
  91144. * Sets the flag that indicates if user zooming should stop animation.
  91145. */
  91146. /**
  91147. * Gets the flag that indicates if user zooming should stop animation.
  91148. */
  91149. zoomStopsAnimation: boolean;
  91150. /**
  91151. * Sets the default speed at which the camera rotates around the model.
  91152. */
  91153. /**
  91154. * Gets the default speed at which the camera rotates around the model.
  91155. */
  91156. idleRotationSpeed: number;
  91157. /**
  91158. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91159. */
  91160. /**
  91161. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91162. */
  91163. idleRotationWaitTime: number;
  91164. /**
  91165. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91166. */
  91167. /**
  91168. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91169. */
  91170. idleRotationSpinupTime: number;
  91171. /**
  91172. * Gets a value indicating if the camera is currently rotating because of this behavior
  91173. */
  91174. readonly rotationInProgress: boolean;
  91175. private _onPrePointerObservableObserver;
  91176. private _onAfterCheckInputsObserver;
  91177. private _attachedCamera;
  91178. private _isPointerDown;
  91179. private _lastFrameTime;
  91180. private _lastInteractionTime;
  91181. private _cameraRotationSpeed;
  91182. /**
  91183. * Initializes the behavior.
  91184. */
  91185. init(): void;
  91186. /**
  91187. * Attaches the behavior to its arc rotate camera.
  91188. * @param camera Defines the camera to attach the behavior to
  91189. */
  91190. attach(camera: ArcRotateCamera): void;
  91191. /**
  91192. * Detaches the behavior from its current arc rotate camera.
  91193. */
  91194. detach(): void;
  91195. /**
  91196. * Returns true if user is scrolling.
  91197. * @return true if user is scrolling.
  91198. */
  91199. private _userIsZooming;
  91200. private _lastFrameRadius;
  91201. private _shouldAnimationStopForInteraction;
  91202. /**
  91203. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91204. */
  91205. private _applyUserInteraction;
  91206. private _userIsMoving;
  91207. }
  91208. }
  91209. declare module BABYLON {
  91210. /**
  91211. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  91212. */
  91213. export class AttachToBoxBehavior implements Behavior<Mesh> {
  91214. private ui;
  91215. /**
  91216. * The name of the behavior
  91217. */
  91218. name: string;
  91219. /**
  91220. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  91221. */
  91222. distanceAwayFromFace: number;
  91223. /**
  91224. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  91225. */
  91226. distanceAwayFromBottomOfFace: number;
  91227. private _faceVectors;
  91228. private _target;
  91229. private _scene;
  91230. private _onRenderObserver;
  91231. private _tmpMatrix;
  91232. private _tmpVector;
  91233. /**
  91234. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  91235. * @param ui The transform node that should be attched to the mesh
  91236. */
  91237. constructor(ui: TransformNode);
  91238. /**
  91239. * Initializes the behavior
  91240. */
  91241. init(): void;
  91242. private _closestFace;
  91243. private _zeroVector;
  91244. private _lookAtTmpMatrix;
  91245. private _lookAtToRef;
  91246. /**
  91247. * Attaches the AttachToBoxBehavior to the passed in mesh
  91248. * @param target The mesh that the specified node will be attached to
  91249. */
  91250. attach(target: Mesh): void;
  91251. /**
  91252. * Detaches the behavior from the mesh
  91253. */
  91254. detach(): void;
  91255. }
  91256. }
  91257. declare module BABYLON {
  91258. /**
  91259. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  91260. */
  91261. export class FadeInOutBehavior implements Behavior<Mesh> {
  91262. /**
  91263. * Time in milliseconds to delay before fading in (Default: 0)
  91264. */
  91265. delay: number;
  91266. /**
  91267. * Time in milliseconds for the mesh to fade in (Default: 300)
  91268. */
  91269. fadeInTime: number;
  91270. private _millisecondsPerFrame;
  91271. private _hovered;
  91272. private _hoverValue;
  91273. private _ownerNode;
  91274. /**
  91275. * Instatiates the FadeInOutBehavior
  91276. */
  91277. constructor();
  91278. /**
  91279. * The name of the behavior
  91280. */
  91281. readonly name: string;
  91282. /**
  91283. * Initializes the behavior
  91284. */
  91285. init(): void;
  91286. /**
  91287. * Attaches the fade behavior on the passed in mesh
  91288. * @param ownerNode The mesh that will be faded in/out once attached
  91289. */
  91290. attach(ownerNode: Mesh): void;
  91291. /**
  91292. * Detaches the behavior from the mesh
  91293. */
  91294. detach(): void;
  91295. /**
  91296. * Triggers the mesh to begin fading in or out
  91297. * @param value if the object should fade in or out (true to fade in)
  91298. */
  91299. fadeIn(value: boolean): void;
  91300. private _update;
  91301. private _setAllVisibility;
  91302. }
  91303. }
  91304. declare module BABYLON {
  91305. /**
  91306. * Class containing a set of static utilities functions for managing Pivots
  91307. * @hidden
  91308. */
  91309. export class PivotTools {
  91310. private static _PivotCached;
  91311. private static _OldPivotPoint;
  91312. private static _PivotTranslation;
  91313. private static _PivotTmpVector;
  91314. /** @hidden */
  91315. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  91316. /** @hidden */
  91317. static _RestorePivotPoint(mesh: AbstractMesh): void;
  91318. }
  91319. }
  91320. declare module BABYLON {
  91321. /**
  91322. * Class containing static functions to help procedurally build meshes
  91323. */
  91324. export class PlaneBuilder {
  91325. /**
  91326. * Creates a plane mesh
  91327. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91328. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91329. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91333. * @param name defines the name of the mesh
  91334. * @param options defines the options used to create the mesh
  91335. * @param scene defines the hosting scene
  91336. * @returns the plane mesh
  91337. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91338. */
  91339. static CreatePlane(name: string, options: {
  91340. size?: number;
  91341. width?: number;
  91342. height?: number;
  91343. sideOrientation?: number;
  91344. frontUVs?: Vector4;
  91345. backUVs?: Vector4;
  91346. updatable?: boolean;
  91347. sourcePlane?: Plane;
  91348. }, scene: Scene): Mesh;
  91349. }
  91350. }
  91351. declare module BABYLON {
  91352. /**
  91353. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91354. */
  91355. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91356. private static _AnyMouseID;
  91357. private _attachedNode;
  91358. private _dragPlane;
  91359. private _scene;
  91360. private _pointerObserver;
  91361. private _beforeRenderObserver;
  91362. private static _planeScene;
  91363. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  91364. /**
  91365. * 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)
  91366. */
  91367. maxDragAngle: number;
  91368. /**
  91369. * @hidden
  91370. */
  91371. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91372. /**
  91373. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91374. */
  91375. currentDraggingPointerID: number;
  91376. /**
  91377. * The last position where the pointer hit the drag plane in world space
  91378. */
  91379. lastDragPosition: Vector3;
  91380. /**
  91381. * If the behavior is currently in a dragging state
  91382. */
  91383. dragging: boolean;
  91384. /**
  91385. * 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)
  91386. */
  91387. dragDeltaRatio: number;
  91388. /**
  91389. * If the drag plane orientation should be updated during the dragging (Default: true)
  91390. */
  91391. updateDragPlane: boolean;
  91392. private _debugMode;
  91393. private _moving;
  91394. /**
  91395. * Fires each time the attached mesh is dragged with the pointer
  91396. * * delta between last drag position and current drag position in world space
  91397. * * dragDistance along the drag axis
  91398. * * dragPlaneNormal normal of the current drag plane used during the drag
  91399. * * dragPlanePoint in world space where the drag intersects the drag plane
  91400. */
  91401. onDragObservable: Observable<{
  91402. delta: Vector3;
  91403. dragPlanePoint: Vector3;
  91404. dragPlaneNormal: Vector3;
  91405. dragDistance: number;
  91406. pointerId: number;
  91407. }>;
  91408. /**
  91409. * Fires each time a drag begins (eg. mouse down on mesh)
  91410. */
  91411. onDragStartObservable: Observable<{
  91412. dragPlanePoint: Vector3;
  91413. pointerId: number;
  91414. }>;
  91415. /**
  91416. * Fires each time a drag ends (eg. mouse release after drag)
  91417. */
  91418. onDragEndObservable: Observable<{
  91419. dragPlanePoint: Vector3;
  91420. pointerId: number;
  91421. }>;
  91422. /**
  91423. * If the attached mesh should be moved when dragged
  91424. */
  91425. moveAttached: boolean;
  91426. /**
  91427. * If the drag behavior will react to drag events (Default: true)
  91428. */
  91429. enabled: boolean;
  91430. /**
  91431. * If camera controls should be detached during the drag
  91432. */
  91433. detachCameraControls: boolean;
  91434. /**
  91435. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91436. */
  91437. useObjectOrienationForDragging: boolean;
  91438. private _options;
  91439. /**
  91440. * Creates a pointer drag behavior that can be attached to a mesh
  91441. * @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)
  91442. */
  91443. constructor(options?: {
  91444. dragAxis?: Vector3;
  91445. dragPlaneNormal?: Vector3;
  91446. });
  91447. /**
  91448. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91449. */
  91450. validateDrag: (targetPosition: Vector3) => boolean;
  91451. /**
  91452. * The name of the behavior
  91453. */
  91454. readonly name: string;
  91455. /**
  91456. * Initializes the behavior
  91457. */
  91458. init(): void;
  91459. private _tmpVector;
  91460. private _alternatePickedPoint;
  91461. private _worldDragAxis;
  91462. private _targetPosition;
  91463. private _attachedElement;
  91464. /**
  91465. * Attaches the drag behavior the passed in mesh
  91466. * @param ownerNode The mesh that will be dragged around once attached
  91467. */
  91468. attach(ownerNode: AbstractMesh): void;
  91469. /**
  91470. * Force relase the drag action by code.
  91471. */
  91472. releaseDrag(): void;
  91473. private _startDragRay;
  91474. private _lastPointerRay;
  91475. /**
  91476. * Simulates the start of a pointer drag event on the behavior
  91477. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91478. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91479. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91480. */
  91481. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91482. private _startDrag;
  91483. private _dragDelta;
  91484. private _moveDrag;
  91485. private _pickWithRayOnDragPlane;
  91486. private _pointA;
  91487. private _pointB;
  91488. private _pointC;
  91489. private _lineA;
  91490. private _lineB;
  91491. private _localAxis;
  91492. private _lookAt;
  91493. private _updateDragPlanePosition;
  91494. /**
  91495. * Detaches the behavior from the mesh
  91496. */
  91497. detach(): void;
  91498. }
  91499. }
  91500. declare module BABYLON {
  91501. /**
  91502. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91503. */
  91504. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91505. private _dragBehaviorA;
  91506. private _dragBehaviorB;
  91507. private _startDistance;
  91508. private _initialScale;
  91509. private _targetScale;
  91510. private _ownerNode;
  91511. private _sceneRenderObserver;
  91512. /**
  91513. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91514. */
  91515. constructor();
  91516. /**
  91517. * The name of the behavior
  91518. */
  91519. readonly name: string;
  91520. /**
  91521. * Initializes the behavior
  91522. */
  91523. init(): void;
  91524. private _getCurrentDistance;
  91525. /**
  91526. * Attaches the scale behavior the passed in mesh
  91527. * @param ownerNode The mesh that will be scaled around once attached
  91528. */
  91529. attach(ownerNode: Mesh): void;
  91530. /**
  91531. * Detaches the behavior from the mesh
  91532. */
  91533. detach(): void;
  91534. }
  91535. }
  91536. declare module BABYLON {
  91537. /**
  91538. * 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
  91539. */
  91540. export class SixDofDragBehavior implements Behavior<Mesh> {
  91541. private static _virtualScene;
  91542. private _ownerNode;
  91543. private _sceneRenderObserver;
  91544. private _scene;
  91545. private _targetPosition;
  91546. private _virtualOriginMesh;
  91547. private _virtualDragMesh;
  91548. private _pointerObserver;
  91549. private _moving;
  91550. private _startingOrientation;
  91551. /**
  91552. * 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)
  91553. */
  91554. private zDragFactor;
  91555. /**
  91556. * If the object should rotate to face the drag origin
  91557. */
  91558. rotateDraggedObject: boolean;
  91559. /**
  91560. * If the behavior is currently in a dragging state
  91561. */
  91562. dragging: boolean;
  91563. /**
  91564. * 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)
  91565. */
  91566. dragDeltaRatio: number;
  91567. /**
  91568. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91569. */
  91570. currentDraggingPointerID: number;
  91571. /**
  91572. * If camera controls should be detached during the drag
  91573. */
  91574. detachCameraControls: boolean;
  91575. /**
  91576. * Fires each time a drag starts
  91577. */
  91578. onDragStartObservable: Observable<{}>;
  91579. /**
  91580. * Fires each time a drag ends (eg. mouse release after drag)
  91581. */
  91582. onDragEndObservable: Observable<{}>;
  91583. /**
  91584. * 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
  91585. */
  91586. constructor();
  91587. /**
  91588. * The name of the behavior
  91589. */
  91590. readonly name: string;
  91591. /**
  91592. * Initializes the behavior
  91593. */
  91594. init(): void;
  91595. /**
  91596. * Attaches the scale behavior the passed in mesh
  91597. * @param ownerNode The mesh that will be scaled around once attached
  91598. */
  91599. attach(ownerNode: Mesh): void;
  91600. /**
  91601. * Detaches the behavior from the mesh
  91602. */
  91603. detach(): void;
  91604. }
  91605. }
  91606. declare module BABYLON {
  91607. /**
  91608. * Class used to apply inverse kinematics to bones
  91609. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91610. */
  91611. export class BoneIKController {
  91612. private static _tmpVecs;
  91613. private static _tmpQuat;
  91614. private static _tmpMats;
  91615. /**
  91616. * Gets or sets the target mesh
  91617. */
  91618. targetMesh: AbstractMesh;
  91619. /** Gets or sets the mesh used as pole */
  91620. poleTargetMesh: AbstractMesh;
  91621. /**
  91622. * Gets or sets the bone used as pole
  91623. */
  91624. poleTargetBone: Nullable<Bone>;
  91625. /**
  91626. * Gets or sets the target position
  91627. */
  91628. targetPosition: Vector3;
  91629. /**
  91630. * Gets or sets the pole target position
  91631. */
  91632. poleTargetPosition: Vector3;
  91633. /**
  91634. * Gets or sets the pole target local offset
  91635. */
  91636. poleTargetLocalOffset: Vector3;
  91637. /**
  91638. * Gets or sets the pole angle
  91639. */
  91640. poleAngle: number;
  91641. /**
  91642. * Gets or sets the mesh associated with the controller
  91643. */
  91644. mesh: AbstractMesh;
  91645. /**
  91646. * 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)
  91647. */
  91648. slerpAmount: number;
  91649. private _bone1Quat;
  91650. private _bone1Mat;
  91651. private _bone2Ang;
  91652. private _bone1;
  91653. private _bone2;
  91654. private _bone1Length;
  91655. private _bone2Length;
  91656. private _maxAngle;
  91657. private _maxReach;
  91658. private _rightHandedSystem;
  91659. private _bendAxis;
  91660. private _slerping;
  91661. private _adjustRoll;
  91662. /**
  91663. * Gets or sets maximum allowed angle
  91664. */
  91665. maxAngle: number;
  91666. /**
  91667. * Creates a new BoneIKController
  91668. * @param mesh defines the mesh to control
  91669. * @param bone defines the bone to control
  91670. * @param options defines options to set up the controller
  91671. */
  91672. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91673. targetMesh?: AbstractMesh;
  91674. poleTargetMesh?: AbstractMesh;
  91675. poleTargetBone?: Bone;
  91676. poleTargetLocalOffset?: Vector3;
  91677. poleAngle?: number;
  91678. bendAxis?: Vector3;
  91679. maxAngle?: number;
  91680. slerpAmount?: number;
  91681. });
  91682. private _setMaxAngle;
  91683. /**
  91684. * Force the controller to update the bones
  91685. */
  91686. update(): void;
  91687. }
  91688. }
  91689. declare module BABYLON {
  91690. /**
  91691. * Class used to make a bone look toward a point in space
  91692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91693. */
  91694. export class BoneLookController {
  91695. private static _tmpVecs;
  91696. private static _tmpQuat;
  91697. private static _tmpMats;
  91698. /**
  91699. * The target Vector3 that the bone will look at
  91700. */
  91701. target: Vector3;
  91702. /**
  91703. * The mesh that the bone is attached to
  91704. */
  91705. mesh: AbstractMesh;
  91706. /**
  91707. * The bone that will be looking to the target
  91708. */
  91709. bone: Bone;
  91710. /**
  91711. * The up axis of the coordinate system that is used when the bone is rotated
  91712. */
  91713. upAxis: Vector3;
  91714. /**
  91715. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91716. */
  91717. upAxisSpace: Space;
  91718. /**
  91719. * Used to make an adjustment to the yaw of the bone
  91720. */
  91721. adjustYaw: number;
  91722. /**
  91723. * Used to make an adjustment to the pitch of the bone
  91724. */
  91725. adjustPitch: number;
  91726. /**
  91727. * Used to make an adjustment to the roll of the bone
  91728. */
  91729. adjustRoll: number;
  91730. /**
  91731. * 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)
  91732. */
  91733. slerpAmount: number;
  91734. private _minYaw;
  91735. private _maxYaw;
  91736. private _minPitch;
  91737. private _maxPitch;
  91738. private _minYawSin;
  91739. private _minYawCos;
  91740. private _maxYawSin;
  91741. private _maxYawCos;
  91742. private _midYawConstraint;
  91743. private _minPitchTan;
  91744. private _maxPitchTan;
  91745. private _boneQuat;
  91746. private _slerping;
  91747. private _transformYawPitch;
  91748. private _transformYawPitchInv;
  91749. private _firstFrameSkipped;
  91750. private _yawRange;
  91751. private _fowardAxis;
  91752. /**
  91753. * Gets or sets the minimum yaw angle that the bone can look to
  91754. */
  91755. minYaw: number;
  91756. /**
  91757. * Gets or sets the maximum yaw angle that the bone can look to
  91758. */
  91759. maxYaw: number;
  91760. /**
  91761. * Gets or sets the minimum pitch angle that the bone can look to
  91762. */
  91763. minPitch: number;
  91764. /**
  91765. * Gets or sets the maximum pitch angle that the bone can look to
  91766. */
  91767. maxPitch: number;
  91768. /**
  91769. * Create a BoneLookController
  91770. * @param mesh the mesh that the bone belongs to
  91771. * @param bone the bone that will be looking to the target
  91772. * @param target the target Vector3 to look at
  91773. * @param options optional settings:
  91774. * * maxYaw: the maximum angle the bone will yaw to
  91775. * * minYaw: the minimum angle the bone will yaw to
  91776. * * maxPitch: the maximum angle the bone will pitch to
  91777. * * minPitch: the minimum angle the bone will yaw to
  91778. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91779. * * upAxis: the up axis of the coordinate system
  91780. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91781. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91782. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91783. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91784. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91785. * * adjustRoll: used to make an adjustment to the roll of the bone
  91786. **/
  91787. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91788. maxYaw?: number;
  91789. minYaw?: number;
  91790. maxPitch?: number;
  91791. minPitch?: number;
  91792. slerpAmount?: number;
  91793. upAxis?: Vector3;
  91794. upAxisSpace?: Space;
  91795. yawAxis?: Vector3;
  91796. pitchAxis?: Vector3;
  91797. adjustYaw?: number;
  91798. adjustPitch?: number;
  91799. adjustRoll?: number;
  91800. });
  91801. /**
  91802. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91803. */
  91804. update(): void;
  91805. private _getAngleDiff;
  91806. private _getAngleBetween;
  91807. private _isAngleBetween;
  91808. }
  91809. }
  91810. declare module BABYLON {
  91811. /**
  91812. * Manage the gamepad inputs to control an arc rotate camera.
  91813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91814. */
  91815. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91816. /**
  91817. * Defines the camera the input is attached to.
  91818. */
  91819. camera: ArcRotateCamera;
  91820. /**
  91821. * Defines the gamepad the input is gathering event from.
  91822. */
  91823. gamepad: Nullable<Gamepad>;
  91824. /**
  91825. * Defines the gamepad rotation sensiblity.
  91826. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91827. */
  91828. gamepadRotationSensibility: number;
  91829. /**
  91830. * Defines the gamepad move sensiblity.
  91831. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91832. */
  91833. gamepadMoveSensibility: number;
  91834. private _onGamepadConnectedObserver;
  91835. private _onGamepadDisconnectedObserver;
  91836. /**
  91837. * Attach the input controls to a specific dom element to get the input from.
  91838. * @param element Defines the element the controls should be listened from
  91839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91840. */
  91841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91842. /**
  91843. * Detach the current controls from the specified dom element.
  91844. * @param element Defines the element to stop listening the inputs from
  91845. */
  91846. detachControl(element: Nullable<HTMLElement>): void;
  91847. /**
  91848. * Update the current camera state depending on the inputs that have been used this frame.
  91849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91850. */
  91851. checkInputs(): void;
  91852. /**
  91853. * Gets the class name of the current intput.
  91854. * @returns the class name
  91855. */
  91856. getClassName(): string;
  91857. /**
  91858. * Get the friendly name associated with the input class.
  91859. * @returns the input friendly name
  91860. */
  91861. getSimpleName(): string;
  91862. }
  91863. }
  91864. declare module BABYLON {
  91865. interface ArcRotateCameraInputsManager {
  91866. /**
  91867. * Add orientation input support to the input manager.
  91868. * @returns the current input manager
  91869. */
  91870. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91871. }
  91872. /**
  91873. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91875. */
  91876. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91877. /**
  91878. * Defines the camera the input is attached to.
  91879. */
  91880. camera: ArcRotateCamera;
  91881. /**
  91882. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91883. */
  91884. alphaCorrection: number;
  91885. /**
  91886. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91887. */
  91888. gammaCorrection: number;
  91889. private _alpha;
  91890. private _gamma;
  91891. private _dirty;
  91892. private _deviceOrientationHandler;
  91893. /**
  91894. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91895. */
  91896. constructor();
  91897. /**
  91898. * Attach the input controls to a specific dom element to get the input from.
  91899. * @param element Defines the element the controls should be listened from
  91900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91901. */
  91902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91903. /** @hidden */
  91904. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91905. /**
  91906. * Update the current camera state depending on the inputs that have been used this frame.
  91907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91908. */
  91909. checkInputs(): void;
  91910. /**
  91911. * Detach the current controls from the specified dom element.
  91912. * @param element Defines the element to stop listening the inputs from
  91913. */
  91914. detachControl(element: Nullable<HTMLElement>): void;
  91915. /**
  91916. * Gets the class name of the current intput.
  91917. * @returns the class name
  91918. */
  91919. getClassName(): string;
  91920. /**
  91921. * Get the friendly name associated with the input class.
  91922. * @returns the input friendly name
  91923. */
  91924. getSimpleName(): string;
  91925. }
  91926. }
  91927. declare module BABYLON {
  91928. /**
  91929. * Listen to mouse events to control the camera.
  91930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91931. */
  91932. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91933. /**
  91934. * Defines the camera the input is attached to.
  91935. */
  91936. camera: FlyCamera;
  91937. /**
  91938. * Defines if touch is enabled. (Default is true.)
  91939. */
  91940. touchEnabled: boolean;
  91941. /**
  91942. * Defines the buttons associated with the input to handle camera rotation.
  91943. */
  91944. buttons: number[];
  91945. /**
  91946. * Assign buttons for Yaw control.
  91947. */
  91948. buttonsYaw: number[];
  91949. /**
  91950. * Assign buttons for Pitch control.
  91951. */
  91952. buttonsPitch: number[];
  91953. /**
  91954. * Assign buttons for Roll control.
  91955. */
  91956. buttonsRoll: number[];
  91957. /**
  91958. * Detect if any button is being pressed while mouse is moved.
  91959. * -1 = Mouse locked.
  91960. * 0 = Left button.
  91961. * 1 = Middle Button.
  91962. * 2 = Right Button.
  91963. */
  91964. activeButton: number;
  91965. /**
  91966. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91967. * Higher values reduce its sensitivity.
  91968. */
  91969. angularSensibility: number;
  91970. private _mousemoveCallback;
  91971. private _observer;
  91972. private _rollObserver;
  91973. private previousPosition;
  91974. private noPreventDefault;
  91975. private element;
  91976. /**
  91977. * Listen to mouse events to control the camera.
  91978. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91980. */
  91981. constructor(touchEnabled?: boolean);
  91982. /**
  91983. * Attach the mouse control to the HTML DOM element.
  91984. * @param element Defines the element that listens to the input events.
  91985. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91986. */
  91987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91988. /**
  91989. * Detach the current controls from the specified dom element.
  91990. * @param element Defines the element to stop listening the inputs from
  91991. */
  91992. detachControl(element: Nullable<HTMLElement>): void;
  91993. /**
  91994. * Gets the class name of the current input.
  91995. * @returns the class name.
  91996. */
  91997. getClassName(): string;
  91998. /**
  91999. * Get the friendly name associated with the input class.
  92000. * @returns the input's friendly name.
  92001. */
  92002. getSimpleName(): string;
  92003. private _pointerInput;
  92004. private _onMouseMove;
  92005. /**
  92006. * Rotate camera by mouse offset.
  92007. */
  92008. private rotateCamera;
  92009. }
  92010. }
  92011. declare module BABYLON {
  92012. /**
  92013. * Default Inputs manager for the FlyCamera.
  92014. * It groups all the default supported inputs for ease of use.
  92015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92016. */
  92017. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92018. /**
  92019. * Instantiates a new FlyCameraInputsManager.
  92020. * @param camera Defines the camera the inputs belong to.
  92021. */
  92022. constructor(camera: FlyCamera);
  92023. /**
  92024. * Add keyboard input support to the input manager.
  92025. * @returns the new FlyCameraKeyboardMoveInput().
  92026. */
  92027. addKeyboard(): FlyCameraInputsManager;
  92028. /**
  92029. * Add mouse input support to the input manager.
  92030. * @param touchEnabled Enable touch screen support.
  92031. * @returns the new FlyCameraMouseInput().
  92032. */
  92033. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92034. }
  92035. }
  92036. declare module BABYLON {
  92037. /**
  92038. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92039. * such as in a 3D Space Shooter or a Flight Simulator.
  92040. */
  92041. export class FlyCamera extends TargetCamera {
  92042. /**
  92043. * Define the collision ellipsoid of the camera.
  92044. * This is helpful for simulating a camera body, like a player's body.
  92045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92046. */
  92047. ellipsoid: Vector3;
  92048. /**
  92049. * Define an offset for the position of the ellipsoid around the camera.
  92050. * This can be helpful if the camera is attached away from the player's body center,
  92051. * such as at its head.
  92052. */
  92053. ellipsoidOffset: Vector3;
  92054. /**
  92055. * Enable or disable collisions of the camera with the rest of the scene objects.
  92056. */
  92057. checkCollisions: boolean;
  92058. /**
  92059. * Enable or disable gravity on the camera.
  92060. */
  92061. applyGravity: boolean;
  92062. /**
  92063. * Define the current direction the camera is moving to.
  92064. */
  92065. cameraDirection: Vector3;
  92066. /**
  92067. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92068. * This overrides and empties cameraRotation.
  92069. */
  92070. rotationQuaternion: Quaternion;
  92071. /**
  92072. * Track Roll to maintain the wanted Rolling when looking around.
  92073. */
  92074. _trackRoll: number;
  92075. /**
  92076. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92077. */
  92078. rollCorrect: number;
  92079. /**
  92080. * Mimic a banked turn, Rolling the camera when Yawing.
  92081. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92082. */
  92083. bankedTurn: boolean;
  92084. /**
  92085. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92086. */
  92087. bankedTurnLimit: number;
  92088. /**
  92089. * Value of 0 disables the banked Roll.
  92090. * Value of 1 is equal to the Yaw angle in radians.
  92091. */
  92092. bankedTurnMultiplier: number;
  92093. /**
  92094. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92095. */
  92096. inputs: FlyCameraInputsManager;
  92097. /**
  92098. * Gets the input sensibility for mouse input.
  92099. * Higher values reduce sensitivity.
  92100. */
  92101. /**
  92102. * Sets the input sensibility for a mouse input.
  92103. * Higher values reduce sensitivity.
  92104. */
  92105. angularSensibility: number;
  92106. /**
  92107. * Get the keys for camera movement forward.
  92108. */
  92109. /**
  92110. * Set the keys for camera movement forward.
  92111. */
  92112. keysForward: number[];
  92113. /**
  92114. * Get the keys for camera movement backward.
  92115. */
  92116. keysBackward: number[];
  92117. /**
  92118. * Get the keys for camera movement up.
  92119. */
  92120. /**
  92121. * Set the keys for camera movement up.
  92122. */
  92123. keysUp: number[];
  92124. /**
  92125. * Get the keys for camera movement down.
  92126. */
  92127. /**
  92128. * Set the keys for camera movement down.
  92129. */
  92130. keysDown: number[];
  92131. /**
  92132. * Get the keys for camera movement left.
  92133. */
  92134. /**
  92135. * Set the keys for camera movement left.
  92136. */
  92137. keysLeft: number[];
  92138. /**
  92139. * Set the keys for camera movement right.
  92140. */
  92141. /**
  92142. * Set the keys for camera movement right.
  92143. */
  92144. keysRight: number[];
  92145. /**
  92146. * Event raised when the camera collides with a mesh in the scene.
  92147. */
  92148. onCollide: (collidedMesh: AbstractMesh) => void;
  92149. private _collider;
  92150. private _needMoveForGravity;
  92151. private _oldPosition;
  92152. private _diffPosition;
  92153. private _newPosition;
  92154. /** @hidden */
  92155. _localDirection: Vector3;
  92156. /** @hidden */
  92157. _transformedDirection: Vector3;
  92158. /**
  92159. * Instantiates a FlyCamera.
  92160. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92161. * such as in a 3D Space Shooter or a Flight Simulator.
  92162. * @param name Define the name of the camera in the scene.
  92163. * @param position Define the starting position of the camera in the scene.
  92164. * @param scene Define the scene the camera belongs to.
  92165. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92166. */
  92167. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92168. /**
  92169. * Attach a control to the HTML DOM element.
  92170. * @param element Defines the element that listens to the input events.
  92171. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92172. */
  92173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92174. /**
  92175. * Detach a control from the HTML DOM element.
  92176. * The camera will stop reacting to that input.
  92177. * @param element Defines the element that listens to the input events.
  92178. */
  92179. detachControl(element: HTMLElement): void;
  92180. private _collisionMask;
  92181. /**
  92182. * Get the mask that the camera ignores in collision events.
  92183. */
  92184. /**
  92185. * Set the mask that the camera ignores in collision events.
  92186. */
  92187. collisionMask: number;
  92188. /** @hidden */
  92189. _collideWithWorld(displacement: Vector3): void;
  92190. /** @hidden */
  92191. private _onCollisionPositionChange;
  92192. /** @hidden */
  92193. _checkInputs(): void;
  92194. /** @hidden */
  92195. _decideIfNeedsToMove(): boolean;
  92196. /** @hidden */
  92197. _updatePosition(): void;
  92198. /**
  92199. * Restore the Roll to its target value at the rate specified.
  92200. * @param rate - Higher means slower restoring.
  92201. * @hidden
  92202. */
  92203. restoreRoll(rate: number): void;
  92204. /**
  92205. * Destroy the camera and release the current resources held by it.
  92206. */
  92207. dispose(): void;
  92208. /**
  92209. * Get the current object class name.
  92210. * @returns the class name.
  92211. */
  92212. getClassName(): string;
  92213. }
  92214. }
  92215. declare module BABYLON {
  92216. /**
  92217. * Listen to keyboard events to control the camera.
  92218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92219. */
  92220. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  92221. /**
  92222. * Defines the camera the input is attached to.
  92223. */
  92224. camera: FlyCamera;
  92225. /**
  92226. * The list of keyboard keys used to control the forward move of the camera.
  92227. */
  92228. keysForward: number[];
  92229. /**
  92230. * The list of keyboard keys used to control the backward move of the camera.
  92231. */
  92232. keysBackward: number[];
  92233. /**
  92234. * The list of keyboard keys used to control the forward move of the camera.
  92235. */
  92236. keysUp: number[];
  92237. /**
  92238. * The list of keyboard keys used to control the backward move of the camera.
  92239. */
  92240. keysDown: number[];
  92241. /**
  92242. * The list of keyboard keys used to control the right strafe move of the camera.
  92243. */
  92244. keysRight: number[];
  92245. /**
  92246. * The list of keyboard keys used to control the left strafe move of the camera.
  92247. */
  92248. keysLeft: number[];
  92249. private _keys;
  92250. private _onCanvasBlurObserver;
  92251. private _onKeyboardObserver;
  92252. private _engine;
  92253. private _scene;
  92254. /**
  92255. * Attach the input controls to a specific dom element to get the input from.
  92256. * @param element Defines the element the controls should be listened from
  92257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92258. */
  92259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92260. /**
  92261. * Detach the current controls from the specified dom element.
  92262. * @param element Defines the element to stop listening the inputs from
  92263. */
  92264. detachControl(element: Nullable<HTMLElement>): void;
  92265. /**
  92266. * Gets the class name of the current intput.
  92267. * @returns the class name
  92268. */
  92269. getClassName(): string;
  92270. /** @hidden */
  92271. _onLostFocus(e: FocusEvent): void;
  92272. /**
  92273. * Get the friendly name associated with the input class.
  92274. * @returns the input friendly name
  92275. */
  92276. getSimpleName(): string;
  92277. /**
  92278. * Update the current camera state depending on the inputs that have been used this frame.
  92279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92280. */
  92281. checkInputs(): void;
  92282. }
  92283. }
  92284. declare module BABYLON {
  92285. interface FreeCameraInputsManager {
  92286. /**
  92287. * Add orientation input support to the input manager.
  92288. * @returns the current input manager
  92289. */
  92290. addDeviceOrientation(): FreeCameraInputsManager;
  92291. }
  92292. /**
  92293. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  92294. * Screen rotation is taken into account.
  92295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92296. */
  92297. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  92298. private _camera;
  92299. private _screenOrientationAngle;
  92300. private _constantTranform;
  92301. private _screenQuaternion;
  92302. private _alpha;
  92303. private _beta;
  92304. private _gamma;
  92305. /**
  92306. * Instantiates a new input
  92307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92308. */
  92309. constructor();
  92310. /**
  92311. * Define the camera controlled by the input.
  92312. */
  92313. camera: FreeCamera;
  92314. /**
  92315. * Attach the input controls to a specific dom element to get the input from.
  92316. * @param element Defines the element the controls should be listened from
  92317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92318. */
  92319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92320. private _orientationChanged;
  92321. private _deviceOrientation;
  92322. /**
  92323. * Detach the current controls from the specified dom element.
  92324. * @param element Defines the element to stop listening the inputs from
  92325. */
  92326. detachControl(element: Nullable<HTMLElement>): void;
  92327. /**
  92328. * Update the current camera state depending on the inputs that have been used this frame.
  92329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92330. */
  92331. checkInputs(): void;
  92332. /**
  92333. * Gets the class name of the current intput.
  92334. * @returns the class name
  92335. */
  92336. getClassName(): string;
  92337. /**
  92338. * Get the friendly name associated with the input class.
  92339. * @returns the input friendly name
  92340. */
  92341. getSimpleName(): string;
  92342. }
  92343. }
  92344. declare module BABYLON {
  92345. /**
  92346. * Manage the gamepad inputs to control a free camera.
  92347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92348. */
  92349. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92350. /**
  92351. * Define the camera the input is attached to.
  92352. */
  92353. camera: FreeCamera;
  92354. /**
  92355. * Define the Gamepad controlling the input
  92356. */
  92357. gamepad: Nullable<Gamepad>;
  92358. /**
  92359. * Defines the gamepad rotation sensiblity.
  92360. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92361. */
  92362. gamepadAngularSensibility: number;
  92363. /**
  92364. * Defines the gamepad move sensiblity.
  92365. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92366. */
  92367. gamepadMoveSensibility: number;
  92368. private _onGamepadConnectedObserver;
  92369. private _onGamepadDisconnectedObserver;
  92370. private _cameraTransform;
  92371. private _deltaTransform;
  92372. private _vector3;
  92373. private _vector2;
  92374. /**
  92375. * Attach the input controls to a specific dom element to get the input from.
  92376. * @param element Defines the element the controls should be listened from
  92377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92378. */
  92379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92380. /**
  92381. * Detach the current controls from the specified dom element.
  92382. * @param element Defines the element to stop listening the inputs from
  92383. */
  92384. detachControl(element: Nullable<HTMLElement>): void;
  92385. /**
  92386. * Update the current camera state depending on the inputs that have been used this frame.
  92387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92388. */
  92389. checkInputs(): void;
  92390. /**
  92391. * Gets the class name of the current intput.
  92392. * @returns the class name
  92393. */
  92394. getClassName(): string;
  92395. /**
  92396. * Get the friendly name associated with the input class.
  92397. * @returns the input friendly name
  92398. */
  92399. getSimpleName(): string;
  92400. }
  92401. }
  92402. declare module BABYLON {
  92403. /**
  92404. * Defines the potential axis of a Joystick
  92405. */
  92406. export enum JoystickAxis {
  92407. /** X axis */
  92408. X = 0,
  92409. /** Y axis */
  92410. Y = 1,
  92411. /** Z axis */
  92412. Z = 2
  92413. }
  92414. /**
  92415. * Class used to define virtual joystick (used in touch mode)
  92416. */
  92417. export class VirtualJoystick {
  92418. /**
  92419. * Gets or sets a boolean indicating that left and right values must be inverted
  92420. */
  92421. reverseLeftRight: boolean;
  92422. /**
  92423. * Gets or sets a boolean indicating that up and down values must be inverted
  92424. */
  92425. reverseUpDown: boolean;
  92426. /**
  92427. * Gets the offset value for the position (ie. the change of the position value)
  92428. */
  92429. deltaPosition: Vector3;
  92430. /**
  92431. * Gets a boolean indicating if the virtual joystick was pressed
  92432. */
  92433. pressed: boolean;
  92434. /**
  92435. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92436. */
  92437. static Canvas: Nullable<HTMLCanvasElement>;
  92438. private static _globalJoystickIndex;
  92439. private static vjCanvasContext;
  92440. private static vjCanvasWidth;
  92441. private static vjCanvasHeight;
  92442. private static halfWidth;
  92443. private _action;
  92444. private _axisTargetedByLeftAndRight;
  92445. private _axisTargetedByUpAndDown;
  92446. private _joystickSensibility;
  92447. private _inversedSensibility;
  92448. private _joystickPointerID;
  92449. private _joystickColor;
  92450. private _joystickPointerPos;
  92451. private _joystickPreviousPointerPos;
  92452. private _joystickPointerStartPos;
  92453. private _deltaJoystickVector;
  92454. private _leftJoystick;
  92455. private _touches;
  92456. private _onPointerDownHandlerRef;
  92457. private _onPointerMoveHandlerRef;
  92458. private _onPointerUpHandlerRef;
  92459. private _onResize;
  92460. /**
  92461. * Creates a new virtual joystick
  92462. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92463. */
  92464. constructor(leftJoystick?: boolean);
  92465. /**
  92466. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92467. * @param newJoystickSensibility defines the new sensibility
  92468. */
  92469. setJoystickSensibility(newJoystickSensibility: number): void;
  92470. private _onPointerDown;
  92471. private _onPointerMove;
  92472. private _onPointerUp;
  92473. /**
  92474. * Change the color of the virtual joystick
  92475. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92476. */
  92477. setJoystickColor(newColor: string): void;
  92478. /**
  92479. * Defines a callback to call when the joystick is touched
  92480. * @param action defines the callback
  92481. */
  92482. setActionOnTouch(action: () => any): void;
  92483. /**
  92484. * Defines which axis you'd like to control for left & right
  92485. * @param axis defines the axis to use
  92486. */
  92487. setAxisForLeftRight(axis: JoystickAxis): void;
  92488. /**
  92489. * Defines which axis you'd like to control for up & down
  92490. * @param axis defines the axis to use
  92491. */
  92492. setAxisForUpDown(axis: JoystickAxis): void;
  92493. private _drawVirtualJoystick;
  92494. /**
  92495. * Release internal HTML canvas
  92496. */
  92497. releaseCanvas(): void;
  92498. }
  92499. }
  92500. declare module BABYLON {
  92501. interface FreeCameraInputsManager {
  92502. /**
  92503. * Add virtual joystick input support to the input manager.
  92504. * @returns the current input manager
  92505. */
  92506. addVirtualJoystick(): FreeCameraInputsManager;
  92507. }
  92508. /**
  92509. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92511. */
  92512. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92513. /**
  92514. * Defines the camera the input is attached to.
  92515. */
  92516. camera: FreeCamera;
  92517. private _leftjoystick;
  92518. private _rightjoystick;
  92519. /**
  92520. * Gets the left stick of the virtual joystick.
  92521. * @returns The virtual Joystick
  92522. */
  92523. getLeftJoystick(): VirtualJoystick;
  92524. /**
  92525. * Gets the right stick of the virtual joystick.
  92526. * @returns The virtual Joystick
  92527. */
  92528. getRightJoystick(): VirtualJoystick;
  92529. /**
  92530. * Update the current camera state depending on the inputs that have been used this frame.
  92531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92532. */
  92533. checkInputs(): void;
  92534. /**
  92535. * Attach the input controls to a specific dom element to get the input from.
  92536. * @param element Defines the element the controls should be listened from
  92537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92538. */
  92539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92540. /**
  92541. * Detach the current controls from the specified dom element.
  92542. * @param element Defines the element to stop listening the inputs from
  92543. */
  92544. detachControl(element: Nullable<HTMLElement>): void;
  92545. /**
  92546. * Gets the class name of the current intput.
  92547. * @returns the class name
  92548. */
  92549. getClassName(): string;
  92550. /**
  92551. * Get the friendly name associated with the input class.
  92552. * @returns the input friendly name
  92553. */
  92554. getSimpleName(): string;
  92555. }
  92556. }
  92557. declare module BABYLON {
  92558. /**
  92559. * This represents a FPS type of camera controlled by touch.
  92560. * This is like a universal camera minus the Gamepad controls.
  92561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92562. */
  92563. export class TouchCamera extends FreeCamera {
  92564. /**
  92565. * Defines the touch sensibility for rotation.
  92566. * The higher the faster.
  92567. */
  92568. touchAngularSensibility: number;
  92569. /**
  92570. * Defines the touch sensibility for move.
  92571. * The higher the faster.
  92572. */
  92573. touchMoveSensibility: number;
  92574. /**
  92575. * Instantiates a new touch camera.
  92576. * This represents a FPS type of camera controlled by touch.
  92577. * This is like a universal camera minus the Gamepad controls.
  92578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92579. * @param name Define the name of the camera in the scene
  92580. * @param position Define the start position of the camera in the scene
  92581. * @param scene Define the scene the camera belongs to
  92582. */
  92583. constructor(name: string, position: Vector3, scene: Scene);
  92584. /**
  92585. * Gets the current object class name.
  92586. * @return the class name
  92587. */
  92588. getClassName(): string;
  92589. /** @hidden */
  92590. _setupInputs(): void;
  92591. }
  92592. }
  92593. declare module BABYLON {
  92594. /**
  92595. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92596. * being tilted forward or back and left or right.
  92597. */
  92598. export class DeviceOrientationCamera extends FreeCamera {
  92599. private _initialQuaternion;
  92600. private _quaternionCache;
  92601. /**
  92602. * Creates a new device orientation camera
  92603. * @param name The name of the camera
  92604. * @param position The start position camera
  92605. * @param scene The scene the camera belongs to
  92606. */
  92607. constructor(name: string, position: Vector3, scene: Scene);
  92608. /**
  92609. * Gets the current instance class name ("DeviceOrientationCamera").
  92610. * This helps avoiding instanceof at run time.
  92611. * @returns the class name
  92612. */
  92613. getClassName(): string;
  92614. /**
  92615. * @hidden
  92616. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92617. */
  92618. _checkInputs(): void;
  92619. /**
  92620. * Reset the camera to its default orientation on the specified axis only.
  92621. * @param axis The axis to reset
  92622. */
  92623. resetToCurrentRotation(axis?: Axis): void;
  92624. }
  92625. }
  92626. declare module BABYLON {
  92627. /**
  92628. * Manage the keyboard inputs to control the movement of a follow camera.
  92629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92630. */
  92631. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92632. /**
  92633. * Defines the camera the input is attached to.
  92634. */
  92635. camera: FollowCamera;
  92636. /**
  92637. * Defines the list of key codes associated with the up action (increase heightOffset)
  92638. */
  92639. keysHeightOffsetIncr: number[];
  92640. /**
  92641. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92642. */
  92643. keysHeightOffsetDecr: number[];
  92644. /**
  92645. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92646. */
  92647. keysHeightOffsetModifierAlt: boolean;
  92648. /**
  92649. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92650. */
  92651. keysHeightOffsetModifierCtrl: boolean;
  92652. /**
  92653. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92654. */
  92655. keysHeightOffsetModifierShift: boolean;
  92656. /**
  92657. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92658. */
  92659. keysRotationOffsetIncr: number[];
  92660. /**
  92661. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92662. */
  92663. keysRotationOffsetDecr: number[];
  92664. /**
  92665. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92666. */
  92667. keysRotationOffsetModifierAlt: boolean;
  92668. /**
  92669. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92670. */
  92671. keysRotationOffsetModifierCtrl: boolean;
  92672. /**
  92673. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92674. */
  92675. keysRotationOffsetModifierShift: boolean;
  92676. /**
  92677. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92678. */
  92679. keysRadiusIncr: number[];
  92680. /**
  92681. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92682. */
  92683. keysRadiusDecr: number[];
  92684. /**
  92685. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92686. */
  92687. keysRadiusModifierAlt: boolean;
  92688. /**
  92689. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92690. */
  92691. keysRadiusModifierCtrl: boolean;
  92692. /**
  92693. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92694. */
  92695. keysRadiusModifierShift: boolean;
  92696. /**
  92697. * Defines the rate of change of heightOffset.
  92698. */
  92699. heightSensibility: number;
  92700. /**
  92701. * Defines the rate of change of rotationOffset.
  92702. */
  92703. rotationSensibility: number;
  92704. /**
  92705. * Defines the rate of change of radius.
  92706. */
  92707. radiusSensibility: number;
  92708. private _keys;
  92709. private _ctrlPressed;
  92710. private _altPressed;
  92711. private _shiftPressed;
  92712. private _onCanvasBlurObserver;
  92713. private _onKeyboardObserver;
  92714. private _engine;
  92715. private _scene;
  92716. /**
  92717. * Attach the input controls to a specific dom element to get the input from.
  92718. * @param element Defines the element the controls should be listened from
  92719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92720. */
  92721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92722. /**
  92723. * Detach the current controls from the specified dom element.
  92724. * @param element Defines the element to stop listening the inputs from
  92725. */
  92726. detachControl(element: Nullable<HTMLElement>): void;
  92727. /**
  92728. * Update the current camera state depending on the inputs that have been used this frame.
  92729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92730. */
  92731. checkInputs(): void;
  92732. /**
  92733. * Gets the class name of the current input.
  92734. * @returns the class name
  92735. */
  92736. getClassName(): string;
  92737. /**
  92738. * Get the friendly name associated with the input class.
  92739. * @returns the input friendly name
  92740. */
  92741. getSimpleName(): string;
  92742. /**
  92743. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92744. * allow modification of the heightOffset value.
  92745. */
  92746. private _modifierHeightOffset;
  92747. /**
  92748. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92749. * allow modification of the rotationOffset value.
  92750. */
  92751. private _modifierRotationOffset;
  92752. /**
  92753. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92754. * allow modification of the radius value.
  92755. */
  92756. private _modifierRadius;
  92757. }
  92758. }
  92759. declare module BABYLON {
  92760. /**
  92761. * Manage the mouse wheel inputs to control a follow camera.
  92762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92763. */
  92764. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92765. /**
  92766. * Defines the camera the input is attached to.
  92767. */
  92768. camera: FollowCamera;
  92769. /**
  92770. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92771. */
  92772. axisControlRadius: boolean;
  92773. /**
  92774. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92775. */
  92776. axisControlHeight: boolean;
  92777. /**
  92778. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92779. */
  92780. axisControlRotation: boolean;
  92781. /**
  92782. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92783. * relation to mouseWheel events.
  92784. */
  92785. wheelPrecision: number;
  92786. /**
  92787. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92788. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92789. */
  92790. wheelDeltaPercentage: number;
  92791. private _wheel;
  92792. private _observer;
  92793. /**
  92794. * Attach the input controls to a specific dom element to get the input from.
  92795. * @param element Defines the element the controls should be listened from
  92796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92797. */
  92798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92799. /**
  92800. * Detach the current controls from the specified dom element.
  92801. * @param element Defines the element to stop listening the inputs from
  92802. */
  92803. detachControl(element: Nullable<HTMLElement>): void;
  92804. /**
  92805. * Gets the class name of the current intput.
  92806. * @returns the class name
  92807. */
  92808. getClassName(): string;
  92809. /**
  92810. * Get the friendly name associated with the input class.
  92811. * @returns the input friendly name
  92812. */
  92813. getSimpleName(): string;
  92814. }
  92815. }
  92816. declare module BABYLON {
  92817. /**
  92818. * Default Inputs manager for the FollowCamera.
  92819. * It groups all the default supported inputs for ease of use.
  92820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92821. */
  92822. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92823. /**
  92824. * Instantiates a new FollowCameraInputsManager.
  92825. * @param camera Defines the camera the inputs belong to
  92826. */
  92827. constructor(camera: FollowCamera);
  92828. /**
  92829. * Add keyboard input support to the input manager.
  92830. * @returns the current input manager
  92831. */
  92832. addKeyboard(): FollowCameraInputsManager;
  92833. /**
  92834. * Add mouse wheel input support to the input manager.
  92835. * @returns the current input manager
  92836. */
  92837. addMouseWheel(): FollowCameraInputsManager;
  92838. /**
  92839. * Add pointers input support to the input manager.
  92840. * @returns the current input manager
  92841. */
  92842. addPointers(): FollowCameraInputsManager;
  92843. /**
  92844. * Add orientation input support to the input manager.
  92845. * @returns the current input manager
  92846. */
  92847. addVRDeviceOrientation(): FollowCameraInputsManager;
  92848. }
  92849. }
  92850. declare module BABYLON {
  92851. /**
  92852. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92853. * an arc rotate version arcFollowCamera are available.
  92854. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92855. */
  92856. export class FollowCamera extends TargetCamera {
  92857. /**
  92858. * Distance the follow camera should follow an object at
  92859. */
  92860. radius: number;
  92861. /**
  92862. * Minimum allowed distance of the camera to the axis of rotation
  92863. * (The camera can not get closer).
  92864. * This can help limiting how the Camera is able to move in the scene.
  92865. */
  92866. lowerRadiusLimit: Nullable<number>;
  92867. /**
  92868. * Maximum allowed distance of the camera to the axis of rotation
  92869. * (The camera can not get further).
  92870. * This can help limiting how the Camera is able to move in the scene.
  92871. */
  92872. upperRadiusLimit: Nullable<number>;
  92873. /**
  92874. * Define a rotation offset between the camera and the object it follows
  92875. */
  92876. rotationOffset: number;
  92877. /**
  92878. * Minimum allowed angle to camera position relative to target object.
  92879. * This can help limiting how the Camera is able to move in the scene.
  92880. */
  92881. lowerRotationOffsetLimit: Nullable<number>;
  92882. /**
  92883. * Maximum allowed angle to camera position relative to target object.
  92884. * This can help limiting how the Camera is able to move in the scene.
  92885. */
  92886. upperRotationOffsetLimit: Nullable<number>;
  92887. /**
  92888. * Define a height offset between the camera and the object it follows.
  92889. * It can help following an object from the top (like a car chaing a plane)
  92890. */
  92891. heightOffset: number;
  92892. /**
  92893. * Minimum allowed height of camera position relative to target object.
  92894. * This can help limiting how the Camera is able to move in the scene.
  92895. */
  92896. lowerHeightOffsetLimit: Nullable<number>;
  92897. /**
  92898. * Maximum allowed height of camera position relative to target object.
  92899. * This can help limiting how the Camera is able to move in the scene.
  92900. */
  92901. upperHeightOffsetLimit: Nullable<number>;
  92902. /**
  92903. * Define how fast the camera can accelerate to follow it s target.
  92904. */
  92905. cameraAcceleration: number;
  92906. /**
  92907. * Define the speed limit of the camera following an object.
  92908. */
  92909. maxCameraSpeed: number;
  92910. /**
  92911. * Define the target of the camera.
  92912. */
  92913. lockedTarget: Nullable<AbstractMesh>;
  92914. /**
  92915. * Defines the input associated with the camera.
  92916. */
  92917. inputs: FollowCameraInputsManager;
  92918. /**
  92919. * Instantiates the follow camera.
  92920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92921. * @param name Define the name of the camera in the scene
  92922. * @param position Define the position of the camera
  92923. * @param scene Define the scene the camera belong to
  92924. * @param lockedTarget Define the target of the camera
  92925. */
  92926. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92927. private _follow;
  92928. /**
  92929. * Attached controls to the current camera.
  92930. * @param element Defines the element the controls should be listened from
  92931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92932. */
  92933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92934. /**
  92935. * Detach the current controls from the camera.
  92936. * The camera will stop reacting to inputs.
  92937. * @param element Defines the element to stop listening the inputs from
  92938. */
  92939. detachControl(element: HTMLElement): void;
  92940. /** @hidden */
  92941. _checkInputs(): void;
  92942. private _checkLimits;
  92943. /**
  92944. * Gets the camera class name.
  92945. * @returns the class name
  92946. */
  92947. getClassName(): string;
  92948. }
  92949. /**
  92950. * Arc Rotate version of the follow camera.
  92951. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92952. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92953. */
  92954. export class ArcFollowCamera extends TargetCamera {
  92955. /** The longitudinal angle of the camera */
  92956. alpha: number;
  92957. /** The latitudinal angle of the camera */
  92958. beta: number;
  92959. /** The radius of the camera from its target */
  92960. radius: number;
  92961. /** Define the camera target (the messh it should follow) */
  92962. target: Nullable<AbstractMesh>;
  92963. private _cartesianCoordinates;
  92964. /**
  92965. * Instantiates a new ArcFollowCamera
  92966. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92967. * @param name Define the name of the camera
  92968. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92969. * @param beta Define the rotation angle of the camera around the elevation axis
  92970. * @param radius Define the radius of the camera from its target point
  92971. * @param target Define the target of the camera
  92972. * @param scene Define the scene the camera belongs to
  92973. */
  92974. constructor(name: string,
  92975. /** The longitudinal angle of the camera */
  92976. alpha: number,
  92977. /** The latitudinal angle of the camera */
  92978. beta: number,
  92979. /** The radius of the camera from its target */
  92980. radius: number,
  92981. /** Define the camera target (the messh it should follow) */
  92982. target: Nullable<AbstractMesh>, scene: Scene);
  92983. private _follow;
  92984. /** @hidden */
  92985. _checkInputs(): void;
  92986. /**
  92987. * Returns the class name of the object.
  92988. * It is mostly used internally for serialization purposes.
  92989. */
  92990. getClassName(): string;
  92991. }
  92992. }
  92993. declare module BABYLON {
  92994. /**
  92995. * 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,
  92996. * which still works and will still be found in many Playgrounds.
  92997. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92998. */
  92999. export class UniversalCamera extends TouchCamera {
  93000. /**
  93001. * Defines the gamepad rotation sensiblity.
  93002. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93003. */
  93004. gamepadAngularSensibility: number;
  93005. /**
  93006. * Defines the gamepad move sensiblity.
  93007. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93008. */
  93009. gamepadMoveSensibility: number;
  93010. /**
  93011. * 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,
  93012. * which still works and will still be found in many Playgrounds.
  93013. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93014. * @param name Define the name of the camera in the scene
  93015. * @param position Define the start position of the camera in the scene
  93016. * @param scene Define the scene the camera belongs to
  93017. */
  93018. constructor(name: string, position: Vector3, scene: Scene);
  93019. /**
  93020. * Gets the current object class name.
  93021. * @return the class name
  93022. */
  93023. getClassName(): string;
  93024. }
  93025. }
  93026. declare module BABYLON {
  93027. /**
  93028. * This represents a FPS type of camera. This is only here for back compat purpose.
  93029. * Please use the UniversalCamera instead as both are identical.
  93030. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93031. */
  93032. export class GamepadCamera extends UniversalCamera {
  93033. /**
  93034. * Instantiates a new Gamepad Camera
  93035. * This represents a FPS type of camera. This is only here for back compat purpose.
  93036. * Please use the UniversalCamera instead as both are identical.
  93037. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93038. * @param name Define the name of the camera in the scene
  93039. * @param position Define the start position of the camera in the scene
  93040. * @param scene Define the scene the camera belongs to
  93041. */
  93042. constructor(name: string, position: Vector3, scene: Scene);
  93043. /**
  93044. * Gets the current object class name.
  93045. * @return the class name
  93046. */
  93047. getClassName(): string;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /** @hidden */
  93052. export var passPixelShader: {
  93053. name: string;
  93054. shader: string;
  93055. };
  93056. }
  93057. declare module BABYLON {
  93058. /** @hidden */
  93059. export var passCubePixelShader: {
  93060. name: string;
  93061. shader: string;
  93062. };
  93063. }
  93064. declare module BABYLON {
  93065. /**
  93066. * PassPostProcess which produces an output the same as it's input
  93067. */
  93068. export class PassPostProcess extends PostProcess {
  93069. /**
  93070. * Creates the PassPostProcess
  93071. * @param name The name of the effect.
  93072. * @param options The required width/height ratio to downsize to before computing the render pass.
  93073. * @param camera The camera to apply the render pass to.
  93074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93075. * @param engine The engine which the post process will be applied. (default: current engine)
  93076. * @param reusable If the post process can be reused on the same frame. (default: false)
  93077. * @param textureType The type of texture to be used when performing the post processing.
  93078. * @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)
  93079. */
  93080. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93081. }
  93082. /**
  93083. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93084. */
  93085. export class PassCubePostProcess extends PostProcess {
  93086. private _face;
  93087. /**
  93088. * Gets or sets the cube face to display.
  93089. * * 0 is +X
  93090. * * 1 is -X
  93091. * * 2 is +Y
  93092. * * 3 is -Y
  93093. * * 4 is +Z
  93094. * * 5 is -Z
  93095. */
  93096. face: number;
  93097. /**
  93098. * Creates the PassCubePostProcess
  93099. * @param name The name of the effect.
  93100. * @param options The required width/height ratio to downsize to before computing the render pass.
  93101. * @param camera The camera to apply the render pass to.
  93102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93103. * @param engine The engine which the post process will be applied. (default: current engine)
  93104. * @param reusable If the post process can be reused on the same frame. (default: false)
  93105. * @param textureType The type of texture to be used when performing the post processing.
  93106. * @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)
  93107. */
  93108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93109. }
  93110. }
  93111. declare module BABYLON {
  93112. /** @hidden */
  93113. export var anaglyphPixelShader: {
  93114. name: string;
  93115. shader: string;
  93116. };
  93117. }
  93118. declare module BABYLON {
  93119. /**
  93120. * Postprocess used to generate anaglyphic rendering
  93121. */
  93122. export class AnaglyphPostProcess extends PostProcess {
  93123. private _passedProcess;
  93124. /**
  93125. * Creates a new AnaglyphPostProcess
  93126. * @param name defines postprocess name
  93127. * @param options defines creation options or target ratio scale
  93128. * @param rigCameras defines cameras using this postprocess
  93129. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  93130. * @param engine defines hosting engine
  93131. * @param reusable defines if the postprocess will be reused multiple times per frame
  93132. */
  93133. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  93134. }
  93135. }
  93136. declare module BABYLON {
  93137. /**
  93138. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  93139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93140. */
  93141. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  93142. /**
  93143. * Creates a new AnaglyphArcRotateCamera
  93144. * @param name defines camera name
  93145. * @param alpha defines alpha angle (in radians)
  93146. * @param beta defines beta angle (in radians)
  93147. * @param radius defines radius
  93148. * @param target defines camera target
  93149. * @param interaxialDistance defines distance between each color axis
  93150. * @param scene defines the hosting scene
  93151. */
  93152. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  93153. /**
  93154. * Gets camera class name
  93155. * @returns AnaglyphArcRotateCamera
  93156. */
  93157. getClassName(): string;
  93158. }
  93159. }
  93160. declare module BABYLON {
  93161. /**
  93162. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  93163. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93164. */
  93165. export class AnaglyphFreeCamera extends FreeCamera {
  93166. /**
  93167. * Creates a new AnaglyphFreeCamera
  93168. * @param name defines camera name
  93169. * @param position defines initial position
  93170. * @param interaxialDistance defines distance between each color axis
  93171. * @param scene defines the hosting scene
  93172. */
  93173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93174. /**
  93175. * Gets camera class name
  93176. * @returns AnaglyphFreeCamera
  93177. */
  93178. getClassName(): string;
  93179. }
  93180. }
  93181. declare module BABYLON {
  93182. /**
  93183. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  93184. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93185. */
  93186. export class AnaglyphGamepadCamera extends GamepadCamera {
  93187. /**
  93188. * Creates a new AnaglyphGamepadCamera
  93189. * @param name defines camera name
  93190. * @param position defines initial position
  93191. * @param interaxialDistance defines distance between each color axis
  93192. * @param scene defines the hosting scene
  93193. */
  93194. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93195. /**
  93196. * Gets camera class name
  93197. * @returns AnaglyphGamepadCamera
  93198. */
  93199. getClassName(): string;
  93200. }
  93201. }
  93202. declare module BABYLON {
  93203. /**
  93204. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  93205. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93206. */
  93207. export class AnaglyphUniversalCamera extends UniversalCamera {
  93208. /**
  93209. * Creates a new AnaglyphUniversalCamera
  93210. * @param name defines camera name
  93211. * @param position defines initial position
  93212. * @param interaxialDistance defines distance between each color axis
  93213. * @param scene defines the hosting scene
  93214. */
  93215. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93216. /**
  93217. * Gets camera class name
  93218. * @returns AnaglyphUniversalCamera
  93219. */
  93220. getClassName(): string;
  93221. }
  93222. }
  93223. declare module BABYLON {
  93224. /** @hidden */
  93225. export var stereoscopicInterlacePixelShader: {
  93226. name: string;
  93227. shader: string;
  93228. };
  93229. }
  93230. declare module BABYLON {
  93231. /**
  93232. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  93233. */
  93234. export class StereoscopicInterlacePostProcess extends PostProcess {
  93235. private _stepSize;
  93236. private _passedProcess;
  93237. /**
  93238. * Initializes a StereoscopicInterlacePostProcess
  93239. * @param name The name of the effect.
  93240. * @param rigCameras The rig cameras to be appled to the post process
  93241. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  93242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93243. * @param engine The engine which the post process will be applied. (default: current engine)
  93244. * @param reusable If the post process can be reused on the same frame. (default: false)
  93245. */
  93246. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  93247. }
  93248. }
  93249. declare module BABYLON {
  93250. /**
  93251. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  93252. * @see http://doc.babylonjs.com/features/cameras
  93253. */
  93254. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  93255. /**
  93256. * Creates a new StereoscopicArcRotateCamera
  93257. * @param name defines camera name
  93258. * @param alpha defines alpha angle (in radians)
  93259. * @param beta defines beta angle (in radians)
  93260. * @param radius defines radius
  93261. * @param target defines camera target
  93262. * @param interaxialDistance defines distance between each color axis
  93263. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93264. * @param scene defines the hosting scene
  93265. */
  93266. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93267. /**
  93268. * Gets camera class name
  93269. * @returns StereoscopicArcRotateCamera
  93270. */
  93271. getClassName(): string;
  93272. }
  93273. }
  93274. declare module BABYLON {
  93275. /**
  93276. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  93277. * @see http://doc.babylonjs.com/features/cameras
  93278. */
  93279. export class StereoscopicFreeCamera extends FreeCamera {
  93280. /**
  93281. * Creates a new StereoscopicFreeCamera
  93282. * @param name defines camera name
  93283. * @param position defines initial position
  93284. * @param interaxialDistance defines distance between each color axis
  93285. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93286. * @param scene defines the hosting scene
  93287. */
  93288. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93289. /**
  93290. * Gets camera class name
  93291. * @returns StereoscopicFreeCamera
  93292. */
  93293. getClassName(): string;
  93294. }
  93295. }
  93296. declare module BABYLON {
  93297. /**
  93298. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  93299. * @see http://doc.babylonjs.com/features/cameras
  93300. */
  93301. export class StereoscopicGamepadCamera extends GamepadCamera {
  93302. /**
  93303. * Creates a new StereoscopicGamepadCamera
  93304. * @param name defines camera name
  93305. * @param position defines initial position
  93306. * @param interaxialDistance defines distance between each color axis
  93307. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93308. * @param scene defines the hosting scene
  93309. */
  93310. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93311. /**
  93312. * Gets camera class name
  93313. * @returns StereoscopicGamepadCamera
  93314. */
  93315. getClassName(): string;
  93316. }
  93317. }
  93318. declare module BABYLON {
  93319. /**
  93320. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  93321. * @see http://doc.babylonjs.com/features/cameras
  93322. */
  93323. export class StereoscopicUniversalCamera extends UniversalCamera {
  93324. /**
  93325. * Creates a new StereoscopicUniversalCamera
  93326. * @param name defines camera name
  93327. * @param position defines initial position
  93328. * @param interaxialDistance defines distance between each color axis
  93329. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93330. * @param scene defines the hosting scene
  93331. */
  93332. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93333. /**
  93334. * Gets camera class name
  93335. * @returns StereoscopicUniversalCamera
  93336. */
  93337. getClassName(): string;
  93338. }
  93339. }
  93340. declare module BABYLON {
  93341. /**
  93342. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93343. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93344. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93345. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93346. */
  93347. export class VirtualJoysticksCamera extends FreeCamera {
  93348. /**
  93349. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93350. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93351. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93352. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93353. * @param name Define the name of the camera in the scene
  93354. * @param position Define the start position of the camera in the scene
  93355. * @param scene Define the scene the camera belongs to
  93356. */
  93357. constructor(name: string, position: Vector3, scene: Scene);
  93358. /**
  93359. * Gets the current object class name.
  93360. * @return the class name
  93361. */
  93362. getClassName(): string;
  93363. }
  93364. }
  93365. declare module BABYLON {
  93366. /**
  93367. * This represents all the required metrics to create a VR camera.
  93368. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93369. */
  93370. export class VRCameraMetrics {
  93371. /**
  93372. * Define the horizontal resolution off the screen.
  93373. */
  93374. hResolution: number;
  93375. /**
  93376. * Define the vertical resolution off the screen.
  93377. */
  93378. vResolution: number;
  93379. /**
  93380. * Define the horizontal screen size.
  93381. */
  93382. hScreenSize: number;
  93383. /**
  93384. * Define the vertical screen size.
  93385. */
  93386. vScreenSize: number;
  93387. /**
  93388. * Define the vertical screen center position.
  93389. */
  93390. vScreenCenter: number;
  93391. /**
  93392. * Define the distance of the eyes to the screen.
  93393. */
  93394. eyeToScreenDistance: number;
  93395. /**
  93396. * Define the distance between both lenses
  93397. */
  93398. lensSeparationDistance: number;
  93399. /**
  93400. * Define the distance between both viewer's eyes.
  93401. */
  93402. interpupillaryDistance: number;
  93403. /**
  93404. * Define the distortion factor of the VR postprocess.
  93405. * Please, touch with care.
  93406. */
  93407. distortionK: number[];
  93408. /**
  93409. * Define the chromatic aberration correction factors for the VR post process.
  93410. */
  93411. chromaAbCorrection: number[];
  93412. /**
  93413. * Define the scale factor of the post process.
  93414. * The smaller the better but the slower.
  93415. */
  93416. postProcessScaleFactor: number;
  93417. /**
  93418. * Define an offset for the lens center.
  93419. */
  93420. lensCenterOffset: number;
  93421. /**
  93422. * Define if the current vr camera should compensate the distortion of the lense or not.
  93423. */
  93424. compensateDistortion: boolean;
  93425. /**
  93426. * Gets the rendering aspect ratio based on the provided resolutions.
  93427. */
  93428. readonly aspectRatio: number;
  93429. /**
  93430. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93431. */
  93432. readonly aspectRatioFov: number;
  93433. /**
  93434. * @hidden
  93435. */
  93436. readonly leftHMatrix: Matrix;
  93437. /**
  93438. * @hidden
  93439. */
  93440. readonly rightHMatrix: Matrix;
  93441. /**
  93442. * @hidden
  93443. */
  93444. readonly leftPreViewMatrix: Matrix;
  93445. /**
  93446. * @hidden
  93447. */
  93448. readonly rightPreViewMatrix: Matrix;
  93449. /**
  93450. * Get the default VRMetrics based on the most generic setup.
  93451. * @returns the default vr metrics
  93452. */
  93453. static GetDefault(): VRCameraMetrics;
  93454. }
  93455. }
  93456. declare module BABYLON {
  93457. /** @hidden */
  93458. export var vrDistortionCorrectionPixelShader: {
  93459. name: string;
  93460. shader: string;
  93461. };
  93462. }
  93463. declare module BABYLON {
  93464. /**
  93465. * VRDistortionCorrectionPostProcess used for mobile VR
  93466. */
  93467. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93468. private _isRightEye;
  93469. private _distortionFactors;
  93470. private _postProcessScaleFactor;
  93471. private _lensCenterOffset;
  93472. private _scaleIn;
  93473. private _scaleFactor;
  93474. private _lensCenter;
  93475. /**
  93476. * Initializes the VRDistortionCorrectionPostProcess
  93477. * @param name The name of the effect.
  93478. * @param camera The camera to apply the render pass to.
  93479. * @param isRightEye If this is for the right eye distortion
  93480. * @param vrMetrics All the required metrics for the VR camera
  93481. */
  93482. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93483. }
  93484. }
  93485. declare module BABYLON {
  93486. /**
  93487. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93488. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93489. */
  93490. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93491. /**
  93492. * Creates a new VRDeviceOrientationArcRotateCamera
  93493. * @param name defines camera name
  93494. * @param alpha defines the camera rotation along the logitudinal axis
  93495. * @param beta defines the camera rotation along the latitudinal axis
  93496. * @param radius defines the camera distance from its target
  93497. * @param target defines the camera target
  93498. * @param scene defines the scene the camera belongs to
  93499. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93500. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93501. */
  93502. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93503. /**
  93504. * Gets camera class name
  93505. * @returns VRDeviceOrientationArcRotateCamera
  93506. */
  93507. getClassName(): string;
  93508. }
  93509. }
  93510. declare module BABYLON {
  93511. /**
  93512. * Camera used to simulate VR rendering (based on FreeCamera)
  93513. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93514. */
  93515. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93516. /**
  93517. * Creates a new VRDeviceOrientationFreeCamera
  93518. * @param name defines camera name
  93519. * @param position defines the start position of the camera
  93520. * @param scene defines the scene the camera belongs to
  93521. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93522. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93523. */
  93524. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93525. /**
  93526. * Gets camera class name
  93527. * @returns VRDeviceOrientationFreeCamera
  93528. */
  93529. getClassName(): string;
  93530. }
  93531. }
  93532. declare module BABYLON {
  93533. /**
  93534. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93535. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93536. */
  93537. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93538. /**
  93539. * Creates a new VRDeviceOrientationGamepadCamera
  93540. * @param name defines camera name
  93541. * @param position defines the start position of the camera
  93542. * @param scene defines the scene the camera belongs to
  93543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93545. */
  93546. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93547. /**
  93548. * Gets camera class name
  93549. * @returns VRDeviceOrientationGamepadCamera
  93550. */
  93551. getClassName(): string;
  93552. }
  93553. }
  93554. declare module BABYLON {
  93555. /**
  93556. * Defines supported buttons for XBox360 compatible gamepads
  93557. */
  93558. export enum Xbox360Button {
  93559. /** A */
  93560. A = 0,
  93561. /** B */
  93562. B = 1,
  93563. /** X */
  93564. X = 2,
  93565. /** Y */
  93566. Y = 3,
  93567. /** Start */
  93568. Start = 4,
  93569. /** Back */
  93570. Back = 5,
  93571. /** Left button */
  93572. LB = 6,
  93573. /** Right button */
  93574. RB = 7,
  93575. /** Left stick */
  93576. LeftStick = 8,
  93577. /** Right stick */
  93578. RightStick = 9
  93579. }
  93580. /** Defines values for XBox360 DPad */
  93581. export enum Xbox360Dpad {
  93582. /** Up */
  93583. Up = 0,
  93584. /** Down */
  93585. Down = 1,
  93586. /** Left */
  93587. Left = 2,
  93588. /** Right */
  93589. Right = 3
  93590. }
  93591. /**
  93592. * Defines a XBox360 gamepad
  93593. */
  93594. export class Xbox360Pad extends Gamepad {
  93595. private _leftTrigger;
  93596. private _rightTrigger;
  93597. private _onlefttriggerchanged;
  93598. private _onrighttriggerchanged;
  93599. private _onbuttondown;
  93600. private _onbuttonup;
  93601. private _ondpaddown;
  93602. private _ondpadup;
  93603. /** Observable raised when a button is pressed */
  93604. onButtonDownObservable: Observable<Xbox360Button>;
  93605. /** Observable raised when a button is released */
  93606. onButtonUpObservable: Observable<Xbox360Button>;
  93607. /** Observable raised when a pad is pressed */
  93608. onPadDownObservable: Observable<Xbox360Dpad>;
  93609. /** Observable raised when a pad is released */
  93610. onPadUpObservable: Observable<Xbox360Dpad>;
  93611. private _buttonA;
  93612. private _buttonB;
  93613. private _buttonX;
  93614. private _buttonY;
  93615. private _buttonBack;
  93616. private _buttonStart;
  93617. private _buttonLB;
  93618. private _buttonRB;
  93619. private _buttonLeftStick;
  93620. private _buttonRightStick;
  93621. private _dPadUp;
  93622. private _dPadDown;
  93623. private _dPadLeft;
  93624. private _dPadRight;
  93625. private _isXboxOnePad;
  93626. /**
  93627. * Creates a new XBox360 gamepad object
  93628. * @param id defines the id of this gamepad
  93629. * @param index defines its index
  93630. * @param gamepad defines the internal HTML gamepad object
  93631. * @param xboxOne defines if it is a XBox One gamepad
  93632. */
  93633. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93634. /**
  93635. * Defines the callback to call when left trigger is pressed
  93636. * @param callback defines the callback to use
  93637. */
  93638. onlefttriggerchanged(callback: (value: number) => void): void;
  93639. /**
  93640. * Defines the callback to call when right trigger is pressed
  93641. * @param callback defines the callback to use
  93642. */
  93643. onrighttriggerchanged(callback: (value: number) => void): void;
  93644. /**
  93645. * Gets the left trigger value
  93646. */
  93647. /**
  93648. * Sets the left trigger value
  93649. */
  93650. leftTrigger: number;
  93651. /**
  93652. * Gets the right trigger value
  93653. */
  93654. /**
  93655. * Sets the right trigger value
  93656. */
  93657. rightTrigger: number;
  93658. /**
  93659. * Defines the callback to call when a button is pressed
  93660. * @param callback defines the callback to use
  93661. */
  93662. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93663. /**
  93664. * Defines the callback to call when a button is released
  93665. * @param callback defines the callback to use
  93666. */
  93667. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93668. /**
  93669. * Defines the callback to call when a pad is pressed
  93670. * @param callback defines the callback to use
  93671. */
  93672. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93673. /**
  93674. * Defines the callback to call when a pad is released
  93675. * @param callback defines the callback to use
  93676. */
  93677. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93678. private _setButtonValue;
  93679. private _setDPadValue;
  93680. /**
  93681. * Gets the value of the `A` button
  93682. */
  93683. /**
  93684. * Sets the value of the `A` button
  93685. */
  93686. buttonA: number;
  93687. /**
  93688. * Gets the value of the `B` button
  93689. */
  93690. /**
  93691. * Sets the value of the `B` button
  93692. */
  93693. buttonB: number;
  93694. /**
  93695. * Gets the value of the `X` button
  93696. */
  93697. /**
  93698. * Sets the value of the `X` button
  93699. */
  93700. buttonX: number;
  93701. /**
  93702. * Gets the value of the `Y` button
  93703. */
  93704. /**
  93705. * Sets the value of the `Y` button
  93706. */
  93707. buttonY: number;
  93708. /**
  93709. * Gets the value of the `Start` button
  93710. */
  93711. /**
  93712. * Sets the value of the `Start` button
  93713. */
  93714. buttonStart: number;
  93715. /**
  93716. * Gets the value of the `Back` button
  93717. */
  93718. /**
  93719. * Sets the value of the `Back` button
  93720. */
  93721. buttonBack: number;
  93722. /**
  93723. * Gets the value of the `Left` button
  93724. */
  93725. /**
  93726. * Sets the value of the `Left` button
  93727. */
  93728. buttonLB: number;
  93729. /**
  93730. * Gets the value of the `Right` button
  93731. */
  93732. /**
  93733. * Sets the value of the `Right` button
  93734. */
  93735. buttonRB: number;
  93736. /**
  93737. * Gets the value of the Left joystick
  93738. */
  93739. /**
  93740. * Sets the value of the Left joystick
  93741. */
  93742. buttonLeftStick: number;
  93743. /**
  93744. * Gets the value of the Right joystick
  93745. */
  93746. /**
  93747. * Sets the value of the Right joystick
  93748. */
  93749. buttonRightStick: number;
  93750. /**
  93751. * Gets the value of D-pad up
  93752. */
  93753. /**
  93754. * Sets the value of D-pad up
  93755. */
  93756. dPadUp: number;
  93757. /**
  93758. * Gets the value of D-pad down
  93759. */
  93760. /**
  93761. * Sets the value of D-pad down
  93762. */
  93763. dPadDown: number;
  93764. /**
  93765. * Gets the value of D-pad left
  93766. */
  93767. /**
  93768. * Sets the value of D-pad left
  93769. */
  93770. dPadLeft: number;
  93771. /**
  93772. * Gets the value of D-pad right
  93773. */
  93774. /**
  93775. * Sets the value of D-pad right
  93776. */
  93777. dPadRight: number;
  93778. /**
  93779. * Force the gamepad to synchronize with device values
  93780. */
  93781. update(): void;
  93782. /**
  93783. * Disposes the gamepad
  93784. */
  93785. dispose(): void;
  93786. }
  93787. }
  93788. declare module BABYLON {
  93789. /**
  93790. * Base class of materials working in push mode in babylon JS
  93791. * @hidden
  93792. */
  93793. export class PushMaterial extends Material {
  93794. protected _activeEffect: Effect;
  93795. protected _normalMatrix: Matrix;
  93796. /**
  93797. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93798. * This means that the material can keep using a previous shader while a new one is being compiled.
  93799. * This is mostly used when shader parallel compilation is supported (true by default)
  93800. */
  93801. allowShaderHotSwapping: boolean;
  93802. constructor(name: string, scene: Scene);
  93803. getEffect(): Effect;
  93804. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93805. /**
  93806. * Binds the given world matrix to the active effect
  93807. *
  93808. * @param world the matrix to bind
  93809. */
  93810. bindOnlyWorldMatrix(world: Matrix): void;
  93811. /**
  93812. * Binds the given normal matrix to the active effect
  93813. *
  93814. * @param normalMatrix the matrix to bind
  93815. */
  93816. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93817. bind(world: Matrix, mesh?: Mesh): void;
  93818. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93819. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93820. }
  93821. }
  93822. declare module BABYLON {
  93823. /**
  93824. * This groups all the flags used to control the materials channel.
  93825. */
  93826. export class MaterialFlags {
  93827. private static _DiffuseTextureEnabled;
  93828. /**
  93829. * Are diffuse textures enabled in the application.
  93830. */
  93831. static DiffuseTextureEnabled: boolean;
  93832. private static _AmbientTextureEnabled;
  93833. /**
  93834. * Are ambient textures enabled in the application.
  93835. */
  93836. static AmbientTextureEnabled: boolean;
  93837. private static _OpacityTextureEnabled;
  93838. /**
  93839. * Are opacity textures enabled in the application.
  93840. */
  93841. static OpacityTextureEnabled: boolean;
  93842. private static _ReflectionTextureEnabled;
  93843. /**
  93844. * Are reflection textures enabled in the application.
  93845. */
  93846. static ReflectionTextureEnabled: boolean;
  93847. private static _EmissiveTextureEnabled;
  93848. /**
  93849. * Are emissive textures enabled in the application.
  93850. */
  93851. static EmissiveTextureEnabled: boolean;
  93852. private static _SpecularTextureEnabled;
  93853. /**
  93854. * Are specular textures enabled in the application.
  93855. */
  93856. static SpecularTextureEnabled: boolean;
  93857. private static _BumpTextureEnabled;
  93858. /**
  93859. * Are bump textures enabled in the application.
  93860. */
  93861. static BumpTextureEnabled: boolean;
  93862. private static _LightmapTextureEnabled;
  93863. /**
  93864. * Are lightmap textures enabled in the application.
  93865. */
  93866. static LightmapTextureEnabled: boolean;
  93867. private static _RefractionTextureEnabled;
  93868. /**
  93869. * Are refraction textures enabled in the application.
  93870. */
  93871. static RefractionTextureEnabled: boolean;
  93872. private static _ColorGradingTextureEnabled;
  93873. /**
  93874. * Are color grading textures enabled in the application.
  93875. */
  93876. static ColorGradingTextureEnabled: boolean;
  93877. private static _FresnelEnabled;
  93878. /**
  93879. * Are fresnels enabled in the application.
  93880. */
  93881. static FresnelEnabled: boolean;
  93882. private static _ClearCoatTextureEnabled;
  93883. /**
  93884. * Are clear coat textures enabled in the application.
  93885. */
  93886. static ClearCoatTextureEnabled: boolean;
  93887. private static _ClearCoatBumpTextureEnabled;
  93888. /**
  93889. * Are clear coat bump textures enabled in the application.
  93890. */
  93891. static ClearCoatBumpTextureEnabled: boolean;
  93892. }
  93893. }
  93894. declare module BABYLON {
  93895. /** @hidden */
  93896. export var defaultFragmentDeclaration: {
  93897. name: string;
  93898. shader: string;
  93899. };
  93900. }
  93901. declare module BABYLON {
  93902. /** @hidden */
  93903. export var defaultUboDeclaration: {
  93904. name: string;
  93905. shader: string;
  93906. };
  93907. }
  93908. declare module BABYLON {
  93909. /** @hidden */
  93910. export var lightFragmentDeclaration: {
  93911. name: string;
  93912. shader: string;
  93913. };
  93914. }
  93915. declare module BABYLON {
  93916. /** @hidden */
  93917. export var lightUboDeclaration: {
  93918. name: string;
  93919. shader: string;
  93920. };
  93921. }
  93922. declare module BABYLON {
  93923. /** @hidden */
  93924. export var lightsFragmentFunctions: {
  93925. name: string;
  93926. shader: string;
  93927. };
  93928. }
  93929. declare module BABYLON {
  93930. /** @hidden */
  93931. export var shadowsFragmentFunctions: {
  93932. name: string;
  93933. shader: string;
  93934. };
  93935. }
  93936. declare module BABYLON {
  93937. /** @hidden */
  93938. export var fresnelFunction: {
  93939. name: string;
  93940. shader: string;
  93941. };
  93942. }
  93943. declare module BABYLON {
  93944. /** @hidden */
  93945. export var reflectionFunction: {
  93946. name: string;
  93947. shader: string;
  93948. };
  93949. }
  93950. declare module BABYLON {
  93951. /** @hidden */
  93952. export var bumpFragmentFunctions: {
  93953. name: string;
  93954. shader: string;
  93955. };
  93956. }
  93957. declare module BABYLON {
  93958. /** @hidden */
  93959. export var logDepthDeclaration: {
  93960. name: string;
  93961. shader: string;
  93962. };
  93963. }
  93964. declare module BABYLON {
  93965. /** @hidden */
  93966. export var bumpFragment: {
  93967. name: string;
  93968. shader: string;
  93969. };
  93970. }
  93971. declare module BABYLON {
  93972. /** @hidden */
  93973. export var depthPrePass: {
  93974. name: string;
  93975. shader: string;
  93976. };
  93977. }
  93978. declare module BABYLON {
  93979. /** @hidden */
  93980. export var lightFragment: {
  93981. name: string;
  93982. shader: string;
  93983. };
  93984. }
  93985. declare module BABYLON {
  93986. /** @hidden */
  93987. export var logDepthFragment: {
  93988. name: string;
  93989. shader: string;
  93990. };
  93991. }
  93992. declare module BABYLON {
  93993. /** @hidden */
  93994. export var defaultPixelShader: {
  93995. name: string;
  93996. shader: string;
  93997. };
  93998. }
  93999. declare module BABYLON {
  94000. /** @hidden */
  94001. export var defaultVertexDeclaration: {
  94002. name: string;
  94003. shader: string;
  94004. };
  94005. }
  94006. declare module BABYLON {
  94007. /** @hidden */
  94008. export var bumpVertexDeclaration: {
  94009. name: string;
  94010. shader: string;
  94011. };
  94012. }
  94013. declare module BABYLON {
  94014. /** @hidden */
  94015. export var bumpVertex: {
  94016. name: string;
  94017. shader: string;
  94018. };
  94019. }
  94020. declare module BABYLON {
  94021. /** @hidden */
  94022. export var fogVertex: {
  94023. name: string;
  94024. shader: string;
  94025. };
  94026. }
  94027. declare module BABYLON {
  94028. /** @hidden */
  94029. export var shadowsVertex: {
  94030. name: string;
  94031. shader: string;
  94032. };
  94033. }
  94034. declare module BABYLON {
  94035. /** @hidden */
  94036. export var pointCloudVertex: {
  94037. name: string;
  94038. shader: string;
  94039. };
  94040. }
  94041. declare module BABYLON {
  94042. /** @hidden */
  94043. export var logDepthVertex: {
  94044. name: string;
  94045. shader: string;
  94046. };
  94047. }
  94048. declare module BABYLON {
  94049. /** @hidden */
  94050. export var defaultVertexShader: {
  94051. name: string;
  94052. shader: string;
  94053. };
  94054. }
  94055. declare module BABYLON {
  94056. /** @hidden */
  94057. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94058. MAINUV1: boolean;
  94059. MAINUV2: boolean;
  94060. DIFFUSE: boolean;
  94061. DIFFUSEDIRECTUV: number;
  94062. AMBIENT: boolean;
  94063. AMBIENTDIRECTUV: number;
  94064. OPACITY: boolean;
  94065. OPACITYDIRECTUV: number;
  94066. OPACITYRGB: boolean;
  94067. REFLECTION: boolean;
  94068. EMISSIVE: boolean;
  94069. EMISSIVEDIRECTUV: number;
  94070. SPECULAR: boolean;
  94071. SPECULARDIRECTUV: number;
  94072. BUMP: boolean;
  94073. BUMPDIRECTUV: number;
  94074. PARALLAX: boolean;
  94075. PARALLAXOCCLUSION: boolean;
  94076. SPECULAROVERALPHA: boolean;
  94077. CLIPPLANE: boolean;
  94078. CLIPPLANE2: boolean;
  94079. CLIPPLANE3: boolean;
  94080. CLIPPLANE4: boolean;
  94081. ALPHATEST: boolean;
  94082. DEPTHPREPASS: boolean;
  94083. ALPHAFROMDIFFUSE: boolean;
  94084. POINTSIZE: boolean;
  94085. FOG: boolean;
  94086. SPECULARTERM: boolean;
  94087. DIFFUSEFRESNEL: boolean;
  94088. OPACITYFRESNEL: boolean;
  94089. REFLECTIONFRESNEL: boolean;
  94090. REFRACTIONFRESNEL: boolean;
  94091. EMISSIVEFRESNEL: boolean;
  94092. FRESNEL: boolean;
  94093. NORMAL: boolean;
  94094. UV1: boolean;
  94095. UV2: boolean;
  94096. VERTEXCOLOR: boolean;
  94097. VERTEXALPHA: boolean;
  94098. NUM_BONE_INFLUENCERS: number;
  94099. BonesPerMesh: number;
  94100. BONETEXTURE: boolean;
  94101. INSTANCES: boolean;
  94102. GLOSSINESS: boolean;
  94103. ROUGHNESS: boolean;
  94104. EMISSIVEASILLUMINATION: boolean;
  94105. LINKEMISSIVEWITHDIFFUSE: boolean;
  94106. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94107. LIGHTMAP: boolean;
  94108. LIGHTMAPDIRECTUV: number;
  94109. OBJECTSPACE_NORMALMAP: boolean;
  94110. USELIGHTMAPASSHADOWMAP: boolean;
  94111. REFLECTIONMAP_3D: boolean;
  94112. REFLECTIONMAP_SPHERICAL: boolean;
  94113. REFLECTIONMAP_PLANAR: boolean;
  94114. REFLECTIONMAP_CUBIC: boolean;
  94115. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94116. REFLECTIONMAP_PROJECTION: boolean;
  94117. REFLECTIONMAP_SKYBOX: boolean;
  94118. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94119. REFLECTIONMAP_EXPLICIT: boolean;
  94120. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94121. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94122. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94123. INVERTCUBICMAP: boolean;
  94124. LOGARITHMICDEPTH: boolean;
  94125. REFRACTION: boolean;
  94126. REFRACTIONMAP_3D: boolean;
  94127. REFLECTIONOVERALPHA: boolean;
  94128. TWOSIDEDLIGHTING: boolean;
  94129. SHADOWFLOAT: boolean;
  94130. MORPHTARGETS: boolean;
  94131. MORPHTARGETS_NORMAL: boolean;
  94132. MORPHTARGETS_TANGENT: boolean;
  94133. NUM_MORPH_INFLUENCERS: number;
  94134. NONUNIFORMSCALING: boolean;
  94135. PREMULTIPLYALPHA: boolean;
  94136. IMAGEPROCESSING: boolean;
  94137. VIGNETTE: boolean;
  94138. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94139. VIGNETTEBLENDMODEOPAQUE: boolean;
  94140. TONEMAPPING: boolean;
  94141. TONEMAPPING_ACES: boolean;
  94142. CONTRAST: boolean;
  94143. COLORCURVES: boolean;
  94144. COLORGRADING: boolean;
  94145. COLORGRADING3D: boolean;
  94146. SAMPLER3DGREENDEPTH: boolean;
  94147. SAMPLER3DBGRMAP: boolean;
  94148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94149. /**
  94150. * If the reflection texture on this material is in linear color space
  94151. * @hidden
  94152. */
  94153. IS_REFLECTION_LINEAR: boolean;
  94154. /**
  94155. * If the refraction texture on this material is in linear color space
  94156. * @hidden
  94157. */
  94158. IS_REFRACTION_LINEAR: boolean;
  94159. EXPOSURE: boolean;
  94160. constructor();
  94161. setReflectionMode(modeToEnable: string): void;
  94162. }
  94163. /**
  94164. * This is the default material used in Babylon. It is the best trade off between quality
  94165. * and performances.
  94166. * @see http://doc.babylonjs.com/babylon101/materials
  94167. */
  94168. export class StandardMaterial extends PushMaterial {
  94169. private _diffuseTexture;
  94170. /**
  94171. * The basic texture of the material as viewed under a light.
  94172. */
  94173. diffuseTexture: Nullable<BaseTexture>;
  94174. private _ambientTexture;
  94175. /**
  94176. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94177. */
  94178. ambientTexture: Nullable<BaseTexture>;
  94179. private _opacityTexture;
  94180. /**
  94181. * Define the transparency of the material from a texture.
  94182. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94183. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94184. */
  94185. opacityTexture: Nullable<BaseTexture>;
  94186. private _reflectionTexture;
  94187. /**
  94188. * Define the texture used to display the reflection.
  94189. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94190. */
  94191. reflectionTexture: Nullable<BaseTexture>;
  94192. private _emissiveTexture;
  94193. /**
  94194. * Define texture of the material as if self lit.
  94195. * This will be mixed in the final result even in the absence of light.
  94196. */
  94197. emissiveTexture: Nullable<BaseTexture>;
  94198. private _specularTexture;
  94199. /**
  94200. * Define how the color and intensity of the highlight given by the light in the material.
  94201. */
  94202. specularTexture: Nullable<BaseTexture>;
  94203. private _bumpTexture;
  94204. /**
  94205. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94206. * 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.
  94207. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94208. */
  94209. bumpTexture: Nullable<BaseTexture>;
  94210. private _lightmapTexture;
  94211. /**
  94212. * Complex lighting can be computationally expensive to compute at runtime.
  94213. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94214. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94215. */
  94216. lightmapTexture: Nullable<BaseTexture>;
  94217. private _refractionTexture;
  94218. /**
  94219. * Define the texture used to display the refraction.
  94220. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94221. */
  94222. refractionTexture: Nullable<BaseTexture>;
  94223. /**
  94224. * The color of the material lit by the environmental background lighting.
  94225. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94226. */
  94227. ambientColor: Color3;
  94228. /**
  94229. * The basic color of the material as viewed under a light.
  94230. */
  94231. diffuseColor: Color3;
  94232. /**
  94233. * Define how the color and intensity of the highlight given by the light in the material.
  94234. */
  94235. specularColor: Color3;
  94236. /**
  94237. * Define the color of the material as if self lit.
  94238. * This will be mixed in the final result even in the absence of light.
  94239. */
  94240. emissiveColor: Color3;
  94241. /**
  94242. * Defines how sharp are the highlights in the material.
  94243. * The bigger the value the sharper giving a more glossy feeling to the result.
  94244. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94245. */
  94246. specularPower: number;
  94247. private _useAlphaFromDiffuseTexture;
  94248. /**
  94249. * Does the transparency come from the diffuse texture alpha channel.
  94250. */
  94251. useAlphaFromDiffuseTexture: boolean;
  94252. private _useEmissiveAsIllumination;
  94253. /**
  94254. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94255. */
  94256. useEmissiveAsIllumination: boolean;
  94257. private _linkEmissiveWithDiffuse;
  94258. /**
  94259. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94260. * the emissive level when the final color is close to one.
  94261. */
  94262. linkEmissiveWithDiffuse: boolean;
  94263. private _useSpecularOverAlpha;
  94264. /**
  94265. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94266. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94267. */
  94268. useSpecularOverAlpha: boolean;
  94269. private _useReflectionOverAlpha;
  94270. /**
  94271. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94272. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94273. */
  94274. useReflectionOverAlpha: boolean;
  94275. private _disableLighting;
  94276. /**
  94277. * Does lights from the scene impacts this material.
  94278. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94279. */
  94280. disableLighting: boolean;
  94281. private _useObjectSpaceNormalMap;
  94282. /**
  94283. * Allows using an object space normal map (instead of tangent space).
  94284. */
  94285. useObjectSpaceNormalMap: boolean;
  94286. private _useParallax;
  94287. /**
  94288. * Is parallax enabled or not.
  94289. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94290. */
  94291. useParallax: boolean;
  94292. private _useParallaxOcclusion;
  94293. /**
  94294. * Is parallax occlusion enabled or not.
  94295. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  94296. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94297. */
  94298. useParallaxOcclusion: boolean;
  94299. /**
  94300. * 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.
  94301. */
  94302. parallaxScaleBias: number;
  94303. private _roughness;
  94304. /**
  94305. * Helps to define how blurry the reflections should appears in the material.
  94306. */
  94307. roughness: number;
  94308. /**
  94309. * In case of refraction, define the value of the indice of refraction.
  94310. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94311. */
  94312. indexOfRefraction: number;
  94313. /**
  94314. * Invert the refraction texture alongside the y axis.
  94315. * It can be useful with procedural textures or probe for instance.
  94316. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94317. */
  94318. invertRefractionY: boolean;
  94319. /**
  94320. * Defines the alpha limits in alpha test mode.
  94321. */
  94322. alphaCutOff: number;
  94323. private _useLightmapAsShadowmap;
  94324. /**
  94325. * In case of light mapping, define whether the map contains light or shadow informations.
  94326. */
  94327. useLightmapAsShadowmap: boolean;
  94328. private _diffuseFresnelParameters;
  94329. /**
  94330. * Define the diffuse fresnel parameters of the material.
  94331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94332. */
  94333. diffuseFresnelParameters: FresnelParameters;
  94334. private _opacityFresnelParameters;
  94335. /**
  94336. * Define the opacity fresnel parameters of the material.
  94337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94338. */
  94339. opacityFresnelParameters: FresnelParameters;
  94340. private _reflectionFresnelParameters;
  94341. /**
  94342. * Define the reflection fresnel parameters of the material.
  94343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94344. */
  94345. reflectionFresnelParameters: FresnelParameters;
  94346. private _refractionFresnelParameters;
  94347. /**
  94348. * Define the refraction fresnel parameters of the material.
  94349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94350. */
  94351. refractionFresnelParameters: FresnelParameters;
  94352. private _emissiveFresnelParameters;
  94353. /**
  94354. * Define the emissive fresnel parameters of the material.
  94355. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94356. */
  94357. emissiveFresnelParameters: FresnelParameters;
  94358. private _useReflectionFresnelFromSpecular;
  94359. /**
  94360. * If true automatically deducts the fresnels values from the material specularity.
  94361. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94362. */
  94363. useReflectionFresnelFromSpecular: boolean;
  94364. private _useGlossinessFromSpecularMapAlpha;
  94365. /**
  94366. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94367. */
  94368. useGlossinessFromSpecularMapAlpha: boolean;
  94369. private _maxSimultaneousLights;
  94370. /**
  94371. * Defines the maximum number of lights that can be used in the material
  94372. */
  94373. maxSimultaneousLights: number;
  94374. private _invertNormalMapX;
  94375. /**
  94376. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94377. */
  94378. invertNormalMapX: boolean;
  94379. private _invertNormalMapY;
  94380. /**
  94381. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94382. */
  94383. invertNormalMapY: boolean;
  94384. private _twoSidedLighting;
  94385. /**
  94386. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94387. */
  94388. twoSidedLighting: boolean;
  94389. /**
  94390. * Default configuration related to image processing available in the standard Material.
  94391. */
  94392. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94393. /**
  94394. * Gets the image processing configuration used either in this material.
  94395. */
  94396. /**
  94397. * Sets the Default image processing configuration used either in the this material.
  94398. *
  94399. * If sets to null, the scene one is in use.
  94400. */
  94401. imageProcessingConfiguration: ImageProcessingConfiguration;
  94402. /**
  94403. * Keep track of the image processing observer to allow dispose and replace.
  94404. */
  94405. private _imageProcessingObserver;
  94406. /**
  94407. * Attaches a new image processing configuration to the Standard Material.
  94408. * @param configuration
  94409. */
  94410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94411. /**
  94412. * Gets wether the color curves effect is enabled.
  94413. */
  94414. /**
  94415. * Sets wether the color curves effect is enabled.
  94416. */
  94417. cameraColorCurvesEnabled: boolean;
  94418. /**
  94419. * Gets wether the color grading effect is enabled.
  94420. */
  94421. /**
  94422. * Gets wether the color grading effect is enabled.
  94423. */
  94424. cameraColorGradingEnabled: boolean;
  94425. /**
  94426. * Gets wether tonemapping is enabled or not.
  94427. */
  94428. /**
  94429. * Sets wether tonemapping is enabled or not
  94430. */
  94431. cameraToneMappingEnabled: boolean;
  94432. /**
  94433. * The camera exposure used on this material.
  94434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94435. * This corresponds to a photographic exposure.
  94436. */
  94437. /**
  94438. * The camera exposure used on this material.
  94439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94440. * This corresponds to a photographic exposure.
  94441. */
  94442. cameraExposure: number;
  94443. /**
  94444. * Gets The camera contrast used on this material.
  94445. */
  94446. /**
  94447. * Sets The camera contrast used on this material.
  94448. */
  94449. cameraContrast: number;
  94450. /**
  94451. * Gets the Color Grading 2D Lookup Texture.
  94452. */
  94453. /**
  94454. * Sets the Color Grading 2D Lookup Texture.
  94455. */
  94456. cameraColorGradingTexture: Nullable<BaseTexture>;
  94457. /**
  94458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94460. * 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;
  94461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94462. */
  94463. /**
  94464. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94465. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94466. * 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;
  94467. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94468. */
  94469. cameraColorCurves: Nullable<ColorCurves>;
  94470. /**
  94471. * Custom callback helping to override the default shader used in the material.
  94472. */
  94473. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94474. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94475. protected _worldViewProjectionMatrix: Matrix;
  94476. protected _globalAmbientColor: Color3;
  94477. protected _useLogarithmicDepth: boolean;
  94478. /**
  94479. * Instantiates a new standard material.
  94480. * This is the default material used in Babylon. It is the best trade off between quality
  94481. * and performances.
  94482. * @see http://doc.babylonjs.com/babylon101/materials
  94483. * @param name Define the name of the material in the scene
  94484. * @param scene Define the scene the material belong to
  94485. */
  94486. constructor(name: string, scene: Scene);
  94487. /**
  94488. * Gets a boolean indicating that current material needs to register RTT
  94489. */
  94490. readonly hasRenderTargetTextures: boolean;
  94491. /**
  94492. * Gets the current class name of the material e.g. "StandardMaterial"
  94493. * Mainly use in serialization.
  94494. * @returns the class name
  94495. */
  94496. getClassName(): string;
  94497. /**
  94498. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94499. * You can try switching to logarithmic depth.
  94500. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94501. */
  94502. useLogarithmicDepth: boolean;
  94503. /**
  94504. * Specifies if the material will require alpha blending
  94505. * @returns a boolean specifying if alpha blending is needed
  94506. */
  94507. needAlphaBlending(): boolean;
  94508. /**
  94509. * Specifies if this material should be rendered in alpha test mode
  94510. * @returns a boolean specifying if an alpha test is needed.
  94511. */
  94512. needAlphaTesting(): boolean;
  94513. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94514. /**
  94515. * Get the texture used for alpha test purpose.
  94516. * @returns the diffuse texture in case of the standard material.
  94517. */
  94518. getAlphaTestTexture(): Nullable<BaseTexture>;
  94519. /**
  94520. * Get if the submesh is ready to be used and all its information available.
  94521. * Child classes can use it to update shaders
  94522. * @param mesh defines the mesh to check
  94523. * @param subMesh defines which submesh to check
  94524. * @param useInstances specifies that instances should be used
  94525. * @returns a boolean indicating that the submesh is ready or not
  94526. */
  94527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94528. /**
  94529. * Builds the material UBO layouts.
  94530. * Used internally during the effect preparation.
  94531. */
  94532. buildUniformLayout(): void;
  94533. /**
  94534. * Unbinds the material from the mesh
  94535. */
  94536. unbind(): void;
  94537. /**
  94538. * Binds the submesh to this material by preparing the effect and shader to draw
  94539. * @param world defines the world transformation matrix
  94540. * @param mesh defines the mesh containing the submesh
  94541. * @param subMesh defines the submesh to bind the material to
  94542. */
  94543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94544. /**
  94545. * Get the list of animatables in the material.
  94546. * @returns the list of animatables object used in the material
  94547. */
  94548. getAnimatables(): IAnimatable[];
  94549. /**
  94550. * Gets the active textures from the material
  94551. * @returns an array of textures
  94552. */
  94553. getActiveTextures(): BaseTexture[];
  94554. /**
  94555. * Specifies if the material uses a texture
  94556. * @param texture defines the texture to check against the material
  94557. * @returns a boolean specifying if the material uses the texture
  94558. */
  94559. hasTexture(texture: BaseTexture): boolean;
  94560. /**
  94561. * Disposes the material
  94562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94564. */
  94565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94566. /**
  94567. * Makes a duplicate of the material, and gives it a new name
  94568. * @param name defines the new name for the duplicated material
  94569. * @returns the cloned material
  94570. */
  94571. clone(name: string): StandardMaterial;
  94572. /**
  94573. * Serializes this material in a JSON representation
  94574. * @returns the serialized material object
  94575. */
  94576. serialize(): any;
  94577. /**
  94578. * Creates a standard material from parsed material data
  94579. * @param source defines the JSON representation of the material
  94580. * @param scene defines the hosting scene
  94581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94582. * @returns a new standard material
  94583. */
  94584. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94585. /**
  94586. * Are diffuse textures enabled in the application.
  94587. */
  94588. static DiffuseTextureEnabled: boolean;
  94589. /**
  94590. * Are ambient textures enabled in the application.
  94591. */
  94592. static AmbientTextureEnabled: boolean;
  94593. /**
  94594. * Are opacity textures enabled in the application.
  94595. */
  94596. static OpacityTextureEnabled: boolean;
  94597. /**
  94598. * Are reflection textures enabled in the application.
  94599. */
  94600. static ReflectionTextureEnabled: boolean;
  94601. /**
  94602. * Are emissive textures enabled in the application.
  94603. */
  94604. static EmissiveTextureEnabled: boolean;
  94605. /**
  94606. * Are specular textures enabled in the application.
  94607. */
  94608. static SpecularTextureEnabled: boolean;
  94609. /**
  94610. * Are bump textures enabled in the application.
  94611. */
  94612. static BumpTextureEnabled: boolean;
  94613. /**
  94614. * Are lightmap textures enabled in the application.
  94615. */
  94616. static LightmapTextureEnabled: boolean;
  94617. /**
  94618. * Are refraction textures enabled in the application.
  94619. */
  94620. static RefractionTextureEnabled: boolean;
  94621. /**
  94622. * Are color grading textures enabled in the application.
  94623. */
  94624. static ColorGradingTextureEnabled: boolean;
  94625. /**
  94626. * Are fresnels enabled in the application.
  94627. */
  94628. static FresnelEnabled: boolean;
  94629. }
  94630. }
  94631. declare module BABYLON {
  94632. /**
  94633. * A class extending Texture allowing drawing on a texture
  94634. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94635. */
  94636. export class DynamicTexture extends Texture {
  94637. private _generateMipMaps;
  94638. private _canvas;
  94639. private _context;
  94640. private _engine;
  94641. /**
  94642. * Creates a DynamicTexture
  94643. * @param name defines the name of the texture
  94644. * @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
  94645. * @param scene defines the scene where you want the texture
  94646. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94647. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94648. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94649. */
  94650. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94651. /**
  94652. * Get the current class name of the texture useful for serialization or dynamic coding.
  94653. * @returns "DynamicTexture"
  94654. */
  94655. getClassName(): string;
  94656. /**
  94657. * Gets the current state of canRescale
  94658. */
  94659. readonly canRescale: boolean;
  94660. private _recreate;
  94661. /**
  94662. * Scales the texture
  94663. * @param ratio the scale factor to apply to both width and height
  94664. */
  94665. scale(ratio: number): void;
  94666. /**
  94667. * Resizes the texture
  94668. * @param width the new width
  94669. * @param height the new height
  94670. */
  94671. scaleTo(width: number, height: number): void;
  94672. /**
  94673. * Gets the context of the canvas used by the texture
  94674. * @returns the canvas context of the dynamic texture
  94675. */
  94676. getContext(): CanvasRenderingContext2D;
  94677. /**
  94678. * Clears the texture
  94679. */
  94680. clear(): void;
  94681. /**
  94682. * Updates the texture
  94683. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94684. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94685. */
  94686. update(invertY?: boolean, premulAlpha?: boolean): void;
  94687. /**
  94688. * Draws text onto the texture
  94689. * @param text defines the text to be drawn
  94690. * @param x defines the placement of the text from the left
  94691. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94692. * @param font defines the font to be used with font-style, font-size, font-name
  94693. * @param color defines the color used for the text
  94694. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94695. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94696. * @param update defines whether texture is immediately update (default is true)
  94697. */
  94698. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94699. /**
  94700. * Clones the texture
  94701. * @returns the clone of the texture.
  94702. */
  94703. clone(): DynamicTexture;
  94704. /**
  94705. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94706. * @returns a serialized dynamic texture object
  94707. */
  94708. serialize(): any;
  94709. /** @hidden */
  94710. _rebuild(): void;
  94711. }
  94712. }
  94713. declare module BABYLON {
  94714. /** @hidden */
  94715. export var imageProcessingPixelShader: {
  94716. name: string;
  94717. shader: string;
  94718. };
  94719. }
  94720. declare module BABYLON {
  94721. /**
  94722. * ImageProcessingPostProcess
  94723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94724. */
  94725. export class ImageProcessingPostProcess extends PostProcess {
  94726. /**
  94727. * Default configuration related to image processing available in the PBR Material.
  94728. */
  94729. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94730. /**
  94731. * Gets the image processing configuration used either in this material.
  94732. */
  94733. /**
  94734. * Sets the Default image processing configuration used either in the this material.
  94735. *
  94736. * If sets to null, the scene one is in use.
  94737. */
  94738. imageProcessingConfiguration: ImageProcessingConfiguration;
  94739. /**
  94740. * Keep track of the image processing observer to allow dispose and replace.
  94741. */
  94742. private _imageProcessingObserver;
  94743. /**
  94744. * Attaches a new image processing configuration to the PBR Material.
  94745. * @param configuration
  94746. */
  94747. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94748. /**
  94749. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94750. */
  94751. /**
  94752. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94753. */
  94754. colorCurves: Nullable<ColorCurves>;
  94755. /**
  94756. * Gets wether the color curves effect is enabled.
  94757. */
  94758. /**
  94759. * Sets wether the color curves effect is enabled.
  94760. */
  94761. colorCurvesEnabled: boolean;
  94762. /**
  94763. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94764. */
  94765. /**
  94766. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94767. */
  94768. colorGradingTexture: Nullable<BaseTexture>;
  94769. /**
  94770. * Gets wether the color grading effect is enabled.
  94771. */
  94772. /**
  94773. * Gets wether the color grading effect is enabled.
  94774. */
  94775. colorGradingEnabled: boolean;
  94776. /**
  94777. * Gets exposure used in the effect.
  94778. */
  94779. /**
  94780. * Sets exposure used in the effect.
  94781. */
  94782. exposure: number;
  94783. /**
  94784. * Gets wether tonemapping is enabled or not.
  94785. */
  94786. /**
  94787. * Sets wether tonemapping is enabled or not
  94788. */
  94789. toneMappingEnabled: boolean;
  94790. /**
  94791. * Gets contrast used in the effect.
  94792. */
  94793. /**
  94794. * Sets contrast used in the effect.
  94795. */
  94796. contrast: number;
  94797. /**
  94798. * Gets Vignette stretch size.
  94799. */
  94800. /**
  94801. * Sets Vignette stretch size.
  94802. */
  94803. vignetteStretch: number;
  94804. /**
  94805. * Gets Vignette centre X Offset.
  94806. */
  94807. /**
  94808. * Sets Vignette centre X Offset.
  94809. */
  94810. vignetteCentreX: number;
  94811. /**
  94812. * Gets Vignette centre Y Offset.
  94813. */
  94814. /**
  94815. * Sets Vignette centre Y Offset.
  94816. */
  94817. vignetteCentreY: number;
  94818. /**
  94819. * Gets Vignette weight or intensity of the vignette effect.
  94820. */
  94821. /**
  94822. * Sets Vignette weight or intensity of the vignette effect.
  94823. */
  94824. vignetteWeight: number;
  94825. /**
  94826. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94827. * if vignetteEnabled is set to true.
  94828. */
  94829. /**
  94830. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94831. * if vignetteEnabled is set to true.
  94832. */
  94833. vignetteColor: Color4;
  94834. /**
  94835. * Gets Camera field of view used by the Vignette effect.
  94836. */
  94837. /**
  94838. * Sets Camera field of view used by the Vignette effect.
  94839. */
  94840. vignetteCameraFov: number;
  94841. /**
  94842. * Gets the vignette blend mode allowing different kind of effect.
  94843. */
  94844. /**
  94845. * Sets the vignette blend mode allowing different kind of effect.
  94846. */
  94847. vignetteBlendMode: number;
  94848. /**
  94849. * Gets wether the vignette effect is enabled.
  94850. */
  94851. /**
  94852. * Sets wether the vignette effect is enabled.
  94853. */
  94854. vignetteEnabled: boolean;
  94855. private _fromLinearSpace;
  94856. /**
  94857. * Gets wether the input of the processing is in Gamma or Linear Space.
  94858. */
  94859. /**
  94860. * Sets wether the input of the processing is in Gamma or Linear Space.
  94861. */
  94862. fromLinearSpace: boolean;
  94863. /**
  94864. * Defines cache preventing GC.
  94865. */
  94866. private _defines;
  94867. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94868. /**
  94869. * "ImageProcessingPostProcess"
  94870. * @returns "ImageProcessingPostProcess"
  94871. */
  94872. getClassName(): string;
  94873. protected _updateParameters(): void;
  94874. dispose(camera?: Camera): void;
  94875. }
  94876. }
  94877. declare module BABYLON {
  94878. /**
  94879. * Class containing static functions to help procedurally build meshes
  94880. */
  94881. export class GroundBuilder {
  94882. /**
  94883. * Creates a ground mesh
  94884. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94885. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94887. * @param name defines the name of the mesh
  94888. * @param options defines the options used to create the mesh
  94889. * @param scene defines the hosting scene
  94890. * @returns the ground mesh
  94891. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94892. */
  94893. static CreateGround(name: string, options: {
  94894. width?: number;
  94895. height?: number;
  94896. subdivisions?: number;
  94897. subdivisionsX?: number;
  94898. subdivisionsY?: number;
  94899. updatable?: boolean;
  94900. }, scene: any): Mesh;
  94901. /**
  94902. * Creates a tiled ground mesh
  94903. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94904. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94905. * * 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
  94906. * * 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
  94907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94908. * @param name defines the name of the mesh
  94909. * @param options defines the options used to create the mesh
  94910. * @param scene defines the hosting scene
  94911. * @returns the tiled ground mesh
  94912. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94913. */
  94914. static CreateTiledGround(name: string, options: {
  94915. xmin: number;
  94916. zmin: number;
  94917. xmax: number;
  94918. zmax: number;
  94919. subdivisions?: {
  94920. w: number;
  94921. h: number;
  94922. };
  94923. precision?: {
  94924. w: number;
  94925. h: number;
  94926. };
  94927. updatable?: boolean;
  94928. }, scene: Scene): Mesh;
  94929. /**
  94930. * Creates a ground mesh from a height map
  94931. * * The parameter `url` sets the URL of the height map image resource.
  94932. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94933. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94934. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94935. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94936. * * 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.
  94937. * * 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).
  94938. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94940. * @param name defines the name of the mesh
  94941. * @param url defines the url to the height map
  94942. * @param options defines the options used to create the mesh
  94943. * @param scene defines the hosting scene
  94944. * @returns the ground mesh
  94945. * @see https://doc.babylonjs.com/babylon101/height_map
  94946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94947. */
  94948. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94949. width?: number;
  94950. height?: number;
  94951. subdivisions?: number;
  94952. minHeight?: number;
  94953. maxHeight?: number;
  94954. colorFilter?: Color3;
  94955. alphaFilter?: number;
  94956. updatable?: boolean;
  94957. onReady?: (mesh: GroundMesh) => void;
  94958. }, scene: Scene): GroundMesh;
  94959. }
  94960. }
  94961. declare module BABYLON {
  94962. /**
  94963. * Class containing static functions to help procedurally build meshes
  94964. */
  94965. export class TorusBuilder {
  94966. /**
  94967. * Creates a torus mesh
  94968. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94969. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94970. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94974. * @param name defines the name of the mesh
  94975. * @param options defines the options used to create the mesh
  94976. * @param scene defines the hosting scene
  94977. * @returns the torus mesh
  94978. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94979. */
  94980. static CreateTorus(name: string, options: {
  94981. diameter?: number;
  94982. thickness?: number;
  94983. tessellation?: number;
  94984. updatable?: boolean;
  94985. sideOrientation?: number;
  94986. frontUVs?: Vector4;
  94987. backUVs?: Vector4;
  94988. }, scene: any): Mesh;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * Class containing static functions to help procedurally build meshes
  94994. */
  94995. export class CylinderBuilder {
  94996. /**
  94997. * Creates a cylinder or a cone mesh
  94998. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94999. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95000. * * 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.
  95001. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95002. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95003. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95004. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95005. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95006. * * 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).
  95007. * * 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
  95008. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95009. * * 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
  95010. * * 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.
  95011. * * If `enclose` is false, a ring surface is one element.
  95012. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95013. * * 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
  95014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95017. * @param name defines the name of the mesh
  95018. * @param options defines the options used to create the mesh
  95019. * @param scene defines the hosting scene
  95020. * @returns the cylinder mesh
  95021. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95022. */
  95023. static CreateCylinder(name: string, options: {
  95024. height?: number;
  95025. diameterTop?: number;
  95026. diameterBottom?: number;
  95027. diameter?: number;
  95028. tessellation?: number;
  95029. subdivisions?: number;
  95030. arc?: number;
  95031. faceColors?: Color4[];
  95032. faceUV?: Vector4[];
  95033. updatable?: boolean;
  95034. hasRings?: boolean;
  95035. enclose?: boolean;
  95036. sideOrientation?: number;
  95037. frontUVs?: Vector4;
  95038. backUVs?: Vector4;
  95039. }, scene: any): Mesh;
  95040. }
  95041. }
  95042. declare module BABYLON {
  95043. /**
  95044. * Manager for handling gamepads
  95045. */
  95046. export class GamepadManager {
  95047. private _scene?;
  95048. private _babylonGamepads;
  95049. private _oneGamepadConnected;
  95050. /** @hidden */
  95051. _isMonitoring: boolean;
  95052. private _gamepadEventSupported;
  95053. private _gamepadSupport;
  95054. /**
  95055. * observable to be triggered when the gamepad controller has been connected
  95056. */
  95057. onGamepadConnectedObservable: Observable<Gamepad>;
  95058. /**
  95059. * observable to be triggered when the gamepad controller has been disconnected
  95060. */
  95061. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95062. private _onGamepadConnectedEvent;
  95063. private _onGamepadDisconnectedEvent;
  95064. /**
  95065. * Initializes the gamepad manager
  95066. * @param _scene BabylonJS scene
  95067. */
  95068. constructor(_scene?: Scene | undefined);
  95069. /**
  95070. * The gamepads in the game pad manager
  95071. */
  95072. readonly gamepads: Gamepad[];
  95073. /**
  95074. * Get the gamepad controllers based on type
  95075. * @param type The type of gamepad controller
  95076. * @returns Nullable gamepad
  95077. */
  95078. getGamepadByType(type?: number): Nullable<Gamepad>;
  95079. /**
  95080. * Disposes the gamepad manager
  95081. */
  95082. dispose(): void;
  95083. private _addNewGamepad;
  95084. private _startMonitoringGamepads;
  95085. private _stopMonitoringGamepads;
  95086. /** @hidden */
  95087. _checkGamepadsStatus(): void;
  95088. private _updateGamepadObjects;
  95089. }
  95090. }
  95091. declare module BABYLON {
  95092. interface Scene {
  95093. /** @hidden */
  95094. _gamepadManager: Nullable<GamepadManager>;
  95095. /**
  95096. * Gets the gamepad manager associated with the scene
  95097. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  95098. */
  95099. gamepadManager: GamepadManager;
  95100. }
  95101. /**
  95102. * Interface representing a free camera inputs manager
  95103. */
  95104. interface FreeCameraInputsManager {
  95105. /**
  95106. * Adds gamepad input support to the FreeCameraInputsManager.
  95107. * @returns the FreeCameraInputsManager
  95108. */
  95109. addGamepad(): FreeCameraInputsManager;
  95110. }
  95111. /**
  95112. * Interface representing an arc rotate camera inputs manager
  95113. */
  95114. interface ArcRotateCameraInputsManager {
  95115. /**
  95116. * Adds gamepad input support to the ArcRotateCamera InputManager.
  95117. * @returns the camera inputs manager
  95118. */
  95119. addGamepad(): ArcRotateCameraInputsManager;
  95120. }
  95121. /**
  95122. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  95123. */
  95124. export class GamepadSystemSceneComponent implements ISceneComponent {
  95125. /**
  95126. * The component name helpfull to identify the component in the list of scene components.
  95127. */
  95128. readonly name: string;
  95129. /**
  95130. * The scene the component belongs to.
  95131. */
  95132. scene: Scene;
  95133. /**
  95134. * Creates a new instance of the component for the given scene
  95135. * @param scene Defines the scene to register the component in
  95136. */
  95137. constructor(scene: Scene);
  95138. /**
  95139. * Registers the component in a given scene
  95140. */
  95141. register(): void;
  95142. /**
  95143. * Rebuilds the elements related to this component in case of
  95144. * context lost for instance.
  95145. */
  95146. rebuild(): void;
  95147. /**
  95148. * Disposes the component and the associated ressources
  95149. */
  95150. dispose(): void;
  95151. private _beforeCameraUpdate;
  95152. }
  95153. }
  95154. declare module BABYLON {
  95155. /**
  95156. * Options to modify the vr teleportation behavior.
  95157. */
  95158. export interface VRTeleportationOptions {
  95159. /**
  95160. * The name of the mesh which should be used as the teleportation floor. (default: null)
  95161. */
  95162. floorMeshName?: string;
  95163. /**
  95164. * A list of meshes to be used as the teleportation floor. (default: empty)
  95165. */
  95166. floorMeshes?: Mesh[];
  95167. }
  95168. /**
  95169. * Options to modify the vr experience helper's behavior.
  95170. */
  95171. export interface VRExperienceHelperOptions extends WebVROptions {
  95172. /**
  95173. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  95174. */
  95175. createDeviceOrientationCamera?: boolean;
  95176. /**
  95177. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  95178. */
  95179. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  95180. /**
  95181. * Uses the main button on the controller to toggle the laser casted. (default: true)
  95182. */
  95183. laserToggle?: boolean;
  95184. /**
  95185. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  95186. */
  95187. floorMeshes?: Mesh[];
  95188. /**
  95189. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  95190. */
  95191. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  95192. }
  95193. /**
  95194. * Helps to quickly add VR support to an existing scene.
  95195. * See http://doc.babylonjs.com/how_to/webvr_helper
  95196. */
  95197. export class VRExperienceHelper {
  95198. /** Options to modify the vr experience helper's behavior. */
  95199. webVROptions: VRExperienceHelperOptions;
  95200. private _scene;
  95201. private _position;
  95202. private _btnVR;
  95203. private _btnVRDisplayed;
  95204. private _webVRsupported;
  95205. private _webVRready;
  95206. private _webVRrequesting;
  95207. private _webVRpresenting;
  95208. private _hasEnteredVR;
  95209. private _fullscreenVRpresenting;
  95210. private _canvas;
  95211. private _webVRCamera;
  95212. private _vrDeviceOrientationCamera;
  95213. private _deviceOrientationCamera;
  95214. private _existingCamera;
  95215. private _onKeyDown;
  95216. private _onVrDisplayPresentChange;
  95217. private _onVRDisplayChanged;
  95218. private _onVRRequestPresentStart;
  95219. private _onVRRequestPresentComplete;
  95220. /**
  95221. * Observable raised when entering VR.
  95222. */
  95223. onEnteringVRObservable: Observable<VRExperienceHelper>;
  95224. /**
  95225. * Observable raised when exiting VR.
  95226. */
  95227. onExitingVRObservable: Observable<VRExperienceHelper>;
  95228. /**
  95229. * Observable raised when controller mesh is loaded.
  95230. */
  95231. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95232. /** Return this.onEnteringVRObservable
  95233. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  95234. */
  95235. readonly onEnteringVR: Observable<VRExperienceHelper>;
  95236. /** Return this.onExitingVRObservable
  95237. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  95238. */
  95239. readonly onExitingVR: Observable<VRExperienceHelper>;
  95240. /** Return this.onControllerMeshLoadedObservable
  95241. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  95242. */
  95243. readonly onControllerMeshLoaded: Observable<WebVRController>;
  95244. private _rayLength;
  95245. private _useCustomVRButton;
  95246. private _teleportationRequested;
  95247. private _teleportActive;
  95248. private _floorMeshName;
  95249. private _floorMeshesCollection;
  95250. private _rotationAllowed;
  95251. private _teleportBackwardsVector;
  95252. private _teleportationTarget;
  95253. private _isDefaultTeleportationTarget;
  95254. private _postProcessMove;
  95255. private _teleportationFillColor;
  95256. private _teleportationBorderColor;
  95257. private _rotationAngle;
  95258. private _haloCenter;
  95259. private _cameraGazer;
  95260. private _padSensibilityUp;
  95261. private _padSensibilityDown;
  95262. private _leftController;
  95263. private _rightController;
  95264. /**
  95265. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  95266. */
  95267. onNewMeshSelected: Observable<AbstractMesh>;
  95268. /**
  95269. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  95270. */
  95271. onNewMeshPicked: Observable<PickingInfo>;
  95272. private _circleEase;
  95273. /**
  95274. * Observable raised before camera teleportation
  95275. */
  95276. onBeforeCameraTeleport: Observable<Vector3>;
  95277. /**
  95278. * Observable raised after camera teleportation
  95279. */
  95280. onAfterCameraTeleport: Observable<Vector3>;
  95281. /**
  95282. * Observable raised when current selected mesh gets unselected
  95283. */
  95284. onSelectedMeshUnselected: Observable<AbstractMesh>;
  95285. private _raySelectionPredicate;
  95286. /**
  95287. * To be optionaly changed by user to define custom ray selection
  95288. */
  95289. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  95290. /**
  95291. * To be optionaly changed by user to define custom selection logic (after ray selection)
  95292. */
  95293. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  95294. /**
  95295. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  95296. */
  95297. teleportationEnabled: boolean;
  95298. private _defaultHeight;
  95299. private _teleportationInitialized;
  95300. private _interactionsEnabled;
  95301. private _interactionsRequested;
  95302. private _displayGaze;
  95303. private _displayLaserPointer;
  95304. /**
  95305. * The mesh used to display where the user is going to teleport.
  95306. */
  95307. /**
  95308. * Sets the mesh to be used to display where the user is going to teleport.
  95309. */
  95310. teleportationTarget: Mesh;
  95311. /**
  95312. * 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
  95313. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  95314. * See http://doc.babylonjs.com/resources/baking_transformations
  95315. */
  95316. gazeTrackerMesh: Mesh;
  95317. /**
  95318. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  95319. */
  95320. updateGazeTrackerScale: boolean;
  95321. /**
  95322. * If the gaze trackers color should be updated when selecting meshes
  95323. */
  95324. updateGazeTrackerColor: boolean;
  95325. /**
  95326. * The gaze tracking mesh corresponding to the left controller
  95327. */
  95328. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  95329. /**
  95330. * The gaze tracking mesh corresponding to the right controller
  95331. */
  95332. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  95333. /**
  95334. * If the ray of the gaze should be displayed.
  95335. */
  95336. /**
  95337. * Sets if the ray of the gaze should be displayed.
  95338. */
  95339. displayGaze: boolean;
  95340. /**
  95341. * If the ray of the LaserPointer should be displayed.
  95342. */
  95343. /**
  95344. * Sets if the ray of the LaserPointer should be displayed.
  95345. */
  95346. displayLaserPointer: boolean;
  95347. /**
  95348. * The deviceOrientationCamera used as the camera when not in VR.
  95349. */
  95350. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95351. /**
  95352. * Based on the current WebVR support, returns the current VR camera used.
  95353. */
  95354. readonly currentVRCamera: Nullable<Camera>;
  95355. /**
  95356. * The webVRCamera which is used when in VR.
  95357. */
  95358. readonly webVRCamera: WebVRFreeCamera;
  95359. /**
  95360. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95361. */
  95362. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95363. private readonly _teleportationRequestInitiated;
  95364. /**
  95365. * Defines wether or not Pointer lock should be requested when switching to
  95366. * full screen.
  95367. */
  95368. requestPointerLockOnFullScreen: boolean;
  95369. /**
  95370. * Instantiates a VRExperienceHelper.
  95371. * Helps to quickly add VR support to an existing scene.
  95372. * @param scene The scene the VRExperienceHelper belongs to.
  95373. * @param webVROptions Options to modify the vr experience helper's behavior.
  95374. */
  95375. constructor(scene: Scene,
  95376. /** Options to modify the vr experience helper's behavior. */
  95377. webVROptions?: VRExperienceHelperOptions);
  95378. private _onDefaultMeshLoaded;
  95379. private _onResize;
  95380. private _onFullscreenChange;
  95381. /**
  95382. * Gets a value indicating if we are currently in VR mode.
  95383. */
  95384. readonly isInVRMode: boolean;
  95385. private onVrDisplayPresentChange;
  95386. private onVRDisplayChanged;
  95387. private moveButtonToBottomRight;
  95388. private displayVRButton;
  95389. private updateButtonVisibility;
  95390. private _cachedAngularSensibility;
  95391. /**
  95392. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95393. * Otherwise, will use the fullscreen API.
  95394. */
  95395. enterVR(): void;
  95396. /**
  95397. * Attempt to exit VR, or fullscreen.
  95398. */
  95399. exitVR(): void;
  95400. /**
  95401. * The position of the vr experience helper.
  95402. */
  95403. /**
  95404. * Sets the position of the vr experience helper.
  95405. */
  95406. position: Vector3;
  95407. /**
  95408. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95409. */
  95410. enableInteractions(): void;
  95411. private readonly _noControllerIsActive;
  95412. private beforeRender;
  95413. private _isTeleportationFloor;
  95414. /**
  95415. * Adds a floor mesh to be used for teleportation.
  95416. * @param floorMesh the mesh to be used for teleportation.
  95417. */
  95418. addFloorMesh(floorMesh: Mesh): void;
  95419. /**
  95420. * Removes a floor mesh from being used for teleportation.
  95421. * @param floorMesh the mesh to be removed.
  95422. */
  95423. removeFloorMesh(floorMesh: Mesh): void;
  95424. /**
  95425. * Enables interactions and teleportation using the VR controllers and gaze.
  95426. * @param vrTeleportationOptions options to modify teleportation behavior.
  95427. */
  95428. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95429. private _onNewGamepadConnected;
  95430. private _tryEnableInteractionOnController;
  95431. private _onNewGamepadDisconnected;
  95432. private _enableInteractionOnController;
  95433. private _checkTeleportWithRay;
  95434. private _checkRotate;
  95435. private _checkTeleportBackwards;
  95436. private _enableTeleportationOnController;
  95437. private _createTeleportationCircles;
  95438. private _displayTeleportationTarget;
  95439. private _hideTeleportationTarget;
  95440. private _rotateCamera;
  95441. private _moveTeleportationSelectorTo;
  95442. private _workingVector;
  95443. private _workingQuaternion;
  95444. private _workingMatrix;
  95445. /**
  95446. * Teleports the users feet to the desired location
  95447. * @param location The location where the user's feet should be placed
  95448. */
  95449. teleportCamera(location: Vector3): void;
  95450. private _convertNormalToDirectionOfRay;
  95451. private _castRayAndSelectObject;
  95452. private _notifySelectedMeshUnselected;
  95453. /**
  95454. * Sets the color of the laser ray from the vr controllers.
  95455. * @param color new color for the ray.
  95456. */
  95457. changeLaserColor(color: Color3): void;
  95458. /**
  95459. * Sets the color of the ray from the vr headsets gaze.
  95460. * @param color new color for the ray.
  95461. */
  95462. changeGazeColor(color: Color3): void;
  95463. /**
  95464. * Exits VR and disposes of the vr experience helper
  95465. */
  95466. dispose(): void;
  95467. /**
  95468. * Gets the name of the VRExperienceHelper class
  95469. * @returns "VRExperienceHelper"
  95470. */
  95471. getClassName(): string;
  95472. }
  95473. }
  95474. declare module BABYLON {
  95475. /**
  95476. * Manages an XRSession
  95477. * @see https://doc.babylonjs.com/how_to/webxr
  95478. */
  95479. export class WebXRSessionManager implements IDisposable {
  95480. private scene;
  95481. /**
  95482. * Fires every time a new xrFrame arrives which can be used to update the camera
  95483. */
  95484. onXRFrameObservable: Observable<any>;
  95485. /**
  95486. * Fires when the xr session is ended either by the device or manually done
  95487. */
  95488. onXRSessionEnded: Observable<any>;
  95489. /** @hidden */
  95490. _xrSession: XRSession;
  95491. /** @hidden */
  95492. _frameOfReference: XRFrameOfReference;
  95493. /** @hidden */
  95494. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95495. /** @hidden */
  95496. _currentXRFrame: Nullable<XRFrame>;
  95497. private _xrNavigator;
  95498. private _xrDevice;
  95499. private _tmpMatrix;
  95500. /**
  95501. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95502. * @param scene The scene which the session should be created for
  95503. */
  95504. constructor(scene: Scene);
  95505. /**
  95506. * Initializes the manager
  95507. * After initialization enterXR can be called to start an XR session
  95508. * @returns Promise which resolves after it is initialized
  95509. */
  95510. initializeAsync(): Promise<void>;
  95511. /**
  95512. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95513. * @param sessionCreationOptions xr options to create the session with
  95514. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95515. * @returns Promise which resolves after it enters XR
  95516. */
  95517. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95518. /**
  95519. * Stops the xrSession and restores the renderloop
  95520. * @returns Promise which resolves after it exits XR
  95521. */
  95522. exitXRAsync(): Promise<void>;
  95523. /**
  95524. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95525. * @param ray ray to cast into the environment
  95526. * @returns Promise which resolves with a collision point in the environment if it exists
  95527. */
  95528. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95529. /**
  95530. * Checks if a session would be supported for the creation options specified
  95531. * @param options creation options to check if they are supported
  95532. * @returns true if supported
  95533. */
  95534. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95535. /**
  95536. * @hidden
  95537. * Converts the render layer of xrSession to a render target
  95538. * @param session session to create render target for
  95539. * @param scene scene the new render target should be created for
  95540. */
  95541. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95542. /**
  95543. * Disposes of the session manager
  95544. */
  95545. dispose(): void;
  95546. }
  95547. }
  95548. declare module BABYLON {
  95549. /**
  95550. * WebXR Camera which holds the views for the xrSession
  95551. * @see https://doc.babylonjs.com/how_to/webxr
  95552. */
  95553. export class WebXRCamera extends FreeCamera {
  95554. private static _TmpMatrix;
  95555. /**
  95556. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95557. * @param name the name of the camera
  95558. * @param scene the scene to add the camera to
  95559. */
  95560. constructor(name: string, scene: Scene);
  95561. private _updateNumberOfRigCameras;
  95562. /** @hidden */
  95563. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95564. /**
  95565. * Updates the cameras position from the current pose information of the XR session
  95566. * @param xrSessionManager the session containing pose information
  95567. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95568. */
  95569. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95570. }
  95571. }
  95572. declare module BABYLON {
  95573. /**
  95574. * States of the webXR experience
  95575. */
  95576. export enum WebXRState {
  95577. /**
  95578. * Transitioning to being in XR mode
  95579. */
  95580. ENTERING_XR = 0,
  95581. /**
  95582. * Transitioning to non XR mode
  95583. */
  95584. EXITING_XR = 1,
  95585. /**
  95586. * In XR mode and presenting
  95587. */
  95588. IN_XR = 2,
  95589. /**
  95590. * Not entered XR mode
  95591. */
  95592. NOT_IN_XR = 3
  95593. }
  95594. /**
  95595. * Helper class used to enable XR
  95596. * @see https://doc.babylonjs.com/how_to/webxr
  95597. */
  95598. export class WebXRExperienceHelper implements IDisposable {
  95599. private scene;
  95600. /**
  95601. * 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
  95602. */
  95603. container: AbstractMesh;
  95604. /**
  95605. * Camera used to render xr content
  95606. */
  95607. camera: WebXRCamera;
  95608. /**
  95609. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95610. */
  95611. state: WebXRState;
  95612. private _setState;
  95613. private static _TmpVector;
  95614. /**
  95615. * Fires when the state of the experience helper has changed
  95616. */
  95617. onStateChangedObservable: Observable<WebXRState>;
  95618. /** @hidden */
  95619. _sessionManager: WebXRSessionManager;
  95620. private _nonVRCamera;
  95621. private _originalSceneAutoClear;
  95622. private _supported;
  95623. /**
  95624. * Creates the experience helper
  95625. * @param scene the scene to attach the experience helper to
  95626. * @returns a promise for the experience helper
  95627. */
  95628. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95629. /**
  95630. * Creates a WebXRExperienceHelper
  95631. * @param scene The scene the helper should be created in
  95632. */
  95633. private constructor();
  95634. /**
  95635. * Exits XR mode and returns the scene to its original state
  95636. * @returns promise that resolves after xr mode has exited
  95637. */
  95638. exitXRAsync(): Promise<void>;
  95639. /**
  95640. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95641. * @param sessionCreationOptions options for the XR session
  95642. * @param frameOfReference frame of reference of the XR session
  95643. * @returns promise that resolves after xr mode has entered
  95644. */
  95645. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95646. /**
  95647. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95648. * @param ray ray to cast into the environment
  95649. * @returns Promise which resolves with a collision point in the environment if it exists
  95650. */
  95651. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95652. /**
  95653. * Updates the global position of the camera by moving the camera's container
  95654. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95655. * @param position The desired global position of the camera
  95656. */
  95657. setPositionOfCameraUsingContainer(position: Vector3): void;
  95658. /**
  95659. * Rotates the xr camera by rotating the camera's container around the camera's position
  95660. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95661. * @param rotation the desired quaternion rotation to apply to the camera
  95662. */
  95663. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95664. /**
  95665. * Checks if the creation options are supported by the xr session
  95666. * @param options creation options
  95667. * @returns true if supported
  95668. */
  95669. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95670. /**
  95671. * Disposes of the experience helper
  95672. */
  95673. dispose(): void;
  95674. }
  95675. }
  95676. declare module BABYLON {
  95677. /**
  95678. * Button which can be used to enter a different mode of XR
  95679. */
  95680. export class WebXREnterExitUIButton {
  95681. /** button element */
  95682. element: HTMLElement;
  95683. /** XR initialization options for the button */
  95684. initializationOptions: XRSessionCreationOptions;
  95685. /**
  95686. * Creates a WebXREnterExitUIButton
  95687. * @param element button element
  95688. * @param initializationOptions XR initialization options for the button
  95689. */
  95690. constructor(
  95691. /** button element */
  95692. element: HTMLElement,
  95693. /** XR initialization options for the button */
  95694. initializationOptions: XRSessionCreationOptions);
  95695. /**
  95696. * Overwritable function which can be used to update the button's visuals when the state changes
  95697. * @param activeButton the current active button in the UI
  95698. */
  95699. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95700. }
  95701. /**
  95702. * Options to create the webXR UI
  95703. */
  95704. export class WebXREnterExitUIOptions {
  95705. /**
  95706. * Context to enter xr with
  95707. */
  95708. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95709. /**
  95710. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95711. */
  95712. customButtons?: Array<WebXREnterExitUIButton>;
  95713. }
  95714. /**
  95715. * UI to allow the user to enter/exit XR mode
  95716. */
  95717. export class WebXREnterExitUI implements IDisposable {
  95718. private scene;
  95719. private _overlay;
  95720. private _buttons;
  95721. private _activeButton;
  95722. /**
  95723. * Fired every time the active button is changed.
  95724. *
  95725. * When xr is entered via a button that launches xr that button will be the callback parameter
  95726. *
  95727. * When exiting xr the callback parameter will be null)
  95728. */
  95729. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95730. /**
  95731. * Creates UI to allow the user to enter/exit XR mode
  95732. * @param scene the scene to add the ui to
  95733. * @param helper the xr experience helper to enter/exit xr with
  95734. * @param options options to configure the UI
  95735. * @returns the created ui
  95736. */
  95737. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95738. private constructor();
  95739. private _updateButtons;
  95740. /**
  95741. * Disposes of the object
  95742. */
  95743. dispose(): void;
  95744. }
  95745. }
  95746. declare module BABYLON {
  95747. /**
  95748. * Represents an XR input
  95749. */
  95750. export class WebXRController {
  95751. /**
  95752. * 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
  95753. */
  95754. grip?: AbstractMesh;
  95755. /**
  95756. * Pointer which can be used to select objects or attach a visible laser to
  95757. */
  95758. pointer: AbstractMesh;
  95759. /**
  95760. * Creates the controller
  95761. * @see https://doc.babylonjs.com/how_to/webxr
  95762. * @param scene the scene which the controller should be associated to
  95763. */
  95764. constructor(scene: Scene);
  95765. /**
  95766. * Disposes of the object
  95767. */
  95768. dispose(): void;
  95769. }
  95770. /**
  95771. * XR input used to track XR inputs such as controllers/rays
  95772. */
  95773. export class WebXRInput implements IDisposable {
  95774. private helper;
  95775. /**
  95776. * XR controllers being tracked
  95777. */
  95778. controllers: Array<WebXRController>;
  95779. private _tmpMatrix;
  95780. private _frameObserver;
  95781. /**
  95782. * Initializes the WebXRInput
  95783. * @param helper experience helper which the input should be created for
  95784. */
  95785. constructor(helper: WebXRExperienceHelper);
  95786. /**
  95787. * Disposes of the object
  95788. */
  95789. dispose(): void;
  95790. }
  95791. }
  95792. declare module BABYLON {
  95793. /**
  95794. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95795. */
  95796. export class WebXRManagedOutputCanvas implements IDisposable {
  95797. private _canvas;
  95798. /**
  95799. * xrpresent context of the canvas which can be used to display/mirror xr content
  95800. */
  95801. canvasContext: Nullable<WebGLRenderingContext>;
  95802. /**
  95803. * Initializes the canvas to be added/removed upon entering/exiting xr
  95804. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95805. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95806. */
  95807. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95808. /**
  95809. * Disposes of the object
  95810. */
  95811. dispose(): void;
  95812. private _setManagedOutputCanvas;
  95813. private _addCanvas;
  95814. private _removeCanvas;
  95815. }
  95816. }
  95817. declare module BABYLON {
  95818. /**
  95819. * Contains an array of blocks representing the octree
  95820. */
  95821. export interface IOctreeContainer<T> {
  95822. /**
  95823. * Blocks within the octree
  95824. */
  95825. blocks: Array<OctreeBlock<T>>;
  95826. }
  95827. /**
  95828. * Class used to store a cell in an octree
  95829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95830. */
  95831. export class OctreeBlock<T> {
  95832. /**
  95833. * Gets the content of the current block
  95834. */
  95835. entries: T[];
  95836. /**
  95837. * Gets the list of block children
  95838. */
  95839. blocks: Array<OctreeBlock<T>>;
  95840. private _depth;
  95841. private _maxDepth;
  95842. private _capacity;
  95843. private _minPoint;
  95844. private _maxPoint;
  95845. private _boundingVectors;
  95846. private _creationFunc;
  95847. /**
  95848. * Creates a new block
  95849. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95850. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95851. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95852. * @param depth defines the current depth of this block in the octree
  95853. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95854. * @param creationFunc defines a callback to call when an element is added to the block
  95855. */
  95856. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95857. /**
  95858. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95859. */
  95860. readonly capacity: number;
  95861. /**
  95862. * Gets the minimum vector (in world space) of the block's bounding box
  95863. */
  95864. readonly minPoint: Vector3;
  95865. /**
  95866. * Gets the maximum vector (in world space) of the block's bounding box
  95867. */
  95868. readonly maxPoint: Vector3;
  95869. /**
  95870. * Add a new element to this block
  95871. * @param entry defines the element to add
  95872. */
  95873. addEntry(entry: T): void;
  95874. /**
  95875. * Remove an element from this block
  95876. * @param entry defines the element to remove
  95877. */
  95878. removeEntry(entry: T): void;
  95879. /**
  95880. * Add an array of elements to this block
  95881. * @param entries defines the array of elements to add
  95882. */
  95883. addEntries(entries: T[]): void;
  95884. /**
  95885. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95886. * @param frustumPlanes defines the frustum planes to test
  95887. * @param selection defines the array to store current content if selection is positive
  95888. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95889. */
  95890. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95891. /**
  95892. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95893. * @param sphereCenter defines the bounding sphere center
  95894. * @param sphereRadius defines the bounding sphere radius
  95895. * @param selection defines the array to store current content if selection is positive
  95896. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95897. */
  95898. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95899. /**
  95900. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95901. * @param ray defines the ray to test with
  95902. * @param selection defines the array to store current content if selection is positive
  95903. */
  95904. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95905. /**
  95906. * Subdivide the content into child blocks (this block will then be empty)
  95907. */
  95908. createInnerBlocks(): void;
  95909. /**
  95910. * @hidden
  95911. */
  95912. 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;
  95913. }
  95914. }
  95915. declare module BABYLON {
  95916. /**
  95917. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95918. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95919. */
  95920. export class Octree<T> {
  95921. /** 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.) */
  95922. maxDepth: number;
  95923. /**
  95924. * Blocks within the octree containing objects
  95925. */
  95926. blocks: Array<OctreeBlock<T>>;
  95927. /**
  95928. * Content stored in the octree
  95929. */
  95930. dynamicContent: T[];
  95931. private _maxBlockCapacity;
  95932. private _selectionContent;
  95933. private _creationFunc;
  95934. /**
  95935. * Creates a octree
  95936. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95937. * @param creationFunc function to be used to instatiate the octree
  95938. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95939. * @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.)
  95940. */
  95941. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95942. /** 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.) */
  95943. maxDepth?: number);
  95944. /**
  95945. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95946. * @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);
  95947. * @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);
  95948. * @param entries meshes to be added to the octree blocks
  95949. */
  95950. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95951. /**
  95952. * Adds a mesh to the octree
  95953. * @param entry Mesh to add to the octree
  95954. */
  95955. addMesh(entry: T): void;
  95956. /**
  95957. * Remove an element from the octree
  95958. * @param entry defines the element to remove
  95959. */
  95960. removeMesh(entry: T): void;
  95961. /**
  95962. * Selects an array of meshes within the frustum
  95963. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95964. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95965. * @returns array of meshes within the frustum
  95966. */
  95967. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95968. /**
  95969. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95970. * @param sphereCenter defines the bounding sphere center
  95971. * @param sphereRadius defines the bounding sphere radius
  95972. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95973. * @returns an array of objects that intersect the sphere
  95974. */
  95975. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95976. /**
  95977. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95978. * @param ray defines the ray to test with
  95979. * @returns array of intersected objects
  95980. */
  95981. intersectsRay(ray: Ray): SmartArray<T>;
  95982. /**
  95983. * Adds a mesh into the octree block if it intersects the block
  95984. */
  95985. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95986. /**
  95987. * Adds a submesh into the octree block if it intersects the block
  95988. */
  95989. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95990. }
  95991. }
  95992. declare module BABYLON {
  95993. interface Scene {
  95994. /**
  95995. * @hidden
  95996. * Backing Filed
  95997. */
  95998. _selectionOctree: Octree<AbstractMesh>;
  95999. /**
  96000. * Gets the octree used to boost mesh selection (picking)
  96001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96002. */
  96003. selectionOctree: Octree<AbstractMesh>;
  96004. /**
  96005. * Creates or updates the octree used to boost selection (picking)
  96006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96007. * @param maxCapacity defines the maximum capacity per leaf
  96008. * @param maxDepth defines the maximum depth of the octree
  96009. * @returns an octree of AbstractMesh
  96010. */
  96011. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96012. }
  96013. interface AbstractMesh {
  96014. /**
  96015. * @hidden
  96016. * Backing Field
  96017. */
  96018. _submeshesOctree: Octree<SubMesh>;
  96019. /**
  96020. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96021. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96022. * @param maxCapacity defines the maximum size of each block (64 by default)
  96023. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96024. * @returns the new octree
  96025. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96027. */
  96028. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96029. }
  96030. /**
  96031. * Defines the octree scene component responsible to manage any octrees
  96032. * in a given scene.
  96033. */
  96034. export class OctreeSceneComponent {
  96035. /**
  96036. * The component name helpfull to identify the component in the list of scene components.
  96037. */
  96038. readonly name: string;
  96039. /**
  96040. * The scene the component belongs to.
  96041. */
  96042. scene: Scene;
  96043. /**
  96044. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96045. */
  96046. readonly checksIsEnabled: boolean;
  96047. /**
  96048. * Creates a new instance of the component for the given scene
  96049. * @param scene Defines the scene to register the component in
  96050. */
  96051. constructor(scene: Scene);
  96052. /**
  96053. * Registers the component in a given scene
  96054. */
  96055. register(): void;
  96056. /**
  96057. * Return the list of active meshes
  96058. * @returns the list of active meshes
  96059. */
  96060. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96061. /**
  96062. * Return the list of active sub meshes
  96063. * @param mesh The mesh to get the candidates sub meshes from
  96064. * @returns the list of active sub meshes
  96065. */
  96066. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96067. private _tempRay;
  96068. /**
  96069. * Return the list of sub meshes intersecting with a given local ray
  96070. * @param mesh defines the mesh to find the submesh for
  96071. * @param localRay defines the ray in local space
  96072. * @returns the list of intersecting sub meshes
  96073. */
  96074. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96075. /**
  96076. * Return the list of sub meshes colliding with a collider
  96077. * @param mesh defines the mesh to find the submesh for
  96078. * @param collider defines the collider to evaluate the collision against
  96079. * @returns the list of colliding sub meshes
  96080. */
  96081. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96082. /**
  96083. * Rebuilds the elements related to this component in case of
  96084. * context lost for instance.
  96085. */
  96086. rebuild(): void;
  96087. /**
  96088. * Disposes the component and the associated ressources.
  96089. */
  96090. dispose(): void;
  96091. }
  96092. }
  96093. declare module BABYLON {
  96094. /**
  96095. * Class containing static functions to help procedurally build meshes
  96096. */
  96097. export class LinesBuilder {
  96098. /**
  96099. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  96100. * * 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
  96101. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  96102. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  96103. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  96104. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  96105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  96106. * * 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
  96107. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  96108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  96110. * @param name defines the name of the new line system
  96111. * @param options defines the options used to create the line system
  96112. * @param scene defines the hosting scene
  96113. * @returns a new line system mesh
  96114. */
  96115. static CreateLineSystem(name: string, options: {
  96116. lines: Vector3[][];
  96117. updatable?: boolean;
  96118. instance?: Nullable<LinesMesh>;
  96119. colors?: Nullable<Color4[][]>;
  96120. useVertexAlpha?: boolean;
  96121. }, scene: Nullable<Scene>): LinesMesh;
  96122. /**
  96123. * Creates a line mesh
  96124. * 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
  96125. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96126. * * The parameter `points` is an array successive Vector3
  96127. * * 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
  96128. * * The optional parameter `colors` is an array of successive Color4, one per line point
  96129. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  96130. * * When updating an instance, remember that only point positions can change, not the number of points
  96131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  96133. * @param name defines the name of the new line system
  96134. * @param options defines the options used to create the line system
  96135. * @param scene defines the hosting scene
  96136. * @returns a new line mesh
  96137. */
  96138. static CreateLines(name: string, options: {
  96139. points: Vector3[];
  96140. updatable?: boolean;
  96141. instance?: Nullable<LinesMesh>;
  96142. colors?: Color4[];
  96143. useVertexAlpha?: boolean;
  96144. }, scene?: Nullable<Scene>): LinesMesh;
  96145. /**
  96146. * Creates a dashed line mesh
  96147. * * 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
  96148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96149. * * The parameter `points` is an array successive Vector3
  96150. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  96151. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  96152. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96153. * * 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
  96154. * * When updating an instance, remember that only point positions can change, not the number of points
  96155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96156. * @param name defines the name of the mesh
  96157. * @param options defines the options used to create the mesh
  96158. * @param scene defines the hosting scene
  96159. * @returns the dashed line mesh
  96160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  96161. */
  96162. static CreateDashedLines(name: string, options: {
  96163. points: Vector3[];
  96164. dashSize?: number;
  96165. gapSize?: number;
  96166. dashNb?: number;
  96167. updatable?: boolean;
  96168. instance?: LinesMesh;
  96169. }, scene?: Nullable<Scene>): LinesMesh;
  96170. }
  96171. }
  96172. declare module BABYLON {
  96173. /**
  96174. * Renders a layer on top of an existing scene
  96175. */
  96176. export class UtilityLayerRenderer implements IDisposable {
  96177. /** the original scene that will be rendered on top of */
  96178. originalScene: Scene;
  96179. private _pointerCaptures;
  96180. private _lastPointerEvents;
  96181. private static _DefaultUtilityLayer;
  96182. private static _DefaultKeepDepthUtilityLayer;
  96183. /**
  96184. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  96185. */
  96186. pickUtilitySceneFirst: boolean;
  96187. /**
  96188. * 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)
  96189. */
  96190. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  96191. /**
  96192. * 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)
  96193. */
  96194. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  96195. /**
  96196. * The scene that is rendered on top of the original scene
  96197. */
  96198. utilityLayerScene: Scene;
  96199. /**
  96200. * If the utility layer should automatically be rendered on top of existing scene
  96201. */
  96202. shouldRender: boolean;
  96203. /**
  96204. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  96205. */
  96206. onlyCheckPointerDownEvents: boolean;
  96207. /**
  96208. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  96209. */
  96210. processAllEvents: boolean;
  96211. /**
  96212. * Observable raised when the pointer move from the utility layer scene to the main scene
  96213. */
  96214. onPointerOutObservable: Observable<number>;
  96215. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  96216. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  96217. private _afterRenderObserver;
  96218. private _sceneDisposeObserver;
  96219. private _originalPointerObserver;
  96220. /**
  96221. * Instantiates a UtilityLayerRenderer
  96222. * @param originalScene the original scene that will be rendered on top of
  96223. * @param handleEvents boolean indicating if the utility layer should handle events
  96224. */
  96225. constructor(
  96226. /** the original scene that will be rendered on top of */
  96227. originalScene: Scene, handleEvents?: boolean);
  96228. private _notifyObservers;
  96229. /**
  96230. * Renders the utility layers scene on top of the original scene
  96231. */
  96232. render(): void;
  96233. /**
  96234. * Disposes of the renderer
  96235. */
  96236. dispose(): void;
  96237. private _updateCamera;
  96238. }
  96239. }
  96240. declare module BABYLON {
  96241. /**
  96242. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  96243. */
  96244. export class Gizmo implements IDisposable {
  96245. /** The utility layer the gizmo will be added to */
  96246. gizmoLayer: UtilityLayerRenderer;
  96247. /**
  96248. * The root mesh of the gizmo
  96249. */
  96250. _rootMesh: Mesh;
  96251. private _attachedMesh;
  96252. /**
  96253. * Ratio for the scale of the gizmo (Default: 1)
  96254. */
  96255. scaleRatio: number;
  96256. private _tmpMatrix;
  96257. /**
  96258. * If a custom mesh has been set (Default: false)
  96259. */
  96260. protected _customMeshSet: boolean;
  96261. /**
  96262. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  96263. * * When set, interactions will be enabled
  96264. */
  96265. attachedMesh: Nullable<AbstractMesh>;
  96266. /**
  96267. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  96268. * @param mesh The mesh to replace the default mesh of the gizmo
  96269. */
  96270. setCustomMesh(mesh: Mesh): void;
  96271. /**
  96272. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  96273. */
  96274. updateGizmoRotationToMatchAttachedMesh: boolean;
  96275. /**
  96276. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  96277. */
  96278. updateGizmoPositionToMatchAttachedMesh: boolean;
  96279. /**
  96280. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  96281. */
  96282. protected _updateScale: boolean;
  96283. protected _interactionsEnabled: boolean;
  96284. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96285. private _beforeRenderObserver;
  96286. /**
  96287. * Creates a gizmo
  96288. * @param gizmoLayer The utility layer the gizmo will be added to
  96289. */
  96290. constructor(
  96291. /** The utility layer the gizmo will be added to */
  96292. gizmoLayer?: UtilityLayerRenderer);
  96293. private _tempVector;
  96294. /**
  96295. * @hidden
  96296. * Updates the gizmo to match the attached mesh's position/rotation
  96297. */
  96298. protected _update(): void;
  96299. /**
  96300. * Disposes of the gizmo
  96301. */
  96302. dispose(): void;
  96303. }
  96304. }
  96305. declare module BABYLON {
  96306. /**
  96307. * Single axis drag gizmo
  96308. */
  96309. export class AxisDragGizmo extends Gizmo {
  96310. /**
  96311. * Drag behavior responsible for the gizmos dragging interactions
  96312. */
  96313. dragBehavior: PointerDragBehavior;
  96314. private _pointerObserver;
  96315. /**
  96316. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  96317. */
  96318. snapDistance: number;
  96319. /**
  96320. * Event that fires each time the gizmo snaps to a new location.
  96321. * * snapDistance is the the change in distance
  96322. */
  96323. onSnapObservable: Observable<{
  96324. snapDistance: number;
  96325. }>;
  96326. /** @hidden */
  96327. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  96328. /** @hidden */
  96329. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  96330. /**
  96331. * Creates an AxisDragGizmo
  96332. * @param gizmoLayer The utility layer the gizmo will be added to
  96333. * @param dragAxis The axis which the gizmo will be able to drag on
  96334. * @param color The color of the gizmo
  96335. */
  96336. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96338. /**
  96339. * Disposes of the gizmo
  96340. */
  96341. dispose(): void;
  96342. }
  96343. }
  96344. declare module BABYLON.Debug {
  96345. /**
  96346. * The Axes viewer will show 3 axes in a specific point in space
  96347. */
  96348. export class AxesViewer {
  96349. private _xAxis;
  96350. private _yAxis;
  96351. private _zAxis;
  96352. private _scaleLinesFactor;
  96353. private _instanced;
  96354. /**
  96355. * Gets the hosting scene
  96356. */
  96357. scene: Scene;
  96358. /**
  96359. * Gets or sets a number used to scale line length
  96360. */
  96361. scaleLines: number;
  96362. /** Gets the node hierarchy used to render x-axis */
  96363. readonly xAxis: TransformNode;
  96364. /** Gets the node hierarchy used to render y-axis */
  96365. readonly yAxis: TransformNode;
  96366. /** Gets the node hierarchy used to render z-axis */
  96367. readonly zAxis: TransformNode;
  96368. /**
  96369. * Creates a new AxesViewer
  96370. * @param scene defines the hosting scene
  96371. * @param scaleLines defines a number used to scale line length (1 by default)
  96372. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96373. * @param xAxis defines the node hierarchy used to render the x-axis
  96374. * @param yAxis defines the node hierarchy used to render the y-axis
  96375. * @param zAxis defines the node hierarchy used to render the z-axis
  96376. */
  96377. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96378. /**
  96379. * Force the viewer to update
  96380. * @param position defines the position of the viewer
  96381. * @param xaxis defines the x axis of the viewer
  96382. * @param yaxis defines the y axis of the viewer
  96383. * @param zaxis defines the z axis of the viewer
  96384. */
  96385. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96386. /**
  96387. * Creates an instance of this axes viewer.
  96388. * @returns a new axes viewer with instanced meshes
  96389. */
  96390. createInstance(): AxesViewer;
  96391. /** Releases resources */
  96392. dispose(): void;
  96393. private static _SetRenderingGroupId;
  96394. }
  96395. }
  96396. declare module BABYLON.Debug {
  96397. /**
  96398. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96399. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96400. */
  96401. export class BoneAxesViewer extends AxesViewer {
  96402. /**
  96403. * Gets or sets the target mesh where to display the axes viewer
  96404. */
  96405. mesh: Nullable<Mesh>;
  96406. /**
  96407. * Gets or sets the target bone where to display the axes viewer
  96408. */
  96409. bone: Nullable<Bone>;
  96410. /** Gets current position */
  96411. pos: Vector3;
  96412. /** Gets direction of X axis */
  96413. xaxis: Vector3;
  96414. /** Gets direction of Y axis */
  96415. yaxis: Vector3;
  96416. /** Gets direction of Z axis */
  96417. zaxis: Vector3;
  96418. /**
  96419. * Creates a new BoneAxesViewer
  96420. * @param scene defines the hosting scene
  96421. * @param bone defines the target bone
  96422. * @param mesh defines the target mesh
  96423. * @param scaleLines defines a scaling factor for line length (1 by default)
  96424. */
  96425. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96426. /**
  96427. * Force the viewer to update
  96428. */
  96429. update(): void;
  96430. /** Releases resources */
  96431. dispose(): void;
  96432. }
  96433. }
  96434. declare module BABYLON {
  96435. /**
  96436. * Interface used to define scene explorer extensibility option
  96437. */
  96438. export interface IExplorerExtensibilityOption {
  96439. /**
  96440. * Define the option label
  96441. */
  96442. label: string;
  96443. /**
  96444. * Defines the action to execute on click
  96445. */
  96446. action: (entity: any) => void;
  96447. }
  96448. /**
  96449. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96450. */
  96451. export interface IExplorerExtensibilityGroup {
  96452. /**
  96453. * Defines a predicate to test if a given type mut be extended
  96454. */
  96455. predicate: (entity: any) => boolean;
  96456. /**
  96457. * Gets the list of options added to a type
  96458. */
  96459. entries: IExplorerExtensibilityOption[];
  96460. }
  96461. /**
  96462. * Interface used to define the options to use to create the Inspector
  96463. */
  96464. export interface IInspectorOptions {
  96465. /**
  96466. * Display in overlay mode (default: false)
  96467. */
  96468. overlay?: boolean;
  96469. /**
  96470. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96471. */
  96472. globalRoot?: HTMLElement;
  96473. /**
  96474. * Display the Scene explorer
  96475. */
  96476. showExplorer?: boolean;
  96477. /**
  96478. * Display the property inspector
  96479. */
  96480. showInspector?: boolean;
  96481. /**
  96482. * Display in embed mode (both panes on the right)
  96483. */
  96484. embedMode?: boolean;
  96485. /**
  96486. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96487. */
  96488. handleResize?: boolean;
  96489. /**
  96490. * Allow the panes to popup (default: true)
  96491. */
  96492. enablePopup?: boolean;
  96493. /**
  96494. * Allow the panes to be closed by users (default: true)
  96495. */
  96496. enableClose?: boolean;
  96497. /**
  96498. * Optional list of extensibility entries
  96499. */
  96500. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96501. /**
  96502. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  96503. */
  96504. inspectorURL?: string;
  96505. }
  96506. interface Scene {
  96507. /**
  96508. * @hidden
  96509. * Backing field
  96510. */
  96511. _debugLayer: DebugLayer;
  96512. /**
  96513. * Gets the debug layer (aka Inspector) associated with the scene
  96514. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96515. */
  96516. debugLayer: DebugLayer;
  96517. }
  96518. /**
  96519. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96520. * what is happening in your scene
  96521. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96522. */
  96523. export class DebugLayer {
  96524. /**
  96525. * Define the url to get the inspector script from.
  96526. * By default it uses the babylonjs CDN.
  96527. * @ignoreNaming
  96528. */
  96529. static InspectorURL: string;
  96530. private _scene;
  96531. private BJSINSPECTOR;
  96532. /**
  96533. * Observable triggered when a property is changed through the inspector.
  96534. */
  96535. onPropertyChangedObservable: Observable<{
  96536. object: any;
  96537. property: string;
  96538. value: any;
  96539. initialValue: any;
  96540. }>;
  96541. /**
  96542. * Instantiates a new debug layer.
  96543. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96544. * what is happening in your scene
  96545. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96546. * @param scene Defines the scene to inspect
  96547. */
  96548. constructor(scene: Scene);
  96549. /** Creates the inspector window. */
  96550. private _createInspector;
  96551. /** Get the inspector from bundle or global */
  96552. private _getGlobalInspector;
  96553. /**
  96554. * Get if the inspector is visible or not.
  96555. * @returns true if visible otherwise, false
  96556. */
  96557. isVisible(): boolean;
  96558. /**
  96559. * Hide the inspector and close its window.
  96560. */
  96561. hide(): void;
  96562. /**
  96563. * Launch the debugLayer.
  96564. * @param config Define the configuration of the inspector
  96565. */
  96566. show(config?: IInspectorOptions): void;
  96567. }
  96568. }
  96569. declare module BABYLON {
  96570. /**
  96571. * Class containing static functions to help procedurally build meshes
  96572. */
  96573. export class BoxBuilder {
  96574. /**
  96575. * Creates a box mesh
  96576. * * The parameter `size` sets the size (float) of each box side (default 1)
  96577. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96578. * * 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)
  96579. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96583. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96584. * @param name defines the name of the mesh
  96585. * @param options defines the options used to create the mesh
  96586. * @param scene defines the hosting scene
  96587. * @returns the box mesh
  96588. */
  96589. static CreateBox(name: string, options: {
  96590. size?: number;
  96591. width?: number;
  96592. height?: number;
  96593. depth?: number;
  96594. faceUV?: Vector4[];
  96595. faceColors?: Color4[];
  96596. sideOrientation?: number;
  96597. frontUVs?: Vector4;
  96598. backUVs?: Vector4;
  96599. updatable?: boolean;
  96600. }, scene?: Nullable<Scene>): Mesh;
  96601. }
  96602. }
  96603. declare module BABYLON {
  96604. /**
  96605. * Class containing static functions to help procedurally build meshes
  96606. */
  96607. export class SphereBuilder {
  96608. /**
  96609. * Creates a sphere mesh
  96610. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96611. * * 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`)
  96612. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96613. * * 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
  96614. * * 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)
  96615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96618. * @param name defines the name of the mesh
  96619. * @param options defines the options used to create the mesh
  96620. * @param scene defines the hosting scene
  96621. * @returns the sphere mesh
  96622. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96623. */
  96624. static CreateSphere(name: string, options: {
  96625. segments?: number;
  96626. diameter?: number;
  96627. diameterX?: number;
  96628. diameterY?: number;
  96629. diameterZ?: number;
  96630. arc?: number;
  96631. slice?: number;
  96632. sideOrientation?: number;
  96633. frontUVs?: Vector4;
  96634. backUVs?: Vector4;
  96635. updatable?: boolean;
  96636. }, scene: any): Mesh;
  96637. }
  96638. }
  96639. declare module BABYLON.Debug {
  96640. /**
  96641. * Used to show the physics impostor around the specific mesh
  96642. */
  96643. export class PhysicsViewer {
  96644. /** @hidden */
  96645. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96646. /** @hidden */
  96647. protected _meshes: Array<Nullable<AbstractMesh>>;
  96648. /** @hidden */
  96649. protected _scene: Nullable<Scene>;
  96650. /** @hidden */
  96651. protected _numMeshes: number;
  96652. /** @hidden */
  96653. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96654. private _renderFunction;
  96655. private _utilityLayer;
  96656. private _debugBoxMesh;
  96657. private _debugSphereMesh;
  96658. private _debugMaterial;
  96659. /**
  96660. * Creates a new PhysicsViewer
  96661. * @param scene defines the hosting scene
  96662. */
  96663. constructor(scene: Scene);
  96664. /** @hidden */
  96665. protected _updateDebugMeshes(): void;
  96666. /**
  96667. * Renders a specified physic impostor
  96668. * @param impostor defines the impostor to render
  96669. * @returns the new debug mesh used to render the impostor
  96670. */
  96671. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96672. /**
  96673. * Hides a specified physic impostor
  96674. * @param impostor defines the impostor to hide
  96675. */
  96676. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96677. private _getDebugMaterial;
  96678. private _getDebugBoxMesh;
  96679. private _getDebugSphereMesh;
  96680. private _getDebugMesh;
  96681. /** Releases all resources */
  96682. dispose(): void;
  96683. }
  96684. }
  96685. declare module BABYLON {
  96686. /**
  96687. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96688. * in order to better appreciate the issue one might have.
  96689. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96690. */
  96691. export class RayHelper {
  96692. /**
  96693. * Defines the ray we are currently tryin to visualize.
  96694. */
  96695. ray: Nullable<Ray>;
  96696. private _renderPoints;
  96697. private _renderLine;
  96698. private _renderFunction;
  96699. private _scene;
  96700. private _updateToMeshFunction;
  96701. private _attachedToMesh;
  96702. private _meshSpaceDirection;
  96703. private _meshSpaceOrigin;
  96704. /**
  96705. * Helper function to create a colored helper in a scene in one line.
  96706. * @param ray Defines the ray we are currently tryin to visualize
  96707. * @param scene Defines the scene the ray is used in
  96708. * @param color Defines the color we want to see the ray in
  96709. * @returns The newly created ray helper.
  96710. */
  96711. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96712. /**
  96713. * Instantiate a new ray helper.
  96714. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96715. * in order to better appreciate the issue one might have.
  96716. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96717. * @param ray Defines the ray we are currently tryin to visualize
  96718. */
  96719. constructor(ray: Ray);
  96720. /**
  96721. * Shows the ray we are willing to debug.
  96722. * @param scene Defines the scene the ray needs to be rendered in
  96723. * @param color Defines the color the ray needs to be rendered in
  96724. */
  96725. show(scene: Scene, color?: Color3): void;
  96726. /**
  96727. * Hides the ray we are debugging.
  96728. */
  96729. hide(): void;
  96730. private _render;
  96731. /**
  96732. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96733. * @param mesh Defines the mesh we want the helper attached to
  96734. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96735. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96736. * @param length Defines the length of the ray
  96737. */
  96738. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96739. /**
  96740. * Detach the ray helper from the mesh it has previously been attached to.
  96741. */
  96742. detachFromMesh(): void;
  96743. private _updateToMesh;
  96744. /**
  96745. * Dispose the helper and release its associated resources.
  96746. */
  96747. dispose(): void;
  96748. }
  96749. }
  96750. declare module BABYLON.Debug {
  96751. /**
  96752. * Class used to render a debug view of a given skeleton
  96753. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96754. */
  96755. export class SkeletonViewer {
  96756. /** defines the skeleton to render */
  96757. skeleton: Skeleton;
  96758. /** defines the mesh attached to the skeleton */
  96759. mesh: AbstractMesh;
  96760. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96761. autoUpdateBonesMatrices: boolean;
  96762. /** defines the rendering group id to use with the viewer */
  96763. renderingGroupId: number;
  96764. /** Gets or sets the color used to render the skeleton */
  96765. color: Color3;
  96766. private _scene;
  96767. private _debugLines;
  96768. private _debugMesh;
  96769. private _isEnabled;
  96770. private _renderFunction;
  96771. private _utilityLayer;
  96772. /**
  96773. * Returns the mesh used to render the bones
  96774. */
  96775. readonly debugMesh: Nullable<LinesMesh>;
  96776. /**
  96777. * Creates a new SkeletonViewer
  96778. * @param skeleton defines the skeleton to render
  96779. * @param mesh defines the mesh attached to the skeleton
  96780. * @param scene defines the hosting scene
  96781. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96782. * @param renderingGroupId defines the rendering group id to use with the viewer
  96783. */
  96784. constructor(
  96785. /** defines the skeleton to render */
  96786. skeleton: Skeleton,
  96787. /** defines the mesh attached to the skeleton */
  96788. mesh: AbstractMesh, scene: Scene,
  96789. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96790. autoUpdateBonesMatrices?: boolean,
  96791. /** defines the rendering group id to use with the viewer */
  96792. renderingGroupId?: number);
  96793. /** Gets or sets a boolean indicating if the viewer is enabled */
  96794. isEnabled: boolean;
  96795. private _getBonePosition;
  96796. private _getLinesForBonesWithLength;
  96797. private _getLinesForBonesNoLength;
  96798. /** Update the viewer to sync with current skeleton state */
  96799. update(): void;
  96800. /** Release associated resources */
  96801. dispose(): void;
  96802. }
  96803. }
  96804. declare module BABYLON {
  96805. /**
  96806. * Options to create the null engine
  96807. */
  96808. export class NullEngineOptions {
  96809. /**
  96810. * Render width (Default: 512)
  96811. */
  96812. renderWidth: number;
  96813. /**
  96814. * Render height (Default: 256)
  96815. */
  96816. renderHeight: number;
  96817. /**
  96818. * Texture size (Default: 512)
  96819. */
  96820. textureSize: number;
  96821. /**
  96822. * If delta time between frames should be constant
  96823. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96824. */
  96825. deterministicLockstep: boolean;
  96826. /**
  96827. * Maximum about of steps between frames (Default: 4)
  96828. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96829. */
  96830. lockstepMaxSteps: number;
  96831. }
  96832. /**
  96833. * The null engine class provides support for headless version of babylon.js.
  96834. * This can be used in server side scenario or for testing purposes
  96835. */
  96836. export class NullEngine extends Engine {
  96837. private _options;
  96838. /**
  96839. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96840. */
  96841. isDeterministicLockStep(): boolean;
  96842. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96843. getLockstepMaxSteps(): number;
  96844. /**
  96845. * Sets hardware scaling, used to save performance if needed
  96846. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96847. */
  96848. getHardwareScalingLevel(): number;
  96849. constructor(options?: NullEngineOptions);
  96850. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96851. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96852. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96853. getRenderWidth(useScreen?: boolean): number;
  96854. getRenderHeight(useScreen?: boolean): number;
  96855. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96856. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96857. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96858. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96859. bindSamplers(effect: Effect): void;
  96860. enableEffect(effect: Effect): void;
  96861. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96862. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96863. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96864. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96865. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96866. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96867. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96868. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96869. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96870. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96871. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96872. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96873. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96874. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96875. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96876. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96877. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96878. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96879. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96880. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96881. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96882. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96883. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96884. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96885. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96886. bindBuffers(vertexBuffers: {
  96887. [key: string]: VertexBuffer;
  96888. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96889. wipeCaches(bruteForce?: boolean): void;
  96890. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96891. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96892. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96893. /** @hidden */
  96894. _createTexture(): WebGLTexture;
  96895. /** @hidden */
  96896. _releaseTexture(texture: InternalTexture): void;
  96897. 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;
  96898. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96899. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96900. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96901. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96902. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96903. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96904. areAllEffectsReady(): boolean;
  96905. /**
  96906. * @hidden
  96907. * Get the current error code of the webGL context
  96908. * @returns the error code
  96909. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96910. */
  96911. getError(): number;
  96912. /** @hidden */
  96913. _getUnpackAlignement(): number;
  96914. /** @hidden */
  96915. _unpackFlipY(value: boolean): void;
  96916. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96917. /**
  96918. * Updates a dynamic vertex buffer.
  96919. * @param vertexBuffer the vertex buffer to update
  96920. * @param data the data used to update the vertex buffer
  96921. * @param byteOffset the byte offset of the data (optional)
  96922. * @param byteLength the byte length of the data (optional)
  96923. */
  96924. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96925. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96926. /** @hidden */
  96927. _bindTexture(channel: number, texture: InternalTexture): void;
  96928. /** @hidden */
  96929. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96930. releaseEffects(): void;
  96931. displayLoadingUI(): void;
  96932. hideLoadingUI(): void;
  96933. /** @hidden */
  96934. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96935. /** @hidden */
  96936. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96937. /** @hidden */
  96938. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96939. /** @hidden */
  96940. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96941. }
  96942. }
  96943. declare module BABYLON {
  96944. /** @hidden */
  96945. export class _OcclusionDataStorage {
  96946. /** @hidden */
  96947. occlusionInternalRetryCounter: number;
  96948. /** @hidden */
  96949. isOcclusionQueryInProgress: boolean;
  96950. /** @hidden */
  96951. isOccluded: boolean;
  96952. /** @hidden */
  96953. occlusionRetryCount: number;
  96954. /** @hidden */
  96955. occlusionType: number;
  96956. /** @hidden */
  96957. occlusionQueryAlgorithmType: number;
  96958. }
  96959. interface Engine {
  96960. /**
  96961. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96962. * @return the new query
  96963. */
  96964. createQuery(): WebGLQuery;
  96965. /**
  96966. * Delete and release a webGL query
  96967. * @param query defines the query to delete
  96968. * @return the current engine
  96969. */
  96970. deleteQuery(query: WebGLQuery): Engine;
  96971. /**
  96972. * Check if a given query has resolved and got its value
  96973. * @param query defines the query to check
  96974. * @returns true if the query got its value
  96975. */
  96976. isQueryResultAvailable(query: WebGLQuery): boolean;
  96977. /**
  96978. * Gets the value of a given query
  96979. * @param query defines the query to check
  96980. * @returns the value of the query
  96981. */
  96982. getQueryResult(query: WebGLQuery): number;
  96983. /**
  96984. * Initiates an occlusion query
  96985. * @param algorithmType defines the algorithm to use
  96986. * @param query defines the query to use
  96987. * @returns the current engine
  96988. * @see http://doc.babylonjs.com/features/occlusionquery
  96989. */
  96990. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96991. /**
  96992. * Ends an occlusion query
  96993. * @see http://doc.babylonjs.com/features/occlusionquery
  96994. * @param algorithmType defines the algorithm to use
  96995. * @returns the current engine
  96996. */
  96997. endOcclusionQuery(algorithmType: number): Engine;
  96998. /**
  96999. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97000. * Please note that only one query can be issued at a time
  97001. * @returns a time token used to track the time span
  97002. */
  97003. startTimeQuery(): Nullable<_TimeToken>;
  97004. /**
  97005. * Ends a time query
  97006. * @param token defines the token used to measure the time span
  97007. * @returns the time spent (in ns)
  97008. */
  97009. endTimeQuery(token: _TimeToken): int;
  97010. /** @hidden */
  97011. _currentNonTimestampToken: Nullable<_TimeToken>;
  97012. /** @hidden */
  97013. _createTimeQuery(): WebGLQuery;
  97014. /** @hidden */
  97015. _deleteTimeQuery(query: WebGLQuery): void;
  97016. /** @hidden */
  97017. _getGlAlgorithmType(algorithmType: number): number;
  97018. /** @hidden */
  97019. _getTimeQueryResult(query: WebGLQuery): any;
  97020. /** @hidden */
  97021. _getTimeQueryAvailability(query: WebGLQuery): any;
  97022. }
  97023. interface AbstractMesh {
  97024. /**
  97025. * Backing filed
  97026. * @hidden
  97027. */
  97028. __occlusionDataStorage: _OcclusionDataStorage;
  97029. /**
  97030. * Access property
  97031. * @hidden
  97032. */
  97033. _occlusionDataStorage: _OcclusionDataStorage;
  97034. /**
  97035. * 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.
  97036. * The default value is -1 which means don't break the query and wait till the result
  97037. * @see http://doc.babylonjs.com/features/occlusionquery
  97038. */
  97039. occlusionRetryCount: number;
  97040. /**
  97041. * 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:
  97042. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97043. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97044. * * 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.
  97045. * @see http://doc.babylonjs.com/features/occlusionquery
  97046. */
  97047. occlusionType: number;
  97048. /**
  97049. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97050. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97051. * * 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.
  97052. * @see http://doc.babylonjs.com/features/occlusionquery
  97053. */
  97054. occlusionQueryAlgorithmType: number;
  97055. /**
  97056. * 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
  97057. * @see http://doc.babylonjs.com/features/occlusionquery
  97058. */
  97059. isOccluded: boolean;
  97060. /**
  97061. * Flag to check the progress status of the query
  97062. * @see http://doc.babylonjs.com/features/occlusionquery
  97063. */
  97064. isOcclusionQueryInProgress: boolean;
  97065. }
  97066. }
  97067. declare module BABYLON {
  97068. /** @hidden */
  97069. export var _forceTransformFeedbackToBundle: boolean;
  97070. interface Engine {
  97071. /**
  97072. * Creates a webGL transform feedback object
  97073. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  97074. * @returns the webGL transform feedback object
  97075. */
  97076. createTransformFeedback(): WebGLTransformFeedback;
  97077. /**
  97078. * Delete a webGL transform feedback object
  97079. * @param value defines the webGL transform feedback object to delete
  97080. */
  97081. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  97082. /**
  97083. * Bind a webGL transform feedback object to the webgl context
  97084. * @param value defines the webGL transform feedback object to bind
  97085. */
  97086. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  97087. /**
  97088. * Begins a transform feedback operation
  97089. * @param usePoints defines if points or triangles must be used
  97090. */
  97091. beginTransformFeedback(usePoints: boolean): void;
  97092. /**
  97093. * Ends a transform feedback operation
  97094. */
  97095. endTransformFeedback(): void;
  97096. /**
  97097. * Specify the varyings to use with transform feedback
  97098. * @param program defines the associated webGL program
  97099. * @param value defines the list of strings representing the varying names
  97100. */
  97101. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  97102. /**
  97103. * Bind a webGL buffer for a transform feedback operation
  97104. * @param value defines the webGL buffer to bind
  97105. */
  97106. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  97107. }
  97108. }
  97109. declare module BABYLON {
  97110. /**
  97111. * Gather the list of clipboard event types as constants.
  97112. */
  97113. export class ClipboardEventTypes {
  97114. /**
  97115. * The clipboard event is fired when a copy command is active (pressed).
  97116. */
  97117. static readonly COPY: number;
  97118. /**
  97119. * The clipboard event is fired when a cut command is active (pressed).
  97120. */
  97121. static readonly CUT: number;
  97122. /**
  97123. * The clipboard event is fired when a paste command is active (pressed).
  97124. */
  97125. static readonly PASTE: number;
  97126. }
  97127. /**
  97128. * This class is used to store clipboard related info for the onClipboardObservable event.
  97129. */
  97130. export class ClipboardInfo {
  97131. /**
  97132. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97133. */
  97134. type: number;
  97135. /**
  97136. * Defines the related dom event
  97137. */
  97138. event: ClipboardEvent;
  97139. /**
  97140. *Creates an instance of ClipboardInfo.
  97141. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  97142. * @param event Defines the related dom event
  97143. */
  97144. constructor(
  97145. /**
  97146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97147. */
  97148. type: number,
  97149. /**
  97150. * Defines the related dom event
  97151. */
  97152. event: ClipboardEvent);
  97153. /**
  97154. * Get the clipboard event's type from the keycode.
  97155. * @param keyCode Defines the keyCode for the current keyboard event.
  97156. * @return {number}
  97157. */
  97158. static GetTypeFromCharacter(keyCode: number): number;
  97159. }
  97160. }
  97161. declare module BABYLON {
  97162. /**
  97163. * Class used to represent data loading progression
  97164. */
  97165. export class SceneLoaderProgressEvent {
  97166. /** defines if data length to load can be evaluated */
  97167. readonly lengthComputable: boolean;
  97168. /** defines the loaded data length */
  97169. readonly loaded: number;
  97170. /** defines the data length to load */
  97171. readonly total: number;
  97172. /**
  97173. * Create a new progress event
  97174. * @param lengthComputable defines if data length to load can be evaluated
  97175. * @param loaded defines the loaded data length
  97176. * @param total defines the data length to load
  97177. */
  97178. constructor(
  97179. /** defines if data length to load can be evaluated */
  97180. lengthComputable: boolean,
  97181. /** defines the loaded data length */
  97182. loaded: number,
  97183. /** defines the data length to load */
  97184. total: number);
  97185. /**
  97186. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  97187. * @param event defines the source event
  97188. * @returns a new SceneLoaderProgressEvent
  97189. */
  97190. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  97191. }
  97192. /**
  97193. * Interface used by SceneLoader plugins to define supported file extensions
  97194. */
  97195. export interface ISceneLoaderPluginExtensions {
  97196. /**
  97197. * Defines the list of supported extensions
  97198. */
  97199. [extension: string]: {
  97200. isBinary: boolean;
  97201. };
  97202. }
  97203. /**
  97204. * Interface used by SceneLoader plugin factory
  97205. */
  97206. export interface ISceneLoaderPluginFactory {
  97207. /**
  97208. * Defines the name of the factory
  97209. */
  97210. name: string;
  97211. /**
  97212. * Function called to create a new plugin
  97213. * @return the new plugin
  97214. */
  97215. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  97216. /**
  97217. * Boolean indicating if the plugin can direct load specific data
  97218. */
  97219. canDirectLoad?: (data: string) => boolean;
  97220. }
  97221. /**
  97222. * Interface used to define a SceneLoader plugin
  97223. */
  97224. export interface ISceneLoaderPlugin {
  97225. /**
  97226. * The friendly name of this plugin.
  97227. */
  97228. name: string;
  97229. /**
  97230. * The file extensions supported by this plugin.
  97231. */
  97232. extensions: string | ISceneLoaderPluginExtensions;
  97233. /**
  97234. * Import meshes into a scene.
  97235. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97236. * @param scene The scene to import into
  97237. * @param data The data to import
  97238. * @param rootUrl The root url for scene and resources
  97239. * @param meshes The meshes array to import into
  97240. * @param particleSystems The particle systems array to import into
  97241. * @param skeletons The skeletons array to import into
  97242. * @param onError The callback when import fails
  97243. * @returns True if successful or false otherwise
  97244. */
  97245. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  97246. /**
  97247. * Load into a scene.
  97248. * @param scene The scene to load into
  97249. * @param data The data to import
  97250. * @param rootUrl The root url for scene and resources
  97251. * @param onError The callback when import fails
  97252. * @returns true if successful or false otherwise
  97253. */
  97254. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  97255. /**
  97256. * The callback that returns true if the data can be directly loaded.
  97257. */
  97258. canDirectLoad?: (data: string) => boolean;
  97259. /**
  97260. * The callback that allows custom handling of the root url based on the response url.
  97261. */
  97262. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97263. /**
  97264. * Load into an asset container.
  97265. * @param scene The scene to load into
  97266. * @param data The data to import
  97267. * @param rootUrl The root url for scene and resources
  97268. * @param onError The callback when import fails
  97269. * @returns The loaded asset container
  97270. */
  97271. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  97272. }
  97273. /**
  97274. * Interface used to define an async SceneLoader plugin
  97275. */
  97276. export interface ISceneLoaderPluginAsync {
  97277. /**
  97278. * The friendly name of this plugin.
  97279. */
  97280. name: string;
  97281. /**
  97282. * The file extensions supported by this plugin.
  97283. */
  97284. extensions: string | ISceneLoaderPluginExtensions;
  97285. /**
  97286. * Import meshes into a scene.
  97287. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97288. * @param scene The scene to import into
  97289. * @param data The data to import
  97290. * @param rootUrl The root url for scene and resources
  97291. * @param onProgress The callback when the load progresses
  97292. * @param fileName Defines the name of the file to load
  97293. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  97294. */
  97295. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  97296. meshes: AbstractMesh[];
  97297. particleSystems: IParticleSystem[];
  97298. skeletons: Skeleton[];
  97299. animationGroups: AnimationGroup[];
  97300. }>;
  97301. /**
  97302. * Load into a scene.
  97303. * @param scene The scene to load into
  97304. * @param data The data to import
  97305. * @param rootUrl The root url for scene and resources
  97306. * @param onProgress The callback when the load progresses
  97307. * @param fileName Defines the name of the file to load
  97308. * @returns Nothing
  97309. */
  97310. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  97311. /**
  97312. * The callback that returns true if the data can be directly loaded.
  97313. */
  97314. canDirectLoad?: (data: string) => boolean;
  97315. /**
  97316. * The callback that allows custom handling of the root url based on the response url.
  97317. */
  97318. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97319. /**
  97320. * Load into an asset container.
  97321. * @param scene The scene to load into
  97322. * @param data The data to import
  97323. * @param rootUrl The root url for scene and resources
  97324. * @param onProgress The callback when the load progresses
  97325. * @param fileName Defines the name of the file to load
  97326. * @returns The loaded asset container
  97327. */
  97328. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  97329. }
  97330. /**
  97331. * Class used to load scene from various file formats using registered plugins
  97332. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  97333. */
  97334. export class SceneLoader {
  97335. /**
  97336. * No logging while loading
  97337. */
  97338. static readonly NO_LOGGING: number;
  97339. /**
  97340. * Minimal logging while loading
  97341. */
  97342. static readonly MINIMAL_LOGGING: number;
  97343. /**
  97344. * Summary logging while loading
  97345. */
  97346. static readonly SUMMARY_LOGGING: number;
  97347. /**
  97348. * Detailled logging while loading
  97349. */
  97350. static readonly DETAILED_LOGGING: number;
  97351. /**
  97352. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97353. */
  97354. static ForceFullSceneLoadingForIncremental: boolean;
  97355. /**
  97356. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97357. */
  97358. static ShowLoadingScreen: boolean;
  97359. /**
  97360. * Defines the current logging level (while loading the scene)
  97361. * @ignorenaming
  97362. */
  97363. static loggingLevel: number;
  97364. /**
  97365. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97366. */
  97367. static CleanBoneMatrixWeights: boolean;
  97368. /**
  97369. * Event raised when a plugin is used to load a scene
  97370. */
  97371. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97372. private static _registeredPlugins;
  97373. private static _getDefaultPlugin;
  97374. private static _getPluginForExtension;
  97375. private static _getPluginForDirectLoad;
  97376. private static _getPluginForFilename;
  97377. private static _getDirectLoad;
  97378. private static _loadData;
  97379. private static _getFileInfo;
  97380. /**
  97381. * Gets a plugin that can load the given extension
  97382. * @param extension defines the extension to load
  97383. * @returns a plugin or null if none works
  97384. */
  97385. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97386. /**
  97387. * Gets a boolean indicating that the given extension can be loaded
  97388. * @param extension defines the extension to load
  97389. * @returns true if the extension is supported
  97390. */
  97391. static IsPluginForExtensionAvailable(extension: string): boolean;
  97392. /**
  97393. * Adds a new plugin to the list of registered plugins
  97394. * @param plugin defines the plugin to add
  97395. */
  97396. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97397. /**
  97398. * Import meshes into a scene
  97399. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97400. * @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)
  97401. * @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)
  97402. * @param scene the instance of BABYLON.Scene to append to
  97403. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97404. * @param onProgress a callback with a progress event for each file being loaded
  97405. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97406. * @param pluginExtension the extension used to determine the plugin
  97407. * @returns The loaded plugin
  97408. */
  97409. 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>;
  97410. /**
  97411. * Import meshes into a scene
  97412. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97413. * @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)
  97414. * @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)
  97415. * @param scene the instance of BABYLON.Scene to append to
  97416. * @param onProgress a callback with a progress event for each file being loaded
  97417. * @param pluginExtension the extension used to determine the plugin
  97418. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97419. */
  97420. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97421. meshes: AbstractMesh[];
  97422. particleSystems: IParticleSystem[];
  97423. skeletons: Skeleton[];
  97424. animationGroups: AnimationGroup[];
  97425. }>;
  97426. /**
  97427. * Load a scene
  97428. * @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)
  97429. * @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)
  97430. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97431. * @param onSuccess a callback with the scene when import succeeds
  97432. * @param onProgress a callback with a progress event for each file being loaded
  97433. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97434. * @param pluginExtension the extension used to determine the plugin
  97435. * @returns The loaded plugin
  97436. */
  97437. 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>;
  97438. /**
  97439. * Load a scene
  97440. * @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)
  97441. * @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)
  97442. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97443. * @param onProgress a callback with a progress event for each file being loaded
  97444. * @param pluginExtension the extension used to determine the plugin
  97445. * @returns The loaded scene
  97446. */
  97447. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97448. /**
  97449. * Append a scene
  97450. * @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)
  97451. * @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)
  97452. * @param scene is the instance of BABYLON.Scene to append to
  97453. * @param onSuccess a callback with the scene when import succeeds
  97454. * @param onProgress a callback with a progress event for each file being loaded
  97455. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97456. * @param pluginExtension the extension used to determine the plugin
  97457. * @returns The loaded plugin
  97458. */
  97459. 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>;
  97460. /**
  97461. * Append a scene
  97462. * @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)
  97463. * @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)
  97464. * @param scene is the instance of BABYLON.Scene to append to
  97465. * @param onProgress a callback with a progress event for each file being loaded
  97466. * @param pluginExtension the extension used to determine the plugin
  97467. * @returns The given scene
  97468. */
  97469. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97470. /**
  97471. * Load a scene into an asset container
  97472. * @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)
  97473. * @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)
  97474. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97475. * @param onSuccess a callback with the scene when import succeeds
  97476. * @param onProgress a callback with a progress event for each file being loaded
  97477. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97478. * @param pluginExtension the extension used to determine the plugin
  97479. * @returns The loaded plugin
  97480. */
  97481. 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>;
  97482. /**
  97483. * Load a scene into an asset container
  97484. * @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)
  97485. * @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)
  97486. * @param scene is the instance of Scene to append to
  97487. * @param onProgress a callback with a progress event for each file being loaded
  97488. * @param pluginExtension the extension used to determine the plugin
  97489. * @returns The loaded asset container
  97490. */
  97491. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97492. }
  97493. }
  97494. declare module BABYLON {
  97495. /**
  97496. * Google Daydream controller
  97497. */
  97498. export class DaydreamController extends WebVRController {
  97499. /**
  97500. * Base Url for the controller model.
  97501. */
  97502. static MODEL_BASE_URL: string;
  97503. /**
  97504. * File name for the controller model.
  97505. */
  97506. static MODEL_FILENAME: string;
  97507. /**
  97508. * Gamepad Id prefix used to identify Daydream Controller.
  97509. */
  97510. static readonly GAMEPAD_ID_PREFIX: string;
  97511. /**
  97512. * Creates a new DaydreamController from a gamepad
  97513. * @param vrGamepad the gamepad that the controller should be created from
  97514. */
  97515. constructor(vrGamepad: any);
  97516. /**
  97517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97518. * @param scene scene in which to add meshes
  97519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97520. */
  97521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97522. /**
  97523. * Called once for each button that changed state since the last frame
  97524. * @param buttonIdx Which button index changed
  97525. * @param state New state of the button
  97526. * @param changes Which properties on the state changed since last frame
  97527. */
  97528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97529. }
  97530. }
  97531. declare module BABYLON {
  97532. /**
  97533. * Gear VR Controller
  97534. */
  97535. export class GearVRController extends WebVRController {
  97536. /**
  97537. * Base Url for the controller model.
  97538. */
  97539. static MODEL_BASE_URL: string;
  97540. /**
  97541. * File name for the controller model.
  97542. */
  97543. static MODEL_FILENAME: string;
  97544. /**
  97545. * Gamepad Id prefix used to identify this controller.
  97546. */
  97547. static readonly GAMEPAD_ID_PREFIX: string;
  97548. private readonly _buttonIndexToObservableNameMap;
  97549. /**
  97550. * Creates a new GearVRController from a gamepad
  97551. * @param vrGamepad the gamepad that the controller should be created from
  97552. */
  97553. constructor(vrGamepad: any);
  97554. /**
  97555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97556. * @param scene scene in which to add meshes
  97557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97558. */
  97559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97560. /**
  97561. * Called once for each button that changed state since the last frame
  97562. * @param buttonIdx Which button index changed
  97563. * @param state New state of the button
  97564. * @param changes Which properties on the state changed since last frame
  97565. */
  97566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97567. }
  97568. }
  97569. declare module BABYLON {
  97570. /**
  97571. * Generic Controller
  97572. */
  97573. export class GenericController extends WebVRController {
  97574. /**
  97575. * Base Url for the controller model.
  97576. */
  97577. static readonly MODEL_BASE_URL: string;
  97578. /**
  97579. * File name for the controller model.
  97580. */
  97581. static readonly MODEL_FILENAME: string;
  97582. /**
  97583. * Creates a new GenericController from a gamepad
  97584. * @param vrGamepad the gamepad that the controller should be created from
  97585. */
  97586. constructor(vrGamepad: any);
  97587. /**
  97588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97589. * @param scene scene in which to add meshes
  97590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97591. */
  97592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97593. /**
  97594. * Called once for each button that changed state since the last frame
  97595. * @param buttonIdx Which button index changed
  97596. * @param state New state of the button
  97597. * @param changes Which properties on the state changed since last frame
  97598. */
  97599. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97600. }
  97601. }
  97602. declare module BABYLON {
  97603. /**
  97604. * Oculus Touch Controller
  97605. */
  97606. export class OculusTouchController extends WebVRController {
  97607. /**
  97608. * Base Url for the controller model.
  97609. */
  97610. static MODEL_BASE_URL: string;
  97611. /**
  97612. * File name for the left controller model.
  97613. */
  97614. static MODEL_LEFT_FILENAME: string;
  97615. /**
  97616. * File name for the right controller model.
  97617. */
  97618. static MODEL_RIGHT_FILENAME: string;
  97619. /**
  97620. * Fired when the secondary trigger on this controller is modified
  97621. */
  97622. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97623. /**
  97624. * Fired when the thumb rest on this controller is modified
  97625. */
  97626. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97627. /**
  97628. * Creates a new OculusTouchController from a gamepad
  97629. * @param vrGamepad the gamepad that the controller should be created from
  97630. */
  97631. constructor(vrGamepad: any);
  97632. /**
  97633. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97634. * @param scene scene in which to add meshes
  97635. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97636. */
  97637. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97638. /**
  97639. * Fired when the A button on this controller is modified
  97640. */
  97641. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97642. /**
  97643. * Fired when the B button on this controller is modified
  97644. */
  97645. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97646. /**
  97647. * Fired when the X button on this controller is modified
  97648. */
  97649. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97650. /**
  97651. * Fired when the Y button on this controller is modified
  97652. */
  97653. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97654. /**
  97655. * Called once for each button that changed state since the last frame
  97656. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97657. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97658. * 2) secondary trigger (same)
  97659. * 3) A (right) X (left), touch, pressed = value
  97660. * 4) B / Y
  97661. * 5) thumb rest
  97662. * @param buttonIdx Which button index changed
  97663. * @param state New state of the button
  97664. * @param changes Which properties on the state changed since last frame
  97665. */
  97666. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97667. }
  97668. }
  97669. declare module BABYLON {
  97670. /**
  97671. * Vive Controller
  97672. */
  97673. export class ViveController extends WebVRController {
  97674. /**
  97675. * Base Url for the controller model.
  97676. */
  97677. static MODEL_BASE_URL: string;
  97678. /**
  97679. * File name for the controller model.
  97680. */
  97681. static MODEL_FILENAME: string;
  97682. /**
  97683. * Creates a new ViveController from a gamepad
  97684. * @param vrGamepad the gamepad that the controller should be created from
  97685. */
  97686. constructor(vrGamepad: any);
  97687. /**
  97688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97689. * @param scene scene in which to add meshes
  97690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97691. */
  97692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97693. /**
  97694. * Fired when the left button on this controller is modified
  97695. */
  97696. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97697. /**
  97698. * Fired when the right button on this controller is modified
  97699. */
  97700. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97701. /**
  97702. * Fired when the menu button on this controller is modified
  97703. */
  97704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97705. /**
  97706. * Called once for each button that changed state since the last frame
  97707. * Vive mapping:
  97708. * 0: touchpad
  97709. * 1: trigger
  97710. * 2: left AND right buttons
  97711. * 3: menu button
  97712. * @param buttonIdx Which button index changed
  97713. * @param state New state of the button
  97714. * @param changes Which properties on the state changed since last frame
  97715. */
  97716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * Defines the WindowsMotionController object that the state of the windows motion controller
  97722. */
  97723. export class WindowsMotionController extends WebVRController {
  97724. /**
  97725. * The base url used to load the left and right controller models
  97726. */
  97727. static MODEL_BASE_URL: string;
  97728. /**
  97729. * The name of the left controller model file
  97730. */
  97731. static MODEL_LEFT_FILENAME: string;
  97732. /**
  97733. * The name of the right controller model file
  97734. */
  97735. static MODEL_RIGHT_FILENAME: string;
  97736. /**
  97737. * The controller name prefix for this controller type
  97738. */
  97739. static readonly GAMEPAD_ID_PREFIX: string;
  97740. /**
  97741. * The controller id pattern for this controller type
  97742. */
  97743. private static readonly GAMEPAD_ID_PATTERN;
  97744. private _loadedMeshInfo;
  97745. private readonly _mapping;
  97746. /**
  97747. * Fired when the trackpad on this controller is clicked
  97748. */
  97749. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97750. /**
  97751. * Fired when the trackpad on this controller is modified
  97752. */
  97753. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97754. /**
  97755. * The current x and y values of this controller's trackpad
  97756. */
  97757. trackpad: StickValues;
  97758. /**
  97759. * Creates a new WindowsMotionController from a gamepad
  97760. * @param vrGamepad the gamepad that the controller should be created from
  97761. */
  97762. constructor(vrGamepad: any);
  97763. /**
  97764. * Fired when the trigger on this controller is modified
  97765. */
  97766. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97767. /**
  97768. * Fired when the menu button on this controller is modified
  97769. */
  97770. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97771. /**
  97772. * Fired when the grip button on this controller is modified
  97773. */
  97774. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97775. /**
  97776. * Fired when the thumbstick button on this controller is modified
  97777. */
  97778. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97779. /**
  97780. * Fired when the touchpad button on this controller is modified
  97781. */
  97782. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97783. /**
  97784. * Fired when the touchpad values on this controller are modified
  97785. */
  97786. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97787. private _updateTrackpad;
  97788. /**
  97789. * Called once per frame by the engine.
  97790. */
  97791. update(): void;
  97792. /**
  97793. * Called once for each button that changed state since the last frame
  97794. * @param buttonIdx Which button index changed
  97795. * @param state New state of the button
  97796. * @param changes Which properties on the state changed since last frame
  97797. */
  97798. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97799. /**
  97800. * Moves the buttons on the controller mesh based on their current state
  97801. * @param buttonName the name of the button to move
  97802. * @param buttonValue the value of the button which determines the buttons new position
  97803. */
  97804. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97805. /**
  97806. * Moves the axis on the controller mesh based on its current state
  97807. * @param axis the index of the axis
  97808. * @param axisValue the value of the axis which determines the meshes new position
  97809. * @hidden
  97810. */
  97811. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97812. /**
  97813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97814. * @param scene scene in which to add meshes
  97815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97816. */
  97817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97818. /**
  97819. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97820. * can be transformed by button presses and axes values, based on this._mapping.
  97821. *
  97822. * @param scene scene in which the meshes exist
  97823. * @param meshes list of meshes that make up the controller model to process
  97824. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97825. */
  97826. private processModel;
  97827. private createMeshInfo;
  97828. /**
  97829. * Gets the ray of the controller in the direction the controller is pointing
  97830. * @param length the length the resulting ray should be
  97831. * @returns a ray in the direction the controller is pointing
  97832. */
  97833. getForwardRay(length?: number): Ray;
  97834. /**
  97835. * Disposes of the controller
  97836. */
  97837. dispose(): void;
  97838. }
  97839. }
  97840. declare module BABYLON {
  97841. /**
  97842. * Single axis scale gizmo
  97843. */
  97844. export class AxisScaleGizmo extends Gizmo {
  97845. private _coloredMaterial;
  97846. /**
  97847. * Drag behavior responsible for the gizmos dragging interactions
  97848. */
  97849. dragBehavior: PointerDragBehavior;
  97850. private _pointerObserver;
  97851. /**
  97852. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97853. */
  97854. snapDistance: number;
  97855. /**
  97856. * Event that fires each time the gizmo snaps to a new location.
  97857. * * snapDistance is the the change in distance
  97858. */
  97859. onSnapObservable: Observable<{
  97860. snapDistance: number;
  97861. }>;
  97862. /**
  97863. * If the scaling operation should be done on all axis (default: false)
  97864. */
  97865. uniformScaling: boolean;
  97866. /**
  97867. * Creates an AxisScaleGizmo
  97868. * @param gizmoLayer The utility layer the gizmo will be added to
  97869. * @param dragAxis The axis which the gizmo will be able to scale on
  97870. * @param color The color of the gizmo
  97871. */
  97872. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97874. /**
  97875. * Disposes of the gizmo
  97876. */
  97877. dispose(): void;
  97878. /**
  97879. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97880. * @param mesh The mesh to replace the default mesh of the gizmo
  97881. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97882. */
  97883. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97884. }
  97885. }
  97886. declare module BABYLON {
  97887. /**
  97888. * Bounding box gizmo
  97889. */
  97890. export class BoundingBoxGizmo extends Gizmo {
  97891. private _lineBoundingBox;
  97892. private _rotateSpheresParent;
  97893. private _scaleBoxesParent;
  97894. private _boundingDimensions;
  97895. private _renderObserver;
  97896. private _pointerObserver;
  97897. private _scaleDragSpeed;
  97898. private _tmpQuaternion;
  97899. private _tmpVector;
  97900. private _tmpRotationMatrix;
  97901. /**
  97902. * 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)
  97903. */
  97904. ignoreChildren: boolean;
  97905. /**
  97906. * 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)
  97907. */
  97908. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97909. /**
  97910. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97911. */
  97912. rotationSphereSize: number;
  97913. /**
  97914. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97915. */
  97916. scaleBoxSize: number;
  97917. /**
  97918. * 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)
  97919. */
  97920. fixedDragMeshScreenSize: boolean;
  97921. /**
  97922. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97923. */
  97924. fixedDragMeshScreenSizeDistanceFactor: number;
  97925. /**
  97926. * Fired when a rotation sphere or scale box is dragged
  97927. */
  97928. onDragStartObservable: Observable<{}>;
  97929. /**
  97930. * Fired when a scale box is dragged
  97931. */
  97932. onScaleBoxDragObservable: Observable<{}>;
  97933. /**
  97934. * Fired when a scale box drag is ended
  97935. */
  97936. onScaleBoxDragEndObservable: Observable<{}>;
  97937. /**
  97938. * Fired when a rotation sphere is dragged
  97939. */
  97940. onRotationSphereDragObservable: Observable<{}>;
  97941. /**
  97942. * Fired when a rotation sphere drag is ended
  97943. */
  97944. onRotationSphereDragEndObservable: Observable<{}>;
  97945. /**
  97946. * 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)
  97947. */
  97948. scalePivot: Nullable<Vector3>;
  97949. private _anchorMesh;
  97950. private _existingMeshScale;
  97951. private _dragMesh;
  97952. private pointerDragBehavior;
  97953. /**
  97954. * Creates an BoundingBoxGizmo
  97955. * @param gizmoLayer The utility layer the gizmo will be added to
  97956. * @param color The color of the gizmo
  97957. */
  97958. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97959. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97960. private _selectNode;
  97961. /**
  97962. * Updates the bounding box information for the Gizmo
  97963. */
  97964. updateBoundingBox(): void;
  97965. private _updateRotationSpheres;
  97966. private _updateScaleBoxes;
  97967. /**
  97968. * Enables rotation on the specified axis and disables rotation on the others
  97969. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97970. */
  97971. setEnabledRotationAxis(axis: string): void;
  97972. /**
  97973. * Enables/disables scaling
  97974. * @param enable if scaling should be enabled
  97975. */
  97976. setEnabledScaling(enable: boolean): void;
  97977. private _updateDummy;
  97978. /**
  97979. * Enables a pointer drag behavior on the bounding box of the gizmo
  97980. */
  97981. enableDragBehavior(): void;
  97982. /**
  97983. * Disposes of the gizmo
  97984. */
  97985. dispose(): void;
  97986. /**
  97987. * 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)
  97988. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97989. * @returns the bounding box mesh with the passed in mesh as a child
  97990. */
  97991. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97992. /**
  97993. * CustomMeshes are not supported by this gizmo
  97994. * @param mesh The mesh to replace the default mesh of the gizmo
  97995. */
  97996. setCustomMesh(mesh: Mesh): void;
  97997. }
  97998. }
  97999. declare module BABYLON {
  98000. /**
  98001. * Single plane rotation gizmo
  98002. */
  98003. export class PlaneRotationGizmo extends Gizmo {
  98004. /**
  98005. * Drag behavior responsible for the gizmos dragging interactions
  98006. */
  98007. dragBehavior: PointerDragBehavior;
  98008. private _pointerObserver;
  98009. /**
  98010. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98011. */
  98012. snapDistance: number;
  98013. /**
  98014. * Event that fires each time the gizmo snaps to a new location.
  98015. * * snapDistance is the the change in distance
  98016. */
  98017. onSnapObservable: Observable<{
  98018. snapDistance: number;
  98019. }>;
  98020. /**
  98021. * Creates a PlaneRotationGizmo
  98022. * @param gizmoLayer The utility layer the gizmo will be added to
  98023. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98024. * @param color The color of the gizmo
  98025. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98026. */
  98027. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98028. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98029. /**
  98030. * Disposes of the gizmo
  98031. */
  98032. dispose(): void;
  98033. }
  98034. }
  98035. declare module BABYLON {
  98036. /**
  98037. * Gizmo that enables rotating a mesh along 3 axis
  98038. */
  98039. export class RotationGizmo extends Gizmo {
  98040. /**
  98041. * Internal gizmo used for interactions on the x axis
  98042. */
  98043. xGizmo: PlaneRotationGizmo;
  98044. /**
  98045. * Internal gizmo used for interactions on the y axis
  98046. */
  98047. yGizmo: PlaneRotationGizmo;
  98048. /**
  98049. * Internal gizmo used for interactions on the z axis
  98050. */
  98051. zGizmo: PlaneRotationGizmo;
  98052. /** Fires an event when any of it's sub gizmos are dragged */
  98053. onDragStartObservable: Observable<{}>;
  98054. /** Fires an event when any of it's sub gizmos are released from dragging */
  98055. onDragEndObservable: Observable<{}>;
  98056. attachedMesh: Nullable<AbstractMesh>;
  98057. /**
  98058. * Creates a RotationGizmo
  98059. * @param gizmoLayer The utility layer the gizmo will be added to
  98060. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98061. */
  98062. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98063. updateGizmoRotationToMatchAttachedMesh: boolean;
  98064. /**
  98065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98066. */
  98067. snapDistance: number;
  98068. /**
  98069. * Ratio for the scale of the gizmo (Default: 1)
  98070. */
  98071. scaleRatio: number;
  98072. /**
  98073. * Disposes of the gizmo
  98074. */
  98075. dispose(): void;
  98076. /**
  98077. * CustomMeshes are not supported by this gizmo
  98078. * @param mesh The mesh to replace the default mesh of the gizmo
  98079. */
  98080. setCustomMesh(mesh: Mesh): void;
  98081. }
  98082. }
  98083. declare module BABYLON {
  98084. /**
  98085. * Gizmo that enables dragging a mesh along 3 axis
  98086. */
  98087. export class PositionGizmo extends Gizmo {
  98088. /**
  98089. * Internal gizmo used for interactions on the x axis
  98090. */
  98091. xGizmo: AxisDragGizmo;
  98092. /**
  98093. * Internal gizmo used for interactions on the y axis
  98094. */
  98095. yGizmo: AxisDragGizmo;
  98096. /**
  98097. * Internal gizmo used for interactions on the z axis
  98098. */
  98099. zGizmo: AxisDragGizmo;
  98100. /** Fires an event when any of it's sub gizmos are dragged */
  98101. onDragStartObservable: Observable<{}>;
  98102. /** Fires an event when any of it's sub gizmos are released from dragging */
  98103. onDragEndObservable: Observable<{}>;
  98104. attachedMesh: Nullable<AbstractMesh>;
  98105. /**
  98106. * Creates a PositionGizmo
  98107. * @param gizmoLayer The utility layer the gizmo will be added to
  98108. */
  98109. constructor(gizmoLayer?: UtilityLayerRenderer);
  98110. updateGizmoRotationToMatchAttachedMesh: boolean;
  98111. /**
  98112. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98113. */
  98114. snapDistance: number;
  98115. /**
  98116. * Ratio for the scale of the gizmo (Default: 1)
  98117. */
  98118. scaleRatio: number;
  98119. /**
  98120. * Disposes of the gizmo
  98121. */
  98122. dispose(): void;
  98123. /**
  98124. * CustomMeshes are not supported by this gizmo
  98125. * @param mesh The mesh to replace the default mesh of the gizmo
  98126. */
  98127. setCustomMesh(mesh: Mesh): void;
  98128. }
  98129. }
  98130. declare module BABYLON {
  98131. /**
  98132. * Class containing static functions to help procedurally build meshes
  98133. */
  98134. export class PolyhedronBuilder {
  98135. /**
  98136. * Creates a polyhedron mesh
  98137. * * 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
  98138. * * The parameter `size` (positive float, default 1) sets the polygon size
  98139. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98140. * * 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`
  98141. * * 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
  98142. * * 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)`)
  98143. * * 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
  98144. * * 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
  98145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98148. * @param name defines the name of the mesh
  98149. * @param options defines the options used to create the mesh
  98150. * @param scene defines the hosting scene
  98151. * @returns the polyhedron mesh
  98152. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  98153. */
  98154. static CreatePolyhedron(name: string, options: {
  98155. type?: number;
  98156. size?: number;
  98157. sizeX?: number;
  98158. sizeY?: number;
  98159. sizeZ?: number;
  98160. custom?: any;
  98161. faceUV?: Vector4[];
  98162. faceColors?: Color4[];
  98163. flat?: boolean;
  98164. updatable?: boolean;
  98165. sideOrientation?: number;
  98166. frontUVs?: Vector4;
  98167. backUVs?: Vector4;
  98168. }, scene: Scene): Mesh;
  98169. }
  98170. }
  98171. declare module BABYLON {
  98172. /**
  98173. * Gizmo that enables scaling a mesh along 3 axis
  98174. */
  98175. export class ScaleGizmo extends Gizmo {
  98176. /**
  98177. * Internal gizmo used for interactions on the x axis
  98178. */
  98179. xGizmo: AxisScaleGizmo;
  98180. /**
  98181. * Internal gizmo used for interactions on the y axis
  98182. */
  98183. yGizmo: AxisScaleGizmo;
  98184. /**
  98185. * Internal gizmo used for interactions on the z axis
  98186. */
  98187. zGizmo: AxisScaleGizmo;
  98188. /**
  98189. * Internal gizmo used to scale all axis equally
  98190. */
  98191. uniformScaleGizmo: AxisScaleGizmo;
  98192. /** Fires an event when any of it's sub gizmos are dragged */
  98193. onDragStartObservable: Observable<{}>;
  98194. /** Fires an event when any of it's sub gizmos are released from dragging */
  98195. onDragEndObservable: Observable<{}>;
  98196. attachedMesh: Nullable<AbstractMesh>;
  98197. /**
  98198. * Creates a ScaleGizmo
  98199. * @param gizmoLayer The utility layer the gizmo will be added to
  98200. */
  98201. constructor(gizmoLayer?: UtilityLayerRenderer);
  98202. updateGizmoRotationToMatchAttachedMesh: boolean;
  98203. /**
  98204. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98205. */
  98206. snapDistance: number;
  98207. /**
  98208. * Ratio for the scale of the gizmo (Default: 1)
  98209. */
  98210. scaleRatio: number;
  98211. /**
  98212. * Disposes of the gizmo
  98213. */
  98214. dispose(): void;
  98215. }
  98216. }
  98217. declare module BABYLON {
  98218. /**
  98219. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  98220. */
  98221. export class GizmoManager implements IDisposable {
  98222. private scene;
  98223. /**
  98224. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  98225. */
  98226. gizmos: {
  98227. positionGizmo: Nullable<PositionGizmo>;
  98228. rotationGizmo: Nullable<RotationGizmo>;
  98229. scaleGizmo: Nullable<ScaleGizmo>;
  98230. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  98231. };
  98232. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  98233. clearGizmoOnEmptyPointerEvent: boolean;
  98234. /** Fires an event when the manager is attached to a mesh */
  98235. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  98236. private _gizmosEnabled;
  98237. private _pointerObserver;
  98238. private _attachedMesh;
  98239. private _boundingBoxColor;
  98240. private _defaultUtilityLayer;
  98241. private _defaultKeepDepthUtilityLayer;
  98242. /**
  98243. * When bounding box gizmo is enabled, this can be used to track drag/end events
  98244. */
  98245. boundingBoxDragBehavior: SixDofDragBehavior;
  98246. /**
  98247. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  98248. */
  98249. attachableMeshes: Nullable<Array<AbstractMesh>>;
  98250. /**
  98251. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  98252. */
  98253. usePointerToAttachGizmos: boolean;
  98254. /**
  98255. * Instatiates a gizmo manager
  98256. * @param scene the scene to overlay the gizmos on top of
  98257. */
  98258. constructor(scene: Scene);
  98259. /**
  98260. * Attaches a set of gizmos to the specified mesh
  98261. * @param mesh The mesh the gizmo's should be attached to
  98262. */
  98263. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  98264. /**
  98265. * If the position gizmo is enabled
  98266. */
  98267. positionGizmoEnabled: boolean;
  98268. /**
  98269. * If the rotation gizmo is enabled
  98270. */
  98271. rotationGizmoEnabled: boolean;
  98272. /**
  98273. * If the scale gizmo is enabled
  98274. */
  98275. scaleGizmoEnabled: boolean;
  98276. /**
  98277. * If the boundingBox gizmo is enabled
  98278. */
  98279. boundingBoxGizmoEnabled: boolean;
  98280. /**
  98281. * Disposes of the gizmo manager
  98282. */
  98283. dispose(): void;
  98284. }
  98285. }
  98286. declare module BABYLON {
  98287. /**
  98288. * Gizmo that enables viewing a light
  98289. */
  98290. export class LightGizmo extends Gizmo {
  98291. private _box;
  98292. /**
  98293. * Creates a LightGizmo
  98294. * @param gizmoLayer The utility layer the gizmo will be added to
  98295. */
  98296. constructor(gizmoLayer?: UtilityLayerRenderer);
  98297. private _light;
  98298. /**
  98299. * The light that the gizmo is attached to
  98300. */
  98301. light: Nullable<Light>;
  98302. /**
  98303. * @hidden
  98304. * Updates the gizmo to match the attached mesh's position/rotation
  98305. */
  98306. protected _update(): void;
  98307. }
  98308. }
  98309. declare module BABYLON {
  98310. /** @hidden */
  98311. export var backgroundFragmentDeclaration: {
  98312. name: string;
  98313. shader: string;
  98314. };
  98315. }
  98316. declare module BABYLON {
  98317. /** @hidden */
  98318. export var backgroundUboDeclaration: {
  98319. name: string;
  98320. shader: string;
  98321. };
  98322. }
  98323. declare module BABYLON {
  98324. /** @hidden */
  98325. export var backgroundPixelShader: {
  98326. name: string;
  98327. shader: string;
  98328. };
  98329. }
  98330. declare module BABYLON {
  98331. /** @hidden */
  98332. export var backgroundVertexDeclaration: {
  98333. name: string;
  98334. shader: string;
  98335. };
  98336. }
  98337. declare module BABYLON {
  98338. /** @hidden */
  98339. export var backgroundVertexShader: {
  98340. name: string;
  98341. shader: string;
  98342. };
  98343. }
  98344. declare module BABYLON {
  98345. /**
  98346. * Background material used to create an efficient environement around your scene.
  98347. */
  98348. export class BackgroundMaterial extends PushMaterial {
  98349. /**
  98350. * Standard reflectance value at parallel view angle.
  98351. */
  98352. static StandardReflectance0: number;
  98353. /**
  98354. * Standard reflectance value at grazing angle.
  98355. */
  98356. static StandardReflectance90: number;
  98357. protected _primaryColor: Color3;
  98358. /**
  98359. * Key light Color (multiply against the environement texture)
  98360. */
  98361. primaryColor: Color3;
  98362. protected __perceptualColor: Nullable<Color3>;
  98363. /**
  98364. * Experimental Internal Use Only.
  98365. *
  98366. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98367. * This acts as a helper to set the primary color to a more "human friendly" value.
  98368. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98369. * output color as close as possible from the chosen value.
  98370. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98371. * part of lighting setup.)
  98372. */
  98373. _perceptualColor: Nullable<Color3>;
  98374. protected _primaryColorShadowLevel: float;
  98375. /**
  98376. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98377. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98378. */
  98379. primaryColorShadowLevel: float;
  98380. protected _primaryColorHighlightLevel: float;
  98381. /**
  98382. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98383. * The primary color is used at the level chosen to define what the white area would look.
  98384. */
  98385. primaryColorHighlightLevel: float;
  98386. protected _reflectionTexture: Nullable<BaseTexture>;
  98387. /**
  98388. * Reflection Texture used in the material.
  98389. * Should be author in a specific way for the best result (refer to the documentation).
  98390. */
  98391. reflectionTexture: Nullable<BaseTexture>;
  98392. protected _reflectionBlur: float;
  98393. /**
  98394. * Reflection Texture level of blur.
  98395. *
  98396. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98397. * texture twice.
  98398. */
  98399. reflectionBlur: float;
  98400. protected _diffuseTexture: Nullable<BaseTexture>;
  98401. /**
  98402. * Diffuse Texture used in the material.
  98403. * Should be author in a specific way for the best result (refer to the documentation).
  98404. */
  98405. diffuseTexture: Nullable<BaseTexture>;
  98406. protected _shadowLights: Nullable<IShadowLight[]>;
  98407. /**
  98408. * Specify the list of lights casting shadow on the material.
  98409. * All scene shadow lights will be included if null.
  98410. */
  98411. shadowLights: Nullable<IShadowLight[]>;
  98412. protected _shadowLevel: float;
  98413. /**
  98414. * Helps adjusting the shadow to a softer level if required.
  98415. * 0 means black shadows and 1 means no shadows.
  98416. */
  98417. shadowLevel: float;
  98418. protected _sceneCenter: Vector3;
  98419. /**
  98420. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98421. * It is usually zero but might be interesting to modify according to your setup.
  98422. */
  98423. sceneCenter: Vector3;
  98424. protected _opacityFresnel: boolean;
  98425. /**
  98426. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98427. * This helps ensuring a nice transition when the camera goes under the ground.
  98428. */
  98429. opacityFresnel: boolean;
  98430. protected _reflectionFresnel: boolean;
  98431. /**
  98432. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98433. * This helps adding a mirror texture on the ground.
  98434. */
  98435. reflectionFresnel: boolean;
  98436. protected _reflectionFalloffDistance: number;
  98437. /**
  98438. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98439. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98440. */
  98441. reflectionFalloffDistance: number;
  98442. protected _reflectionAmount: number;
  98443. /**
  98444. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98445. */
  98446. reflectionAmount: number;
  98447. protected _reflectionReflectance0: number;
  98448. /**
  98449. * This specifies the weight of the reflection at grazing angle.
  98450. */
  98451. reflectionReflectance0: number;
  98452. protected _reflectionReflectance90: number;
  98453. /**
  98454. * This specifies the weight of the reflection at a perpendicular point of view.
  98455. */
  98456. reflectionReflectance90: number;
  98457. /**
  98458. * Sets the reflection reflectance fresnel values according to the default standard
  98459. * empirically know to work well :-)
  98460. */
  98461. reflectionStandardFresnelWeight: number;
  98462. protected _useRGBColor: boolean;
  98463. /**
  98464. * Helps to directly use the maps channels instead of their level.
  98465. */
  98466. useRGBColor: boolean;
  98467. protected _enableNoise: boolean;
  98468. /**
  98469. * This helps reducing the banding effect that could occur on the background.
  98470. */
  98471. enableNoise: boolean;
  98472. /**
  98473. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98474. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98475. * Recommended to be keep at 1.0 except for special cases.
  98476. */
  98477. fovMultiplier: number;
  98478. private _fovMultiplier;
  98479. /**
  98480. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98481. */
  98482. useEquirectangularFOV: boolean;
  98483. private _maxSimultaneousLights;
  98484. /**
  98485. * Number of Simultaneous lights allowed on the material.
  98486. */
  98487. maxSimultaneousLights: int;
  98488. /**
  98489. * Default configuration related to image processing available in the Background Material.
  98490. */
  98491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98492. /**
  98493. * Keep track of the image processing observer to allow dispose and replace.
  98494. */
  98495. private _imageProcessingObserver;
  98496. /**
  98497. * Attaches a new image processing configuration to the PBR Material.
  98498. * @param configuration (if null the scene configuration will be use)
  98499. */
  98500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98501. /**
  98502. * Gets the image processing configuration used either in this material.
  98503. */
  98504. /**
  98505. * Sets the Default image processing configuration used either in the this material.
  98506. *
  98507. * If sets to null, the scene one is in use.
  98508. */
  98509. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98510. /**
  98511. * Gets wether the color curves effect is enabled.
  98512. */
  98513. /**
  98514. * Sets wether the color curves effect is enabled.
  98515. */
  98516. cameraColorCurvesEnabled: boolean;
  98517. /**
  98518. * Gets wether the color grading effect is enabled.
  98519. */
  98520. /**
  98521. * Gets wether the color grading effect is enabled.
  98522. */
  98523. cameraColorGradingEnabled: boolean;
  98524. /**
  98525. * Gets wether tonemapping is enabled or not.
  98526. */
  98527. /**
  98528. * Sets wether tonemapping is enabled or not
  98529. */
  98530. cameraToneMappingEnabled: boolean;
  98531. /**
  98532. * The camera exposure used on this material.
  98533. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98534. * This corresponds to a photographic exposure.
  98535. */
  98536. /**
  98537. * The camera exposure used on this material.
  98538. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98539. * This corresponds to a photographic exposure.
  98540. */
  98541. cameraExposure: float;
  98542. /**
  98543. * Gets The camera contrast used on this material.
  98544. */
  98545. /**
  98546. * Sets The camera contrast used on this material.
  98547. */
  98548. cameraContrast: float;
  98549. /**
  98550. * Gets the Color Grading 2D Lookup Texture.
  98551. */
  98552. /**
  98553. * Sets the Color Grading 2D Lookup Texture.
  98554. */
  98555. cameraColorGradingTexture: Nullable<BaseTexture>;
  98556. /**
  98557. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98558. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98559. * 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;
  98560. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98561. */
  98562. /**
  98563. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98564. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98565. * 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;
  98566. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98567. */
  98568. cameraColorCurves: Nullable<ColorCurves>;
  98569. /**
  98570. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98571. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98572. */
  98573. switchToBGR: boolean;
  98574. private _renderTargets;
  98575. private _reflectionControls;
  98576. private _white;
  98577. private _primaryShadowColor;
  98578. private _primaryHighlightColor;
  98579. /**
  98580. * Instantiates a Background Material in the given scene
  98581. * @param name The friendly name of the material
  98582. * @param scene The scene to add the material to
  98583. */
  98584. constructor(name: string, scene: Scene);
  98585. /**
  98586. * Gets a boolean indicating that current material needs to register RTT
  98587. */
  98588. readonly hasRenderTargetTextures: boolean;
  98589. /**
  98590. * The entire material has been created in order to prevent overdraw.
  98591. * @returns false
  98592. */
  98593. needAlphaTesting(): boolean;
  98594. /**
  98595. * The entire material has been created in order to prevent overdraw.
  98596. * @returns true if blending is enable
  98597. */
  98598. needAlphaBlending(): boolean;
  98599. /**
  98600. * Checks wether the material is ready to be rendered for a given mesh.
  98601. * @param mesh The mesh to render
  98602. * @param subMesh The submesh to check against
  98603. * @param useInstances Specify wether or not the material is used with instances
  98604. * @returns true if all the dependencies are ready (Textures, Effects...)
  98605. */
  98606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98607. /**
  98608. * Compute the primary color according to the chosen perceptual color.
  98609. */
  98610. private _computePrimaryColorFromPerceptualColor;
  98611. /**
  98612. * Compute the highlights and shadow colors according to their chosen levels.
  98613. */
  98614. private _computePrimaryColors;
  98615. /**
  98616. * Build the uniform buffer used in the material.
  98617. */
  98618. buildUniformLayout(): void;
  98619. /**
  98620. * Unbind the material.
  98621. */
  98622. unbind(): void;
  98623. /**
  98624. * Bind only the world matrix to the material.
  98625. * @param world The world matrix to bind.
  98626. */
  98627. bindOnlyWorldMatrix(world: Matrix): void;
  98628. /**
  98629. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98630. * @param world The world matrix to bind.
  98631. * @param subMesh The submesh to bind for.
  98632. */
  98633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98634. /**
  98635. * Dispose the material.
  98636. * @param forceDisposeEffect Force disposal of the associated effect.
  98637. * @param forceDisposeTextures Force disposal of the associated textures.
  98638. */
  98639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98640. /**
  98641. * Clones the material.
  98642. * @param name The cloned name.
  98643. * @returns The cloned material.
  98644. */
  98645. clone(name: string): BackgroundMaterial;
  98646. /**
  98647. * Serializes the current material to its JSON representation.
  98648. * @returns The JSON representation.
  98649. */
  98650. serialize(): any;
  98651. /**
  98652. * Gets the class name of the material
  98653. * @returns "BackgroundMaterial"
  98654. */
  98655. getClassName(): string;
  98656. /**
  98657. * Parse a JSON input to create back a background material.
  98658. * @param source The JSON data to parse
  98659. * @param scene The scene to create the parsed material in
  98660. * @param rootUrl The root url of the assets the material depends upon
  98661. * @returns the instantiated BackgroundMaterial.
  98662. */
  98663. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98664. }
  98665. }
  98666. declare module BABYLON {
  98667. /**
  98668. * Represents the different options available during the creation of
  98669. * a Environment helper.
  98670. *
  98671. * This can control the default ground, skybox and image processing setup of your scene.
  98672. */
  98673. export interface IEnvironmentHelperOptions {
  98674. /**
  98675. * Specifies wether or not to create a ground.
  98676. * True by default.
  98677. */
  98678. createGround: boolean;
  98679. /**
  98680. * Specifies the ground size.
  98681. * 15 by default.
  98682. */
  98683. groundSize: number;
  98684. /**
  98685. * The texture used on the ground for the main color.
  98686. * Comes from the BabylonJS CDN by default.
  98687. *
  98688. * Remarks: Can be either a texture or a url.
  98689. */
  98690. groundTexture: string | BaseTexture;
  98691. /**
  98692. * The color mixed in the ground texture by default.
  98693. * BabylonJS clearColor by default.
  98694. */
  98695. groundColor: Color3;
  98696. /**
  98697. * Specifies the ground opacity.
  98698. * 1 by default.
  98699. */
  98700. groundOpacity: number;
  98701. /**
  98702. * Enables the ground to receive shadows.
  98703. * True by default.
  98704. */
  98705. enableGroundShadow: boolean;
  98706. /**
  98707. * Helps preventing the shadow to be fully black on the ground.
  98708. * 0.5 by default.
  98709. */
  98710. groundShadowLevel: number;
  98711. /**
  98712. * Creates a mirror texture attach to the ground.
  98713. * false by default.
  98714. */
  98715. enableGroundMirror: boolean;
  98716. /**
  98717. * Specifies the ground mirror size ratio.
  98718. * 0.3 by default as the default kernel is 64.
  98719. */
  98720. groundMirrorSizeRatio: number;
  98721. /**
  98722. * Specifies the ground mirror blur kernel size.
  98723. * 64 by default.
  98724. */
  98725. groundMirrorBlurKernel: number;
  98726. /**
  98727. * Specifies the ground mirror visibility amount.
  98728. * 1 by default
  98729. */
  98730. groundMirrorAmount: number;
  98731. /**
  98732. * Specifies the ground mirror reflectance weight.
  98733. * This uses the standard weight of the background material to setup the fresnel effect
  98734. * of the mirror.
  98735. * 1 by default.
  98736. */
  98737. groundMirrorFresnelWeight: number;
  98738. /**
  98739. * Specifies the ground mirror Falloff distance.
  98740. * This can helps reducing the size of the reflection.
  98741. * 0 by Default.
  98742. */
  98743. groundMirrorFallOffDistance: number;
  98744. /**
  98745. * Specifies the ground mirror texture type.
  98746. * Unsigned Int by Default.
  98747. */
  98748. groundMirrorTextureType: number;
  98749. /**
  98750. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98751. * the shown objects.
  98752. */
  98753. groundYBias: number;
  98754. /**
  98755. * Specifies wether or not to create a skybox.
  98756. * True by default.
  98757. */
  98758. createSkybox: boolean;
  98759. /**
  98760. * Specifies the skybox size.
  98761. * 20 by default.
  98762. */
  98763. skyboxSize: number;
  98764. /**
  98765. * The texture used on the skybox for the main color.
  98766. * Comes from the BabylonJS CDN by default.
  98767. *
  98768. * Remarks: Can be either a texture or a url.
  98769. */
  98770. skyboxTexture: string | BaseTexture;
  98771. /**
  98772. * The color mixed in the skybox texture by default.
  98773. * BabylonJS clearColor by default.
  98774. */
  98775. skyboxColor: Color3;
  98776. /**
  98777. * The background rotation around the Y axis of the scene.
  98778. * This helps aligning the key lights of your scene with the background.
  98779. * 0 by default.
  98780. */
  98781. backgroundYRotation: number;
  98782. /**
  98783. * Compute automatically the size of the elements to best fit with the scene.
  98784. */
  98785. sizeAuto: boolean;
  98786. /**
  98787. * Default position of the rootMesh if autoSize is not true.
  98788. */
  98789. rootPosition: Vector3;
  98790. /**
  98791. * Sets up the image processing in the scene.
  98792. * true by default.
  98793. */
  98794. setupImageProcessing: boolean;
  98795. /**
  98796. * The texture used as your environment texture in the scene.
  98797. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98798. *
  98799. * Remarks: Can be either a texture or a url.
  98800. */
  98801. environmentTexture: string | BaseTexture;
  98802. /**
  98803. * The value of the exposure to apply to the scene.
  98804. * 0.6 by default if setupImageProcessing is true.
  98805. */
  98806. cameraExposure: number;
  98807. /**
  98808. * The value of the contrast to apply to the scene.
  98809. * 1.6 by default if setupImageProcessing is true.
  98810. */
  98811. cameraContrast: number;
  98812. /**
  98813. * Specifies wether or not tonemapping should be enabled in the scene.
  98814. * true by default if setupImageProcessing is true.
  98815. */
  98816. toneMappingEnabled: boolean;
  98817. }
  98818. /**
  98819. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98820. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98821. * It also helps with the default setup of your imageProcessing configuration.
  98822. */
  98823. export class EnvironmentHelper {
  98824. /**
  98825. * Default ground texture URL.
  98826. */
  98827. private static _groundTextureCDNUrl;
  98828. /**
  98829. * Default skybox texture URL.
  98830. */
  98831. private static _skyboxTextureCDNUrl;
  98832. /**
  98833. * Default environment texture URL.
  98834. */
  98835. private static _environmentTextureCDNUrl;
  98836. /**
  98837. * Creates the default options for the helper.
  98838. */
  98839. private static _getDefaultOptions;
  98840. private _rootMesh;
  98841. /**
  98842. * Gets the root mesh created by the helper.
  98843. */
  98844. readonly rootMesh: Mesh;
  98845. private _skybox;
  98846. /**
  98847. * Gets the skybox created by the helper.
  98848. */
  98849. readonly skybox: Nullable<Mesh>;
  98850. private _skyboxTexture;
  98851. /**
  98852. * Gets the skybox texture created by the helper.
  98853. */
  98854. readonly skyboxTexture: Nullable<BaseTexture>;
  98855. private _skyboxMaterial;
  98856. /**
  98857. * Gets the skybox material created by the helper.
  98858. */
  98859. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98860. private _ground;
  98861. /**
  98862. * Gets the ground mesh created by the helper.
  98863. */
  98864. readonly ground: Nullable<Mesh>;
  98865. private _groundTexture;
  98866. /**
  98867. * Gets the ground texture created by the helper.
  98868. */
  98869. readonly groundTexture: Nullable<BaseTexture>;
  98870. private _groundMirror;
  98871. /**
  98872. * Gets the ground mirror created by the helper.
  98873. */
  98874. readonly groundMirror: Nullable<MirrorTexture>;
  98875. /**
  98876. * Gets the ground mirror render list to helps pushing the meshes
  98877. * you wish in the ground reflection.
  98878. */
  98879. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98880. private _groundMaterial;
  98881. /**
  98882. * Gets the ground material created by the helper.
  98883. */
  98884. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98885. /**
  98886. * Stores the creation options.
  98887. */
  98888. private readonly _scene;
  98889. private _options;
  98890. /**
  98891. * This observable will be notified with any error during the creation of the environment,
  98892. * mainly texture creation errors.
  98893. */
  98894. onErrorObservable: Observable<{
  98895. message?: string;
  98896. exception?: any;
  98897. }>;
  98898. /**
  98899. * constructor
  98900. * @param options Defines the options we want to customize the helper
  98901. * @param scene The scene to add the material to
  98902. */
  98903. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98904. /**
  98905. * Updates the background according to the new options
  98906. * @param options
  98907. */
  98908. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98909. /**
  98910. * Sets the primary color of all the available elements.
  98911. * @param color the main color to affect to the ground and the background
  98912. */
  98913. setMainColor(color: Color3): void;
  98914. /**
  98915. * Setup the image processing according to the specified options.
  98916. */
  98917. private _setupImageProcessing;
  98918. /**
  98919. * Setup the environment texture according to the specified options.
  98920. */
  98921. private _setupEnvironmentTexture;
  98922. /**
  98923. * Setup the background according to the specified options.
  98924. */
  98925. private _setupBackground;
  98926. /**
  98927. * Get the scene sizes according to the setup.
  98928. */
  98929. private _getSceneSize;
  98930. /**
  98931. * Setup the ground according to the specified options.
  98932. */
  98933. private _setupGround;
  98934. /**
  98935. * Setup the ground material according to the specified options.
  98936. */
  98937. private _setupGroundMaterial;
  98938. /**
  98939. * Setup the ground diffuse texture according to the specified options.
  98940. */
  98941. private _setupGroundDiffuseTexture;
  98942. /**
  98943. * Setup the ground mirror texture according to the specified options.
  98944. */
  98945. private _setupGroundMirrorTexture;
  98946. /**
  98947. * Setup the ground to receive the mirror texture.
  98948. */
  98949. private _setupMirrorInGroundMaterial;
  98950. /**
  98951. * Setup the skybox according to the specified options.
  98952. */
  98953. private _setupSkybox;
  98954. /**
  98955. * Setup the skybox material according to the specified options.
  98956. */
  98957. private _setupSkyboxMaterial;
  98958. /**
  98959. * Setup the skybox reflection texture according to the specified options.
  98960. */
  98961. private _setupSkyboxReflectionTexture;
  98962. private _errorHandler;
  98963. /**
  98964. * Dispose all the elements created by the Helper.
  98965. */
  98966. dispose(): void;
  98967. }
  98968. }
  98969. declare module BABYLON {
  98970. /**
  98971. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98972. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98973. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98974. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98975. */
  98976. export class PhotoDome extends TransformNode {
  98977. private _useDirectMapping;
  98978. /**
  98979. * The texture being displayed on the sphere
  98980. */
  98981. protected _photoTexture: Texture;
  98982. /**
  98983. * Gets or sets the texture being displayed on the sphere
  98984. */
  98985. photoTexture: Texture;
  98986. /**
  98987. * Observable raised when an error occured while loading the 360 image
  98988. */
  98989. onLoadErrorObservable: Observable<string>;
  98990. /**
  98991. * The skybox material
  98992. */
  98993. protected _material: BackgroundMaterial;
  98994. /**
  98995. * The surface used for the skybox
  98996. */
  98997. protected _mesh: Mesh;
  98998. /**
  98999. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99000. * Also see the options.resolution property.
  99001. */
  99002. fovMultiplier: number;
  99003. /**
  99004. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99005. * @param name Element's name, child elements will append suffixes for their own names.
  99006. * @param urlsOfPhoto defines the url of the photo to display
  99007. * @param options defines an object containing optional or exposed sub element properties
  99008. * @param onError defines a callback called when an error occured while loading the texture
  99009. */
  99010. constructor(name: string, urlOfPhoto: string, options: {
  99011. resolution?: number;
  99012. size?: number;
  99013. useDirectMapping?: boolean;
  99014. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99015. /**
  99016. * Releases resources associated with this node.
  99017. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99018. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99019. */
  99020. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99021. }
  99022. }
  99023. declare module BABYLON {
  99024. /**
  99025. * Class used to host texture specific utilities
  99026. */
  99027. export class TextureTools {
  99028. /**
  99029. * Uses the GPU to create a copy texture rescaled at a given size
  99030. * @param texture Texture to copy from
  99031. * @param width defines the desired width
  99032. * @param height defines the desired height
  99033. * @param useBilinearMode defines if bilinear mode has to be used
  99034. * @return the generated texture
  99035. */
  99036. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99037. /**
  99038. * Gets an environment BRDF texture for a given scene
  99039. * @param scene defines the hosting scene
  99040. * @returns the environment BRDF texture
  99041. */
  99042. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99043. private static _environmentBRDFBase64Texture;
  99044. }
  99045. }
  99046. declare module BABYLON {
  99047. /**
  99048. * @hidden
  99049. */
  99050. export interface IMaterialClearCoatDefines {
  99051. CLEARCOAT: boolean;
  99052. CLEARCOAT_TEXTURE: boolean;
  99053. CLEARCOAT_TEXTUREDIRECTUV: number;
  99054. CLEARCOAT_BUMP: boolean;
  99055. CLEARCOAT_BUMPDIRECTUV: number;
  99056. /** @hidden */
  99057. _areTexturesDirty: boolean;
  99058. }
  99059. /**
  99060. * Define the code related to the clear coat parameters of the pbr material.
  99061. */
  99062. export class PBRClearCoatConfiguration {
  99063. private _isEnabled;
  99064. /**
  99065. * Defines if the clear coat is enabled in the material.
  99066. */
  99067. isEnabled: boolean;
  99068. /**
  99069. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  99070. */
  99071. intensity: number;
  99072. /**
  99073. * Defines the clear coat layer roughness.
  99074. */
  99075. roughness: number;
  99076. private _texture;
  99077. /**
  99078. * Stores the clear coat values in a texture.
  99079. */
  99080. texture: Nullable<BaseTexture>;
  99081. private _bumpTexture;
  99082. /**
  99083. * Define the clear coat specific bump texture.
  99084. */
  99085. bumpTexture: Nullable<BaseTexture>;
  99086. /** @hidden */
  99087. private _internalMarkAllSubMeshesAsTexturesDirty;
  99088. /** @hidden */
  99089. _markAllSubMeshesAsTexturesDirty(): void;
  99090. /**
  99091. * Instantiate a new istance of clear coat configuration.
  99092. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  99093. */
  99094. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  99095. /**
  99096. * Specifies that the submesh is ready to be used.
  99097. * @param defines the list of "defines" to update.
  99098. * @param scene defines the scene the material belongs to.
  99099. * @param engine defines the engine the material belongs to.
  99100. * @param disableBumpMap defines wether the material disables bump or not.
  99101. * @returns - boolean indicating that the submesh is ready or not.
  99102. */
  99103. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  99104. /**
  99105. * Checks to see if a texture is used in the material.
  99106. * @param defines the list of "defines" to update.
  99107. * @param scene defines the scene to the material belongs to.
  99108. */
  99109. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  99110. /**
  99111. * Binds the material data.
  99112. * @param uniformBuffer defines the Uniform buffer to fill in.
  99113. * @param scene defines the scene the material belongs to.
  99114. * @param engine defines the engine the material belongs to.
  99115. * @param disableBumpMap defines wether the material disables bump or not.
  99116. * @param isFrozen defines wether the material is frozen or not.
  99117. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99118. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99119. */
  99120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  99121. /**
  99122. * Checks to see if a texture is used in the material.
  99123. * @param texture - Base texture to use.
  99124. * @returns - Boolean specifying if a texture is used in the material.
  99125. */
  99126. hasTexture(texture: BaseTexture): boolean;
  99127. /**
  99128. * Returns an array of the actively used textures.
  99129. * @param activeTextures Array of BaseTextures
  99130. */
  99131. getActiveTextures(activeTextures: BaseTexture[]): void;
  99132. /**
  99133. * Returns the animatable textures.
  99134. * @param animatables Array of animatable textures.
  99135. */
  99136. getAnimatables(animatables: IAnimatable[]): void;
  99137. /**
  99138. * Disposes the resources of the material.
  99139. * @param forceDisposeTextures - Forces the disposal of all textures.
  99140. */
  99141. dispose(forceDisposeTextures?: boolean): void;
  99142. /**
  99143. * Get the current class name of the texture useful for serialization or dynamic coding.
  99144. * @returns "PBRClearCoatConfiguration"
  99145. */
  99146. getClassName(): string;
  99147. /**
  99148. * Makes a duplicate of the current configuration into another one.
  99149. * @param clearCoatConfiguration define the config where to copy the info
  99150. */
  99151. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  99152. /**
  99153. * Serializes this clear coat configuration.
  99154. * @returns - An object with the serialized config.
  99155. */
  99156. serialize(): any;
  99157. /**
  99158. * Parses a Clear Coat Configuration from a serialized object.
  99159. * @param source - Serialized object.
  99160. */
  99161. parse(source: any): void;
  99162. /**
  99163. * Add fallbacks to the effect fallbacks list.
  99164. * @param defines defines the Base texture to use.
  99165. * @param fallbacks defines the current fallback list.
  99166. * @param currentRank defines the current fallback rank.
  99167. * @returns the new fallback rank.
  99168. */
  99169. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99170. /**
  99171. * Add the required uniforms to the current list.
  99172. * @param uniforms defines the current uniform list.
  99173. */
  99174. static AddUniforms(uniforms: string[]): void;
  99175. /**
  99176. * Add the required samplers to the current list.
  99177. * @param samplers defines the current sampler list.
  99178. */
  99179. static AddSamplers(samplers: string[]): void;
  99180. /**
  99181. * Add the required uniforms to the current buffer.
  99182. * @param uniformBuffer defines the current uniform buffer.
  99183. */
  99184. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99185. }
  99186. }
  99187. declare module BABYLON {
  99188. /**
  99189. * @hidden
  99190. */
  99191. export interface IMaterialAnisotropicDefines {
  99192. ANISOTROPIC: boolean;
  99193. MAINUV1: boolean;
  99194. _areMiscDirty: boolean;
  99195. _needUVs: boolean;
  99196. }
  99197. /**
  99198. * Define the code related to the anisotropic parameters of the pbr material.
  99199. */
  99200. export class PBRAnisotropicConfiguration {
  99201. private _isEnabled;
  99202. /**
  99203. * Defines if the anisotropy is enabled in the material.
  99204. */
  99205. isEnabled: boolean;
  99206. /**
  99207. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  99208. */
  99209. intensity: number;
  99210. /**
  99211. * Defines if the effect is along the tangents or bitangents.
  99212. * By default, the effect is "strectching" the highlights along the tangents.
  99213. */
  99214. followTangents: boolean;
  99215. /** @hidden */
  99216. private _internalMarkAllSubMeshesAsMiscDirty;
  99217. /** @hidden */
  99218. _markAllSubMeshesAsMiscDirty(): void;
  99219. /**
  99220. * Instantiate a new istance of clear coat configuration.
  99221. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  99222. */
  99223. constructor(markAllSubMeshesAsMiscDirty: () => void);
  99224. /**
  99225. * Checks to see if a texture is used in the material.
  99226. * @param defines the list of "defines" to update.
  99227. * @param mesh the mesh we are preparing the defines for.
  99228. */
  99229. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  99230. /**
  99231. * Binds the material data.
  99232. * @param uniformBuffer defines the Uniform buffer to fill in.
  99233. * @param isFrozen defines wether the material is frozen or not.
  99234. */
  99235. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  99236. /**
  99237. * Get the current class name of the texture useful for serialization or dynamic coding.
  99238. * @returns "PBRAnisotropicConfiguration"
  99239. */
  99240. getClassName(): string;
  99241. /**
  99242. * Makes a duplicate of the current configuration into another one.
  99243. * @param anisotropicConfiguration define the config where to copy the info
  99244. */
  99245. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  99246. /**
  99247. * Serializes this clear coat configuration.
  99248. * @returns - An object with the serialized config.
  99249. */
  99250. serialize(): any;
  99251. /**
  99252. * Parses a Clear Coat Configuration from a serialized object.
  99253. * @param source - Serialized object.
  99254. */
  99255. parse(source: any): void;
  99256. /**
  99257. * Add fallbacks to the effect fallbacks list.
  99258. * @param defines defines the Base texture to use.
  99259. * @param fallbacks defines the current fallback list.
  99260. * @param currentRank defines the current fallback rank.
  99261. * @returns the new fallback rank.
  99262. */
  99263. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99264. /**
  99265. * Add the required uniforms to the current list.
  99266. * @param uniforms defines the current uniform list.
  99267. */
  99268. static AddUniforms(uniforms: string[]): void;
  99269. /**
  99270. * Add the required uniforms to the current buffer.
  99271. * @param uniformBuffer defines the current uniform buffer.
  99272. */
  99273. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99274. }
  99275. }
  99276. declare module BABYLON {
  99277. /** @hidden */
  99278. export var pbrFragmentDeclaration: {
  99279. name: string;
  99280. shader: string;
  99281. };
  99282. }
  99283. declare module BABYLON {
  99284. /** @hidden */
  99285. export var pbrUboDeclaration: {
  99286. name: string;
  99287. shader: string;
  99288. };
  99289. }
  99290. declare module BABYLON {
  99291. /** @hidden */
  99292. export var pbrFunctions: {
  99293. name: string;
  99294. shader: string;
  99295. };
  99296. }
  99297. declare module BABYLON {
  99298. /** @hidden */
  99299. export var harmonicsFunctions: {
  99300. name: string;
  99301. shader: string;
  99302. };
  99303. }
  99304. declare module BABYLON {
  99305. /** @hidden */
  99306. export var pbrPreLightingFunctions: {
  99307. name: string;
  99308. shader: string;
  99309. };
  99310. }
  99311. declare module BABYLON {
  99312. /** @hidden */
  99313. export var pbrFalloffLightingFunctions: {
  99314. name: string;
  99315. shader: string;
  99316. };
  99317. }
  99318. declare module BABYLON {
  99319. /** @hidden */
  99320. export var pbrLightingFunctions: {
  99321. name: string;
  99322. shader: string;
  99323. };
  99324. }
  99325. declare module BABYLON {
  99326. /** @hidden */
  99327. export var pbrPixelShader: {
  99328. name: string;
  99329. shader: string;
  99330. };
  99331. }
  99332. declare module BABYLON {
  99333. /** @hidden */
  99334. export var pbrVertexDeclaration: {
  99335. name: string;
  99336. shader: string;
  99337. };
  99338. }
  99339. declare module BABYLON {
  99340. /** @hidden */
  99341. export var pbrVertexShader: {
  99342. name: string;
  99343. shader: string;
  99344. };
  99345. }
  99346. declare module BABYLON {
  99347. /**
  99348. * The Physically based material base class of BJS.
  99349. *
  99350. * This offers the main features of a standard PBR material.
  99351. * For more information, please refer to the documentation :
  99352. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99353. */
  99354. export abstract class PBRBaseMaterial extends PushMaterial {
  99355. /**
  99356. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99357. */
  99358. static readonly PBRMATERIAL_OPAQUE: number;
  99359. /**
  99360. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99361. */
  99362. static readonly PBRMATERIAL_ALPHATEST: number;
  99363. /**
  99364. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99365. */
  99366. static readonly PBRMATERIAL_ALPHABLEND: number;
  99367. /**
  99368. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99369. * They are also discarded below the alpha cutoff threshold to improve performances.
  99370. */
  99371. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99372. /**
  99373. * Defines the default value of how much AO map is occluding the analytical lights
  99374. * (point spot...).
  99375. */
  99376. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99377. /**
  99378. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  99379. */
  99380. static readonly LIGHTFALLOFF_PHYSICAL: number;
  99381. /**
  99382. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  99383. * to enhance interoperability with other engines.
  99384. */
  99385. static readonly LIGHTFALLOFF_GLTF: number;
  99386. /**
  99387. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  99388. * to enhance interoperability with other materials.
  99389. */
  99390. static readonly LIGHTFALLOFF_STANDARD: number;
  99391. /**
  99392. * Intensity of the direct lights e.g. the four lights available in your scene.
  99393. * This impacts both the direct diffuse and specular highlights.
  99394. */
  99395. protected _directIntensity: number;
  99396. /**
  99397. * Intensity of the emissive part of the material.
  99398. * This helps controlling the emissive effect without modifying the emissive color.
  99399. */
  99400. protected _emissiveIntensity: number;
  99401. /**
  99402. * Intensity of the environment e.g. how much the environment will light the object
  99403. * either through harmonics for rough material or through the refelction for shiny ones.
  99404. */
  99405. protected _environmentIntensity: number;
  99406. /**
  99407. * This is a special control allowing the reduction of the specular highlights coming from the
  99408. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99409. */
  99410. protected _specularIntensity: number;
  99411. /**
  99412. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  99413. */
  99414. private _lightingInfos;
  99415. /**
  99416. * Debug Control allowing disabling the bump map on this material.
  99417. */
  99418. protected _disableBumpMap: boolean;
  99419. /**
  99420. * AKA Diffuse Texture in standard nomenclature.
  99421. */
  99422. protected _albedoTexture: BaseTexture;
  99423. /**
  99424. * AKA Occlusion Texture in other nomenclature.
  99425. */
  99426. protected _ambientTexture: BaseTexture;
  99427. /**
  99428. * AKA Occlusion Texture Intensity in other nomenclature.
  99429. */
  99430. protected _ambientTextureStrength: number;
  99431. /**
  99432. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99433. * 1 means it completely occludes it
  99434. * 0 mean it has no impact
  99435. */
  99436. protected _ambientTextureImpactOnAnalyticalLights: number;
  99437. /**
  99438. * Stores the alpha values in a texture.
  99439. */
  99440. protected _opacityTexture: BaseTexture;
  99441. /**
  99442. * Stores the reflection values in a texture.
  99443. */
  99444. protected _reflectionTexture: BaseTexture;
  99445. /**
  99446. * Stores the refraction values in a texture.
  99447. */
  99448. protected _refractionTexture: BaseTexture;
  99449. /**
  99450. * Stores the emissive values in a texture.
  99451. */
  99452. protected _emissiveTexture: BaseTexture;
  99453. /**
  99454. * AKA Specular texture in other nomenclature.
  99455. */
  99456. protected _reflectivityTexture: BaseTexture;
  99457. /**
  99458. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99459. */
  99460. protected _metallicTexture: BaseTexture;
  99461. /**
  99462. * Specifies the metallic scalar of the metallic/roughness workflow.
  99463. * Can also be used to scale the metalness values of the metallic texture.
  99464. */
  99465. protected _metallic: Nullable<number>;
  99466. /**
  99467. * Specifies the roughness scalar of the metallic/roughness workflow.
  99468. * Can also be used to scale the roughness values of the metallic texture.
  99469. */
  99470. protected _roughness: Nullable<number>;
  99471. /**
  99472. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99473. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99474. */
  99475. protected _microSurfaceTexture: BaseTexture;
  99476. /**
  99477. * Stores surface normal data used to displace a mesh in a texture.
  99478. */
  99479. protected _bumpTexture: BaseTexture;
  99480. /**
  99481. * Stores the pre-calculated light information of a mesh in a texture.
  99482. */
  99483. protected _lightmapTexture: BaseTexture;
  99484. /**
  99485. * The color of a material in ambient lighting.
  99486. */
  99487. protected _ambientColor: Color3;
  99488. /**
  99489. * AKA Diffuse Color in other nomenclature.
  99490. */
  99491. protected _albedoColor: Color3;
  99492. /**
  99493. * AKA Specular Color in other nomenclature.
  99494. */
  99495. protected _reflectivityColor: Color3;
  99496. /**
  99497. * The color applied when light is reflected from a material.
  99498. */
  99499. protected _reflectionColor: Color3;
  99500. /**
  99501. * The color applied when light is emitted from a material.
  99502. */
  99503. protected _emissiveColor: Color3;
  99504. /**
  99505. * AKA Glossiness in other nomenclature.
  99506. */
  99507. protected _microSurface: number;
  99508. /**
  99509. * source material index of refraction (IOR)' / 'destination material IOR.
  99510. */
  99511. protected _indexOfRefraction: number;
  99512. /**
  99513. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99514. */
  99515. protected _invertRefractionY: boolean;
  99516. /**
  99517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99518. * Materials half opaque for instance using refraction could benefit from this control.
  99519. */
  99520. protected _linkRefractionWithTransparency: boolean;
  99521. /**
  99522. * Specifies that the material will use the light map as a show map.
  99523. */
  99524. protected _useLightmapAsShadowmap: boolean;
  99525. /**
  99526. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99527. * makes the reflect vector face the model (under horizon).
  99528. */
  99529. protected _useHorizonOcclusion: boolean;
  99530. /**
  99531. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99532. * too much the area relying on ambient texture to define their ambient occlusion.
  99533. */
  99534. protected _useRadianceOcclusion: boolean;
  99535. /**
  99536. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99537. */
  99538. protected _useAlphaFromAlbedoTexture: boolean;
  99539. /**
  99540. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  99541. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99542. */
  99543. protected _useSpecularOverAlpha: boolean;
  99544. /**
  99545. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99546. */
  99547. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99548. /**
  99549. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99550. */
  99551. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  99552. /**
  99553. * Specifies if the metallic texture contains the roughness information in its green channel.
  99554. */
  99555. protected _useRoughnessFromMetallicTextureGreen: boolean;
  99556. /**
  99557. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99558. */
  99559. protected _useMetallnessFromMetallicTextureBlue: boolean;
  99560. /**
  99561. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99562. */
  99563. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  99564. /**
  99565. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99566. */
  99567. protected _useAmbientInGrayScale: boolean;
  99568. /**
  99569. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99570. * The material will try to infer what glossiness each pixel should be.
  99571. */
  99572. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  99573. /**
  99574. * Defines the falloff type used in this material.
  99575. * It by default is Physical.
  99576. */
  99577. protected _lightFalloff: number;
  99578. /**
  99579. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99580. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99581. */
  99582. protected _useRadianceOverAlpha: boolean;
  99583. /**
  99584. * Allows using an object space normal map (instead of tangent space).
  99585. */
  99586. protected _useObjectSpaceNormalMap: boolean;
  99587. /**
  99588. * Allows using the bump map in parallax mode.
  99589. */
  99590. protected _useParallax: boolean;
  99591. /**
  99592. * Allows using the bump map in parallax occlusion mode.
  99593. */
  99594. protected _useParallaxOcclusion: boolean;
  99595. /**
  99596. * Controls the scale bias of the parallax mode.
  99597. */
  99598. protected _parallaxScaleBias: number;
  99599. /**
  99600. * If sets to true, disables all the lights affecting the material.
  99601. */
  99602. protected _disableLighting: boolean;
  99603. /**
  99604. * Number of Simultaneous lights allowed on the material.
  99605. */
  99606. protected _maxSimultaneousLights: number;
  99607. /**
  99608. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99609. */
  99610. protected _invertNormalMapX: boolean;
  99611. /**
  99612. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99613. */
  99614. protected _invertNormalMapY: boolean;
  99615. /**
  99616. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99617. */
  99618. protected _twoSidedLighting: boolean;
  99619. /**
  99620. * Defines the alpha limits in alpha test mode.
  99621. */
  99622. protected _alphaCutOff: number;
  99623. /**
  99624. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99625. */
  99626. protected _forceAlphaTest: boolean;
  99627. /**
  99628. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99629. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99630. */
  99631. protected _useAlphaFresnel: boolean;
  99632. /**
  99633. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99634. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99635. */
  99636. protected _useLinearAlphaFresnel: boolean;
  99637. /**
  99638. * The transparency mode of the material.
  99639. */
  99640. protected _transparencyMode: Nullable<number>;
  99641. /**
  99642. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99643. * from cos thetav and roughness:
  99644. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99645. */
  99646. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99647. /**
  99648. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99649. */
  99650. protected _forceIrradianceInFragment: boolean;
  99651. /**
  99652. * Force normal to face away from face.
  99653. */
  99654. protected _forceNormalForward: boolean;
  99655. /**
  99656. * Enables specular anti aliasing in the PBR shader.
  99657. * It will both interacts on the Geometry for analytical and IBL lighting.
  99658. * It also prefilter the roughness map based on the bump values.
  99659. */
  99660. protected _enableSpecularAntiAliasing: boolean;
  99661. /**
  99662. * Default configuration related to image processing available in the PBR Material.
  99663. */
  99664. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99665. /**
  99666. * Keep track of the image processing observer to allow dispose and replace.
  99667. */
  99668. private _imageProcessingObserver;
  99669. /**
  99670. * Attaches a new image processing configuration to the PBR Material.
  99671. * @param configuration
  99672. */
  99673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99674. /**
  99675. * Stores the available render targets.
  99676. */
  99677. private _renderTargets;
  99678. /**
  99679. * Sets the global ambient color for the material used in lighting calculations.
  99680. */
  99681. private _globalAmbientColor;
  99682. /**
  99683. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99684. */
  99685. private _useLogarithmicDepth;
  99686. /**
  99687. * If set to true, no lighting calculations will be applied.
  99688. */
  99689. private _unlit;
  99690. /**
  99691. * Defines the clear coat layer parameters for the material.
  99692. */
  99693. readonly clearCoat: PBRClearCoatConfiguration;
  99694. /**
  99695. * Defines the anisotropic parameters for the material.
  99696. */
  99697. readonly anisotropy: PBRAnisotropicConfiguration;
  99698. /**
  99699. * Instantiates a new PBRMaterial instance.
  99700. *
  99701. * @param name The material name
  99702. * @param scene The scene the material will be use in.
  99703. */
  99704. constructor(name: string, scene: Scene);
  99705. /**
  99706. * Gets a boolean indicating that current material needs to register RTT
  99707. */
  99708. readonly hasRenderTargetTextures: boolean;
  99709. /**
  99710. * Gets the name of the material class.
  99711. */
  99712. getClassName(): string;
  99713. /**
  99714. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99715. */
  99716. /**
  99717. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99718. */
  99719. useLogarithmicDepth: boolean;
  99720. /**
  99721. * Gets the current transparency mode.
  99722. */
  99723. /**
  99724. * Sets the transparency mode of the material.
  99725. *
  99726. * | Value | Type | Description |
  99727. * | ----- | ----------------------------------- | ----------- |
  99728. * | 0 | OPAQUE | |
  99729. * | 1 | ALPHATEST | |
  99730. * | 2 | ALPHABLEND | |
  99731. * | 3 | ALPHATESTANDBLEND | |
  99732. *
  99733. */
  99734. transparencyMode: Nullable<number>;
  99735. /**
  99736. * Returns true if alpha blending should be disabled.
  99737. */
  99738. private readonly _disableAlphaBlending;
  99739. /**
  99740. * Specifies whether or not this material should be rendered in alpha blend mode.
  99741. */
  99742. needAlphaBlending(): boolean;
  99743. /**
  99744. * Specifies if the mesh will require alpha blending.
  99745. * @param mesh - BJS mesh.
  99746. */
  99747. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99748. /**
  99749. * Specifies whether or not this material should be rendered in alpha test mode.
  99750. */
  99751. needAlphaTesting(): boolean;
  99752. /**
  99753. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99754. */
  99755. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99756. /**
  99757. * Gets the texture used for the alpha test.
  99758. */
  99759. getAlphaTestTexture(): BaseTexture;
  99760. /**
  99761. * Specifies that the submesh is ready to be used.
  99762. * @param mesh - BJS mesh.
  99763. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99764. * @param useInstances - Specifies that instances should be used.
  99765. * @returns - boolean indicating that the submesh is ready or not.
  99766. */
  99767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99768. /**
  99769. * Specifies if the material uses metallic roughness workflow.
  99770. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99771. */
  99772. isMetallicWorkflow(): boolean;
  99773. private _prepareEffect;
  99774. private _prepareDefines;
  99775. /**
  99776. * Force shader compilation
  99777. */
  99778. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99779. clipPlane: boolean;
  99780. }>): void;
  99781. /**
  99782. * Initializes the uniform buffer layout for the shader.
  99783. */
  99784. buildUniformLayout(): void;
  99785. /**
  99786. * Unbinds the textures.
  99787. */
  99788. unbind(): void;
  99789. /**
  99790. * Binds the submesh data.
  99791. * @param world - The world matrix.
  99792. * @param mesh - The BJS mesh.
  99793. * @param subMesh - A submesh of the BJS mesh.
  99794. */
  99795. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99796. /**
  99797. * Returns the animatable textures.
  99798. * @returns - Array of animatable textures.
  99799. */
  99800. getAnimatables(): IAnimatable[];
  99801. /**
  99802. * Returns the texture used for reflections.
  99803. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99804. */
  99805. private _getReflectionTexture;
  99806. /**
  99807. * Returns the texture used for refraction or null if none is used.
  99808. * @returns - Refection texture if present. If no refraction texture and refraction
  99809. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99810. */
  99811. private _getRefractionTexture;
  99812. /**
  99813. * Returns an array of the actively used textures.
  99814. * @returns - Array of BaseTextures
  99815. */
  99816. getActiveTextures(): BaseTexture[];
  99817. /**
  99818. * Checks to see if a texture is used in the material.
  99819. * @param texture - Base texture to use.
  99820. * @returns - Boolean specifying if a texture is used in the material.
  99821. */
  99822. hasTexture(texture: BaseTexture): boolean;
  99823. /**
  99824. * Disposes the resources of the material.
  99825. * @param forceDisposeEffect - Forces the disposal of effects.
  99826. * @param forceDisposeTextures - Forces the disposal of all textures.
  99827. */
  99828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99829. }
  99830. }
  99831. declare module BABYLON {
  99832. /**
  99833. * The Physically based material of BJS.
  99834. *
  99835. * This offers the main features of a standard PBR material.
  99836. * For more information, please refer to the documentation :
  99837. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99838. */
  99839. export class PBRMaterial extends PBRBaseMaterial {
  99840. /**
  99841. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99842. */
  99843. static readonly PBRMATERIAL_OPAQUE: number;
  99844. /**
  99845. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99846. */
  99847. static readonly PBRMATERIAL_ALPHATEST: number;
  99848. /**
  99849. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99850. */
  99851. static readonly PBRMATERIAL_ALPHABLEND: number;
  99852. /**
  99853. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99854. * They are also discarded below the alpha cutoff threshold to improve performances.
  99855. */
  99856. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99857. /**
  99858. * Defines the default value of how much AO map is occluding the analytical lights
  99859. * (point spot...).
  99860. */
  99861. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99862. /**
  99863. * Intensity of the direct lights e.g. the four lights available in your scene.
  99864. * This impacts both the direct diffuse and specular highlights.
  99865. */
  99866. directIntensity: number;
  99867. /**
  99868. * Intensity of the emissive part of the material.
  99869. * This helps controlling the emissive effect without modifying the emissive color.
  99870. */
  99871. emissiveIntensity: number;
  99872. /**
  99873. * Intensity of the environment e.g. how much the environment will light the object
  99874. * either through harmonics for rough material or through the refelction for shiny ones.
  99875. */
  99876. environmentIntensity: number;
  99877. /**
  99878. * This is a special control allowing the reduction of the specular highlights coming from the
  99879. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99880. */
  99881. specularIntensity: number;
  99882. /**
  99883. * Debug Control allowing disabling the bump map on this material.
  99884. */
  99885. disableBumpMap: boolean;
  99886. /**
  99887. * AKA Diffuse Texture in standard nomenclature.
  99888. */
  99889. albedoTexture: BaseTexture;
  99890. /**
  99891. * AKA Occlusion Texture in other nomenclature.
  99892. */
  99893. ambientTexture: BaseTexture;
  99894. /**
  99895. * AKA Occlusion Texture Intensity in other nomenclature.
  99896. */
  99897. ambientTextureStrength: number;
  99898. /**
  99899. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99900. * 1 means it completely occludes it
  99901. * 0 mean it has no impact
  99902. */
  99903. ambientTextureImpactOnAnalyticalLights: number;
  99904. /**
  99905. * Stores the alpha values in a texture.
  99906. */
  99907. opacityTexture: BaseTexture;
  99908. /**
  99909. * Stores the reflection values in a texture.
  99910. */
  99911. reflectionTexture: Nullable<BaseTexture>;
  99912. /**
  99913. * Stores the emissive values in a texture.
  99914. */
  99915. emissiveTexture: BaseTexture;
  99916. /**
  99917. * AKA Specular texture in other nomenclature.
  99918. */
  99919. reflectivityTexture: BaseTexture;
  99920. /**
  99921. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99922. */
  99923. metallicTexture: BaseTexture;
  99924. /**
  99925. * Specifies the metallic scalar of the metallic/roughness workflow.
  99926. * Can also be used to scale the metalness values of the metallic texture.
  99927. */
  99928. metallic: Nullable<number>;
  99929. /**
  99930. * Specifies the roughness scalar of the metallic/roughness workflow.
  99931. * Can also be used to scale the roughness values of the metallic texture.
  99932. */
  99933. roughness: Nullable<number>;
  99934. /**
  99935. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99936. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99937. */
  99938. microSurfaceTexture: BaseTexture;
  99939. /**
  99940. * Stores surface normal data used to displace a mesh in a texture.
  99941. */
  99942. bumpTexture: BaseTexture;
  99943. /**
  99944. * Stores the pre-calculated light information of a mesh in a texture.
  99945. */
  99946. lightmapTexture: BaseTexture;
  99947. /**
  99948. * Stores the refracted light information in a texture.
  99949. */
  99950. refractionTexture: BaseTexture;
  99951. /**
  99952. * The color of a material in ambient lighting.
  99953. */
  99954. ambientColor: Color3;
  99955. /**
  99956. * AKA Diffuse Color in other nomenclature.
  99957. */
  99958. albedoColor: Color3;
  99959. /**
  99960. * AKA Specular Color in other nomenclature.
  99961. */
  99962. reflectivityColor: Color3;
  99963. /**
  99964. * The color reflected from the material.
  99965. */
  99966. reflectionColor: Color3;
  99967. /**
  99968. * The color emitted from the material.
  99969. */
  99970. emissiveColor: Color3;
  99971. /**
  99972. * AKA Glossiness in other nomenclature.
  99973. */
  99974. microSurface: number;
  99975. /**
  99976. * source material index of refraction (IOR)' / 'destination material IOR.
  99977. */
  99978. indexOfRefraction: number;
  99979. /**
  99980. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99981. */
  99982. invertRefractionY: boolean;
  99983. /**
  99984. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99985. * Materials half opaque for instance using refraction could benefit from this control.
  99986. */
  99987. linkRefractionWithTransparency: boolean;
  99988. /**
  99989. * If true, the light map contains occlusion information instead of lighting info.
  99990. */
  99991. useLightmapAsShadowmap: boolean;
  99992. /**
  99993. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99994. */
  99995. useAlphaFromAlbedoTexture: boolean;
  99996. /**
  99997. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99998. */
  99999. forceAlphaTest: boolean;
  100000. /**
  100001. * Defines the alpha limits in alpha test mode.
  100002. */
  100003. alphaCutOff: number;
  100004. /**
  100005. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100006. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100007. */
  100008. useSpecularOverAlpha: boolean;
  100009. /**
  100010. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100011. */
  100012. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100013. /**
  100014. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100015. */
  100016. useRoughnessFromMetallicTextureAlpha: boolean;
  100017. /**
  100018. * Specifies if the metallic texture contains the roughness information in its green channel.
  100019. */
  100020. useRoughnessFromMetallicTextureGreen: boolean;
  100021. /**
  100022. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100023. */
  100024. useMetallnessFromMetallicTextureBlue: boolean;
  100025. /**
  100026. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100027. */
  100028. useAmbientOcclusionFromMetallicTextureRed: boolean;
  100029. /**
  100030. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100031. */
  100032. useAmbientInGrayScale: boolean;
  100033. /**
  100034. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100035. * The material will try to infer what glossiness each pixel should be.
  100036. */
  100037. useAutoMicroSurfaceFromReflectivityMap: boolean;
  100038. /**
  100039. * BJS is using an harcoded light falloff based on a manually sets up range.
  100040. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100041. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100042. */
  100043. /**
  100044. * BJS is using an harcoded light falloff based on a manually sets up range.
  100045. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100046. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100047. */
  100048. usePhysicalLightFalloff: boolean;
  100049. /**
  100050. * In order to support the falloff compatibility with gltf, a special mode has been added
  100051. * to reproduce the gltf light falloff.
  100052. */
  100053. /**
  100054. * In order to support the falloff compatibility with gltf, a special mode has been added
  100055. * to reproduce the gltf light falloff.
  100056. */
  100057. useGLTFLightFalloff: boolean;
  100058. /**
  100059. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100060. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100061. */
  100062. useRadianceOverAlpha: boolean;
  100063. /**
  100064. * Allows using an object space normal map (instead of tangent space).
  100065. */
  100066. useObjectSpaceNormalMap: boolean;
  100067. /**
  100068. * Allows using the bump map in parallax mode.
  100069. */
  100070. useParallax: boolean;
  100071. /**
  100072. * Allows using the bump map in parallax occlusion mode.
  100073. */
  100074. useParallaxOcclusion: boolean;
  100075. /**
  100076. * Controls the scale bias of the parallax mode.
  100077. */
  100078. parallaxScaleBias: number;
  100079. /**
  100080. * If sets to true, disables all the lights affecting the material.
  100081. */
  100082. disableLighting: boolean;
  100083. /**
  100084. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100085. */
  100086. forceIrradianceInFragment: boolean;
  100087. /**
  100088. * Number of Simultaneous lights allowed on the material.
  100089. */
  100090. maxSimultaneousLights: number;
  100091. /**
  100092. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100093. */
  100094. invertNormalMapX: boolean;
  100095. /**
  100096. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100097. */
  100098. invertNormalMapY: boolean;
  100099. /**
  100100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100101. */
  100102. twoSidedLighting: boolean;
  100103. /**
  100104. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100105. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100106. */
  100107. useAlphaFresnel: boolean;
  100108. /**
  100109. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100110. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100111. */
  100112. useLinearAlphaFresnel: boolean;
  100113. /**
  100114. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100115. * And/Or occlude the blended part.
  100116. */
  100117. environmentBRDFTexture: Nullable<BaseTexture>;
  100118. /**
  100119. * Force normal to face away from face.
  100120. */
  100121. forceNormalForward: boolean;
  100122. /**
  100123. * Enables specular anti aliasing in the PBR shader.
  100124. * It will both interacts on the Geometry for analytical and IBL lighting.
  100125. * It also prefilter the roughness map based on the bump values.
  100126. */
  100127. enableSpecularAntiAliasing: boolean;
  100128. /**
  100129. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100130. * makes the reflect vector face the model (under horizon).
  100131. */
  100132. useHorizonOcclusion: boolean;
  100133. /**
  100134. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100135. * too much the area relying on ambient texture to define their ambient occlusion.
  100136. */
  100137. useRadianceOcclusion: boolean;
  100138. /**
  100139. * If set to true, no lighting calculations will be applied.
  100140. */
  100141. unlit: boolean;
  100142. /**
  100143. * Gets the image processing configuration used either in this material.
  100144. */
  100145. /**
  100146. * Sets the Default image processing configuration used either in the this material.
  100147. *
  100148. * If sets to null, the scene one is in use.
  100149. */
  100150. imageProcessingConfiguration: ImageProcessingConfiguration;
  100151. /**
  100152. * Gets wether the color curves effect is enabled.
  100153. */
  100154. /**
  100155. * Sets wether the color curves effect is enabled.
  100156. */
  100157. cameraColorCurvesEnabled: boolean;
  100158. /**
  100159. * Gets wether the color grading effect is enabled.
  100160. */
  100161. /**
  100162. * Gets wether the color grading effect is enabled.
  100163. */
  100164. cameraColorGradingEnabled: boolean;
  100165. /**
  100166. * Gets wether tonemapping is enabled or not.
  100167. */
  100168. /**
  100169. * Sets wether tonemapping is enabled or not
  100170. */
  100171. cameraToneMappingEnabled: boolean;
  100172. /**
  100173. * The camera exposure used on this material.
  100174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100175. * This corresponds to a photographic exposure.
  100176. */
  100177. /**
  100178. * The camera exposure used on this material.
  100179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100180. * This corresponds to a photographic exposure.
  100181. */
  100182. cameraExposure: number;
  100183. /**
  100184. * Gets The camera contrast used on this material.
  100185. */
  100186. /**
  100187. * Sets The camera contrast used on this material.
  100188. */
  100189. cameraContrast: number;
  100190. /**
  100191. * Gets the Color Grading 2D Lookup Texture.
  100192. */
  100193. /**
  100194. * Sets the Color Grading 2D Lookup Texture.
  100195. */
  100196. cameraColorGradingTexture: Nullable<BaseTexture>;
  100197. /**
  100198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100200. * 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;
  100201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100202. */
  100203. /**
  100204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100206. * 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;
  100207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100208. */
  100209. cameraColorCurves: Nullable<ColorCurves>;
  100210. /**
  100211. * Instantiates a new PBRMaterial instance.
  100212. *
  100213. * @param name The material name
  100214. * @param scene The scene the material will be use in.
  100215. */
  100216. constructor(name: string, scene: Scene);
  100217. /**
  100218. * Returns the name of this material class.
  100219. */
  100220. getClassName(): string;
  100221. /**
  100222. * Makes a duplicate of the current material.
  100223. * @param name - name to use for the new material.
  100224. */
  100225. clone(name: string): PBRMaterial;
  100226. /**
  100227. * Serializes this PBR Material.
  100228. * @returns - An object with the serialized material.
  100229. */
  100230. serialize(): any;
  100231. /**
  100232. * Parses a PBR Material from a serialized object.
  100233. * @param source - Serialized object.
  100234. * @param scene - BJS scene instance.
  100235. * @param rootUrl - url for the scene object
  100236. * @returns - PBRMaterial
  100237. */
  100238. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  100239. }
  100240. }
  100241. declare module BABYLON {
  100242. /** @hidden */
  100243. export var _forceSceneHelpersToBundle: boolean;
  100244. interface Scene {
  100245. /**
  100246. * Creates a default light for the scene.
  100247. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  100248. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  100249. */
  100250. createDefaultLight(replace?: boolean): void;
  100251. /**
  100252. * Creates a default camera for the scene.
  100253. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  100254. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100255. * @param replace has default false, when true replaces the active camera in the scene
  100256. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  100257. */
  100258. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100259. /**
  100260. * Creates a default camera and a default light.
  100261. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  100262. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100263. * @param replace has the default false, when true replaces the active camera/light in the scene
  100264. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  100265. */
  100266. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100267. /**
  100268. * Creates a new sky box
  100269. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  100270. * @param environmentTexture defines the texture to use as environment texture
  100271. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  100272. * @param scale defines the overall scale of the skybox
  100273. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  100274. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  100275. * @returns a new mesh holding the sky box
  100276. */
  100277. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  100278. /**
  100279. * Creates a new environment
  100280. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  100281. * @param options defines the options you can use to configure the environment
  100282. * @returns the new EnvironmentHelper
  100283. */
  100284. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  100285. /**
  100286. * Creates a new VREXperienceHelper
  100287. * @see http://doc.babylonjs.com/how_to/webvr_helper
  100288. * @param webVROptions defines the options used to create the new VREXperienceHelper
  100289. * @returns a new VREXperienceHelper
  100290. */
  100291. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  100292. /**
  100293. * Creates a new XREXperienceHelper
  100294. * @see http://doc.babylonjs.com/how_to/webxr
  100295. * @returns a promise for a new XREXperienceHelper
  100296. */
  100297. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  100298. }
  100299. }
  100300. declare module BABYLON {
  100301. /**
  100302. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  100303. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  100304. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  100305. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100306. */
  100307. export class VideoDome extends TransformNode {
  100308. private _useDirectMapping;
  100309. /**
  100310. * The video texture being displayed on the sphere
  100311. */
  100312. protected _videoTexture: VideoTexture;
  100313. /**
  100314. * Gets the video texture being displayed on the sphere
  100315. */
  100316. readonly videoTexture: VideoTexture;
  100317. /**
  100318. * The skybox material
  100319. */
  100320. protected _material: BackgroundMaterial;
  100321. /**
  100322. * The surface used for the skybox
  100323. */
  100324. protected _mesh: Mesh;
  100325. /**
  100326. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100327. * Also see the options.resolution property.
  100328. */
  100329. fovMultiplier: number;
  100330. /**
  100331. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  100332. * @param name Element's name, child elements will append suffixes for their own names.
  100333. * @param urlsOrVideo defines the url(s) or the video element to use
  100334. * @param options An object containing optional or exposed sub element properties
  100335. */
  100336. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  100337. resolution?: number;
  100338. clickToPlay?: boolean;
  100339. autoPlay?: boolean;
  100340. loop?: boolean;
  100341. size?: number;
  100342. poster?: string;
  100343. useDirectMapping?: boolean;
  100344. }, scene: Scene);
  100345. /**
  100346. * Releases resources associated with this node.
  100347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100349. */
  100350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100351. }
  100352. }
  100353. declare module BABYLON {
  100354. /**
  100355. * This class can be used to get instrumentation data from a Babylon engine
  100356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100357. */
  100358. export class EngineInstrumentation implements IDisposable {
  100359. /**
  100360. * Define the instrumented engine.
  100361. */
  100362. engine: Engine;
  100363. private _captureGPUFrameTime;
  100364. private _gpuFrameTimeToken;
  100365. private _gpuFrameTime;
  100366. private _captureShaderCompilationTime;
  100367. private _shaderCompilationTime;
  100368. private _onBeginFrameObserver;
  100369. private _onEndFrameObserver;
  100370. private _onBeforeShaderCompilationObserver;
  100371. private _onAfterShaderCompilationObserver;
  100372. /**
  100373. * Gets the perf counter used for GPU frame time
  100374. */
  100375. readonly gpuFrameTimeCounter: PerfCounter;
  100376. /**
  100377. * Gets the GPU frame time capture status
  100378. */
  100379. /**
  100380. * Enable or disable the GPU frame time capture
  100381. */
  100382. captureGPUFrameTime: boolean;
  100383. /**
  100384. * Gets the perf counter used for shader compilation time
  100385. */
  100386. readonly shaderCompilationTimeCounter: PerfCounter;
  100387. /**
  100388. * Gets the shader compilation time capture status
  100389. */
  100390. /**
  100391. * Enable or disable the shader compilation time capture
  100392. */
  100393. captureShaderCompilationTime: boolean;
  100394. /**
  100395. * Instantiates a new engine instrumentation.
  100396. * This class can be used to get instrumentation data from a Babylon engine
  100397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100398. * @param engine Defines the engine to instrument
  100399. */
  100400. constructor(
  100401. /**
  100402. * Define the instrumented engine.
  100403. */
  100404. engine: Engine);
  100405. /**
  100406. * Dispose and release associated resources.
  100407. */
  100408. dispose(): void;
  100409. }
  100410. }
  100411. declare module BABYLON {
  100412. /**
  100413. * This class can be used to get instrumentation data from a Babylon engine
  100414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100415. */
  100416. export class SceneInstrumentation implements IDisposable {
  100417. /**
  100418. * Defines the scene to instrument
  100419. */
  100420. scene: Scene;
  100421. private _captureActiveMeshesEvaluationTime;
  100422. private _activeMeshesEvaluationTime;
  100423. private _captureRenderTargetsRenderTime;
  100424. private _renderTargetsRenderTime;
  100425. private _captureFrameTime;
  100426. private _frameTime;
  100427. private _captureRenderTime;
  100428. private _renderTime;
  100429. private _captureInterFrameTime;
  100430. private _interFrameTime;
  100431. private _captureParticlesRenderTime;
  100432. private _particlesRenderTime;
  100433. private _captureSpritesRenderTime;
  100434. private _spritesRenderTime;
  100435. private _capturePhysicsTime;
  100436. private _physicsTime;
  100437. private _captureAnimationsTime;
  100438. private _animationsTime;
  100439. private _captureCameraRenderTime;
  100440. private _cameraRenderTime;
  100441. private _onBeforeActiveMeshesEvaluationObserver;
  100442. private _onAfterActiveMeshesEvaluationObserver;
  100443. private _onBeforeRenderTargetsRenderObserver;
  100444. private _onAfterRenderTargetsRenderObserver;
  100445. private _onAfterRenderObserver;
  100446. private _onBeforeDrawPhaseObserver;
  100447. private _onAfterDrawPhaseObserver;
  100448. private _onBeforeAnimationsObserver;
  100449. private _onBeforeParticlesRenderingObserver;
  100450. private _onAfterParticlesRenderingObserver;
  100451. private _onBeforeSpritesRenderingObserver;
  100452. private _onAfterSpritesRenderingObserver;
  100453. private _onBeforePhysicsObserver;
  100454. private _onAfterPhysicsObserver;
  100455. private _onAfterAnimationsObserver;
  100456. private _onBeforeCameraRenderObserver;
  100457. private _onAfterCameraRenderObserver;
  100458. /**
  100459. * Gets the perf counter used for active meshes evaluation time
  100460. */
  100461. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  100462. /**
  100463. * Gets the active meshes evaluation time capture status
  100464. */
  100465. /**
  100466. * Enable or disable the active meshes evaluation time capture
  100467. */
  100468. captureActiveMeshesEvaluationTime: boolean;
  100469. /**
  100470. * Gets the perf counter used for render targets render time
  100471. */
  100472. readonly renderTargetsRenderTimeCounter: PerfCounter;
  100473. /**
  100474. * Gets the render targets render time capture status
  100475. */
  100476. /**
  100477. * Enable or disable the render targets render time capture
  100478. */
  100479. captureRenderTargetsRenderTime: boolean;
  100480. /**
  100481. * Gets the perf counter used for particles render time
  100482. */
  100483. readonly particlesRenderTimeCounter: PerfCounter;
  100484. /**
  100485. * Gets the particles render time capture status
  100486. */
  100487. /**
  100488. * Enable or disable the particles render time capture
  100489. */
  100490. captureParticlesRenderTime: boolean;
  100491. /**
  100492. * Gets the perf counter used for sprites render time
  100493. */
  100494. readonly spritesRenderTimeCounter: PerfCounter;
  100495. /**
  100496. * Gets the sprites render time capture status
  100497. */
  100498. /**
  100499. * Enable or disable the sprites render time capture
  100500. */
  100501. captureSpritesRenderTime: boolean;
  100502. /**
  100503. * Gets the perf counter used for physics time
  100504. */
  100505. readonly physicsTimeCounter: PerfCounter;
  100506. /**
  100507. * Gets the physics time capture status
  100508. */
  100509. /**
  100510. * Enable or disable the physics time capture
  100511. */
  100512. capturePhysicsTime: boolean;
  100513. /**
  100514. * Gets the perf counter used for animations time
  100515. */
  100516. readonly animationsTimeCounter: PerfCounter;
  100517. /**
  100518. * Gets the animations time capture status
  100519. */
  100520. /**
  100521. * Enable or disable the animations time capture
  100522. */
  100523. captureAnimationsTime: boolean;
  100524. /**
  100525. * Gets the perf counter used for frame time capture
  100526. */
  100527. readonly frameTimeCounter: PerfCounter;
  100528. /**
  100529. * Gets the frame time capture status
  100530. */
  100531. /**
  100532. * Enable or disable the frame time capture
  100533. */
  100534. captureFrameTime: boolean;
  100535. /**
  100536. * Gets the perf counter used for inter-frames time capture
  100537. */
  100538. readonly interFrameTimeCounter: PerfCounter;
  100539. /**
  100540. * Gets the inter-frames time capture status
  100541. */
  100542. /**
  100543. * Enable or disable the inter-frames time capture
  100544. */
  100545. captureInterFrameTime: boolean;
  100546. /**
  100547. * Gets the perf counter used for render time capture
  100548. */
  100549. readonly renderTimeCounter: PerfCounter;
  100550. /**
  100551. * Gets the render time capture status
  100552. */
  100553. /**
  100554. * Enable or disable the render time capture
  100555. */
  100556. captureRenderTime: boolean;
  100557. /**
  100558. * Gets the perf counter used for camera render time capture
  100559. */
  100560. readonly cameraRenderTimeCounter: PerfCounter;
  100561. /**
  100562. * Gets the camera render time capture status
  100563. */
  100564. /**
  100565. * Enable or disable the camera render time capture
  100566. */
  100567. captureCameraRenderTime: boolean;
  100568. /**
  100569. * Gets the perf counter used for draw calls
  100570. */
  100571. readonly drawCallsCounter: PerfCounter;
  100572. /**
  100573. * Gets the perf counter used for texture collisions
  100574. */
  100575. readonly textureCollisionsCounter: PerfCounter;
  100576. /**
  100577. * Instantiates a new scene instrumentation.
  100578. * This class can be used to get instrumentation data from a Babylon engine
  100579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100580. * @param scene Defines the scene to instrument
  100581. */
  100582. constructor(
  100583. /**
  100584. * Defines the scene to instrument
  100585. */
  100586. scene: Scene);
  100587. /**
  100588. * Dispose and release associated resources.
  100589. */
  100590. dispose(): void;
  100591. }
  100592. }
  100593. declare module BABYLON {
  100594. /** @hidden */
  100595. export var glowMapGenerationPixelShader: {
  100596. name: string;
  100597. shader: string;
  100598. };
  100599. }
  100600. declare module BABYLON {
  100601. /** @hidden */
  100602. export var glowMapGenerationVertexShader: {
  100603. name: string;
  100604. shader: string;
  100605. };
  100606. }
  100607. declare module BABYLON {
  100608. /**
  100609. * Effect layer options. This helps customizing the behaviour
  100610. * of the effect layer.
  100611. */
  100612. export interface IEffectLayerOptions {
  100613. /**
  100614. * Multiplication factor apply to the canvas size to compute the render target size
  100615. * used to generated the objects (the smaller the faster).
  100616. */
  100617. mainTextureRatio: number;
  100618. /**
  100619. * Enforces a fixed size texture to ensure effect stability across devices.
  100620. */
  100621. mainTextureFixedSize?: number;
  100622. /**
  100623. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100624. */
  100625. alphaBlendingMode: number;
  100626. /**
  100627. * The camera attached to the layer.
  100628. */
  100629. camera: Nullable<Camera>;
  100630. /**
  100631. * The rendering group to draw the layer in.
  100632. */
  100633. renderingGroupId: number;
  100634. }
  100635. /**
  100636. * The effect layer Helps adding post process effect blended with the main pass.
  100637. *
  100638. * This can be for instance use to generate glow or higlight effects on the scene.
  100639. *
  100640. * The effect layer class can not be used directly and is intented to inherited from to be
  100641. * customized per effects.
  100642. */
  100643. export abstract class EffectLayer {
  100644. private _vertexBuffers;
  100645. private _indexBuffer;
  100646. private _cachedDefines;
  100647. private _effectLayerMapGenerationEffect;
  100648. private _effectLayerOptions;
  100649. private _mergeEffect;
  100650. protected _scene: Scene;
  100651. protected _engine: Engine;
  100652. protected _maxSize: number;
  100653. protected _mainTextureDesiredSize: ISize;
  100654. protected _mainTexture: RenderTargetTexture;
  100655. protected _shouldRender: boolean;
  100656. protected _postProcesses: PostProcess[];
  100657. protected _textures: BaseTexture[];
  100658. protected _emissiveTextureAndColor: {
  100659. texture: Nullable<BaseTexture>;
  100660. color: Color4;
  100661. };
  100662. /**
  100663. * The name of the layer
  100664. */
  100665. name: string;
  100666. /**
  100667. * The clear color of the texture used to generate the glow map.
  100668. */
  100669. neutralColor: Color4;
  100670. /**
  100671. * Specifies wether the highlight layer is enabled or not.
  100672. */
  100673. isEnabled: boolean;
  100674. /**
  100675. * Gets the camera attached to the layer.
  100676. */
  100677. readonly camera: Nullable<Camera>;
  100678. /**
  100679. * Gets the rendering group id the layer should render in.
  100680. */
  100681. readonly renderingGroupId: number;
  100682. /**
  100683. * An event triggered when the effect layer has been disposed.
  100684. */
  100685. onDisposeObservable: Observable<EffectLayer>;
  100686. /**
  100687. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100688. */
  100689. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100690. /**
  100691. * An event triggered when the generated texture is being merged in the scene.
  100692. */
  100693. onBeforeComposeObservable: Observable<EffectLayer>;
  100694. /**
  100695. * An event triggered when the generated texture has been merged in the scene.
  100696. */
  100697. onAfterComposeObservable: Observable<EffectLayer>;
  100698. /**
  100699. * An event triggered when the efffect layer changes its size.
  100700. */
  100701. onSizeChangedObservable: Observable<EffectLayer>;
  100702. /** @hidden */
  100703. static _SceneComponentInitialization: (scene: Scene) => void;
  100704. /**
  100705. * Instantiates a new effect Layer and references it in the scene.
  100706. * @param name The name of the layer
  100707. * @param scene The scene to use the layer in
  100708. */
  100709. constructor(
  100710. /** The Friendly of the effect in the scene */
  100711. name: string, scene: Scene);
  100712. /**
  100713. * Get the effect name of the layer.
  100714. * @return The effect name
  100715. */
  100716. abstract getEffectName(): string;
  100717. /**
  100718. * Checks for the readiness of the element composing the layer.
  100719. * @param subMesh the mesh to check for
  100720. * @param useInstances specify wether or not to use instances to render the mesh
  100721. * @return true if ready otherwise, false
  100722. */
  100723. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100724. /**
  100725. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100726. * @returns true if the effect requires stencil during the main canvas render pass.
  100727. */
  100728. abstract needStencil(): boolean;
  100729. /**
  100730. * Create the merge effect. This is the shader use to blit the information back
  100731. * to the main canvas at the end of the scene rendering.
  100732. * @returns The effect containing the shader used to merge the effect on the main canvas
  100733. */
  100734. protected abstract _createMergeEffect(): Effect;
  100735. /**
  100736. * Creates the render target textures and post processes used in the effect layer.
  100737. */
  100738. protected abstract _createTextureAndPostProcesses(): void;
  100739. /**
  100740. * Implementation specific of rendering the generating effect on the main canvas.
  100741. * @param effect The effect used to render through
  100742. */
  100743. protected abstract _internalRender(effect: Effect): void;
  100744. /**
  100745. * Sets the required values for both the emissive texture and and the main color.
  100746. */
  100747. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100748. /**
  100749. * Free any resources and references associated to a mesh.
  100750. * Internal use
  100751. * @param mesh The mesh to free.
  100752. */
  100753. abstract _disposeMesh(mesh: Mesh): void;
  100754. /**
  100755. * Serializes this layer (Glow or Highlight for example)
  100756. * @returns a serialized layer object
  100757. */
  100758. abstract serialize?(): any;
  100759. /**
  100760. * Initializes the effect layer with the required options.
  100761. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100762. */
  100763. protected _init(options: Partial<IEffectLayerOptions>): void;
  100764. /**
  100765. * Generates the index buffer of the full screen quad blending to the main canvas.
  100766. */
  100767. private _generateIndexBuffer;
  100768. /**
  100769. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100770. */
  100771. private _genrateVertexBuffer;
  100772. /**
  100773. * Sets the main texture desired size which is the closest power of two
  100774. * of the engine canvas size.
  100775. */
  100776. private _setMainTextureSize;
  100777. /**
  100778. * Creates the main texture for the effect layer.
  100779. */
  100780. protected _createMainTexture(): void;
  100781. /**
  100782. * Adds specific effects defines.
  100783. * @param defines The defines to add specifics to.
  100784. */
  100785. protected _addCustomEffectDefines(defines: string[]): void;
  100786. /**
  100787. * Checks for the readiness of the element composing the layer.
  100788. * @param subMesh the mesh to check for
  100789. * @param useInstances specify wether or not to use instances to render the mesh
  100790. * @param emissiveTexture the associated emissive texture used to generate the glow
  100791. * @return true if ready otherwise, false
  100792. */
  100793. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100794. /**
  100795. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100796. */
  100797. render(): void;
  100798. /**
  100799. * Determine if a given mesh will be used in the current effect.
  100800. * @param mesh mesh to test
  100801. * @returns true if the mesh will be used
  100802. */
  100803. hasMesh(mesh: AbstractMesh): boolean;
  100804. /**
  100805. * Returns true if the layer contains information to display, otherwise false.
  100806. * @returns true if the glow layer should be rendered
  100807. */
  100808. shouldRender(): boolean;
  100809. /**
  100810. * Returns true if the mesh should render, otherwise false.
  100811. * @param mesh The mesh to render
  100812. * @returns true if it should render otherwise false
  100813. */
  100814. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100815. /**
  100816. * Returns true if the mesh can be rendered, otherwise false.
  100817. * @param mesh The mesh to render
  100818. * @param material The material used on the mesh
  100819. * @returns true if it can be rendered otherwise false
  100820. */
  100821. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100822. /**
  100823. * Returns true if the mesh should render, otherwise false.
  100824. * @param mesh The mesh to render
  100825. * @returns true if it should render otherwise false
  100826. */
  100827. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100828. /**
  100829. * Renders the submesh passed in parameter to the generation map.
  100830. */
  100831. protected _renderSubMesh(subMesh: SubMesh): void;
  100832. /**
  100833. * Rebuild the required buffers.
  100834. * @hidden Internal use only.
  100835. */
  100836. _rebuild(): void;
  100837. /**
  100838. * Dispose only the render target textures and post process.
  100839. */
  100840. private _disposeTextureAndPostProcesses;
  100841. /**
  100842. * Dispose the highlight layer and free resources.
  100843. */
  100844. dispose(): void;
  100845. /**
  100846. * Gets the class name of the effect layer
  100847. * @returns the string with the class name of the effect layer
  100848. */
  100849. getClassName(): string;
  100850. /**
  100851. * Creates an effect layer from parsed effect layer data
  100852. * @param parsedEffectLayer defines effect layer data
  100853. * @param scene defines the current scene
  100854. * @param rootUrl defines the root URL containing the effect layer information
  100855. * @returns a parsed effect Layer
  100856. */
  100857. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100858. }
  100859. }
  100860. declare module BABYLON {
  100861. interface AbstractScene {
  100862. /**
  100863. * The list of effect layers (highlights/glow) added to the scene
  100864. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100865. * @see http://doc.babylonjs.com/how_to/glow_layer
  100866. */
  100867. effectLayers: Array<EffectLayer>;
  100868. /**
  100869. * Removes the given effect layer from this scene.
  100870. * @param toRemove defines the effect layer to remove
  100871. * @returns the index of the removed effect layer
  100872. */
  100873. removeEffectLayer(toRemove: EffectLayer): number;
  100874. /**
  100875. * Adds the given effect layer to this scene
  100876. * @param newEffectLayer defines the effect layer to add
  100877. */
  100878. addEffectLayer(newEffectLayer: EffectLayer): void;
  100879. }
  100880. /**
  100881. * Defines the layer scene component responsible to manage any effect layers
  100882. * in a given scene.
  100883. */
  100884. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100885. /**
  100886. * The component name helpfull to identify the component in the list of scene components.
  100887. */
  100888. readonly name: string;
  100889. /**
  100890. * The scene the component belongs to.
  100891. */
  100892. scene: Scene;
  100893. private _engine;
  100894. private _renderEffects;
  100895. private _needStencil;
  100896. private _previousStencilState;
  100897. /**
  100898. * Creates a new instance of the component for the given scene
  100899. * @param scene Defines the scene to register the component in
  100900. */
  100901. constructor(scene: Scene);
  100902. /**
  100903. * Registers the component in a given scene
  100904. */
  100905. register(): void;
  100906. /**
  100907. * Rebuilds the elements related to this component in case of
  100908. * context lost for instance.
  100909. */
  100910. rebuild(): void;
  100911. /**
  100912. * Serializes the component data to the specified json object
  100913. * @param serializationObject The object to serialize to
  100914. */
  100915. serialize(serializationObject: any): void;
  100916. /**
  100917. * Adds all the element from the container to the scene
  100918. * @param container the container holding the elements
  100919. */
  100920. addFromContainer(container: AbstractScene): void;
  100921. /**
  100922. * Removes all the elements in the container from the scene
  100923. * @param container contains the elements to remove
  100924. */
  100925. removeFromContainer(container: AbstractScene): void;
  100926. /**
  100927. * Disposes the component and the associated ressources.
  100928. */
  100929. dispose(): void;
  100930. private _isReadyForMesh;
  100931. private _renderMainTexture;
  100932. private _setStencil;
  100933. private _setStencilBack;
  100934. private _draw;
  100935. private _drawCamera;
  100936. private _drawRenderingGroup;
  100937. }
  100938. }
  100939. declare module BABYLON {
  100940. /** @hidden */
  100941. export var glowMapMergePixelShader: {
  100942. name: string;
  100943. shader: string;
  100944. };
  100945. }
  100946. declare module BABYLON {
  100947. /** @hidden */
  100948. export var glowMapMergeVertexShader: {
  100949. name: string;
  100950. shader: string;
  100951. };
  100952. }
  100953. declare module BABYLON {
  100954. interface AbstractScene {
  100955. /**
  100956. * Return a the first highlight layer of the scene with a given name.
  100957. * @param name The name of the highlight layer to look for.
  100958. * @return The highlight layer if found otherwise null.
  100959. */
  100960. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100961. }
  100962. /**
  100963. * Glow layer options. This helps customizing the behaviour
  100964. * of the glow layer.
  100965. */
  100966. export interface IGlowLayerOptions {
  100967. /**
  100968. * Multiplication factor apply to the canvas size to compute the render target size
  100969. * used to generated the glowing objects (the smaller the faster).
  100970. */
  100971. mainTextureRatio: number;
  100972. /**
  100973. * Enforces a fixed size texture to ensure resize independant blur.
  100974. */
  100975. mainTextureFixedSize?: number;
  100976. /**
  100977. * How big is the kernel of the blur texture.
  100978. */
  100979. blurKernelSize: number;
  100980. /**
  100981. * The camera attached to the layer.
  100982. */
  100983. camera: Nullable<Camera>;
  100984. /**
  100985. * Enable MSAA by chosing the number of samples.
  100986. */
  100987. mainTextureSamples?: number;
  100988. /**
  100989. * The rendering group to draw the layer in.
  100990. */
  100991. renderingGroupId: number;
  100992. }
  100993. /**
  100994. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100995. *
  100996. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100997. * glowy meshes to your scene.
  100998. *
  100999. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  101000. */
  101001. export class GlowLayer extends EffectLayer {
  101002. /**
  101003. * Effect Name of the layer.
  101004. */
  101005. static readonly EffectName: string;
  101006. /**
  101007. * The default blur kernel size used for the glow.
  101008. */
  101009. static DefaultBlurKernelSize: number;
  101010. /**
  101011. * The default texture size ratio used for the glow.
  101012. */
  101013. static DefaultTextureRatio: number;
  101014. /**
  101015. * Sets the kernel size of the blur.
  101016. */
  101017. /**
  101018. * Gets the kernel size of the blur.
  101019. */
  101020. blurKernelSize: number;
  101021. /**
  101022. * Sets the glow intensity.
  101023. */
  101024. /**
  101025. * Gets the glow intensity.
  101026. */
  101027. intensity: number;
  101028. private _options;
  101029. private _intensity;
  101030. private _horizontalBlurPostprocess1;
  101031. private _verticalBlurPostprocess1;
  101032. private _horizontalBlurPostprocess2;
  101033. private _verticalBlurPostprocess2;
  101034. private _blurTexture1;
  101035. private _blurTexture2;
  101036. private _postProcesses1;
  101037. private _postProcesses2;
  101038. private _includedOnlyMeshes;
  101039. private _excludedMeshes;
  101040. /**
  101041. * Callback used to let the user override the color selection on a per mesh basis
  101042. */
  101043. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  101044. /**
  101045. * Callback used to let the user override the texture selection on a per mesh basis
  101046. */
  101047. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  101048. /**
  101049. * Instantiates a new glow Layer and references it to the scene.
  101050. * @param name The name of the layer
  101051. * @param scene The scene to use the layer in
  101052. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  101053. */
  101054. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  101055. /**
  101056. * Get the effect name of the layer.
  101057. * @return The effect name
  101058. */
  101059. getEffectName(): string;
  101060. /**
  101061. * Create the merge effect. This is the shader use to blit the information back
  101062. * to the main canvas at the end of the scene rendering.
  101063. */
  101064. protected _createMergeEffect(): Effect;
  101065. /**
  101066. * Creates the render target textures and post processes used in the glow layer.
  101067. */
  101068. protected _createTextureAndPostProcesses(): void;
  101069. /**
  101070. * Checks for the readiness of the element composing the layer.
  101071. * @param subMesh the mesh to check for
  101072. * @param useInstances specify wether or not to use instances to render the mesh
  101073. * @param emissiveTexture the associated emissive texture used to generate the glow
  101074. * @return true if ready otherwise, false
  101075. */
  101076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101077. /**
  101078. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101079. */
  101080. needStencil(): boolean;
  101081. /**
  101082. * Returns true if the mesh can be rendered, otherwise false.
  101083. * @param mesh The mesh to render
  101084. * @param material The material used on the mesh
  101085. * @returns true if it can be rendered otherwise false
  101086. */
  101087. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101088. /**
  101089. * Implementation specific of rendering the generating effect on the main canvas.
  101090. * @param effect The effect used to render through
  101091. */
  101092. protected _internalRender(effect: Effect): void;
  101093. /**
  101094. * Sets the required values for both the emissive texture and and the main color.
  101095. */
  101096. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101097. /**
  101098. * Returns true if the mesh should render, otherwise false.
  101099. * @param mesh The mesh to render
  101100. * @returns true if it should render otherwise false
  101101. */
  101102. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101103. /**
  101104. * Adds specific effects defines.
  101105. * @param defines The defines to add specifics to.
  101106. */
  101107. protected _addCustomEffectDefines(defines: string[]): void;
  101108. /**
  101109. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  101110. * @param mesh The mesh to exclude from the glow layer
  101111. */
  101112. addExcludedMesh(mesh: Mesh): void;
  101113. /**
  101114. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  101115. * @param mesh The mesh to remove
  101116. */
  101117. removeExcludedMesh(mesh: Mesh): void;
  101118. /**
  101119. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  101120. * @param mesh The mesh to include in the glow layer
  101121. */
  101122. addIncludedOnlyMesh(mesh: Mesh): void;
  101123. /**
  101124. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  101125. * @param mesh The mesh to remove
  101126. */
  101127. removeIncludedOnlyMesh(mesh: Mesh): void;
  101128. /**
  101129. * Determine if a given mesh will be used in the glow layer
  101130. * @param mesh The mesh to test
  101131. * @returns true if the mesh will be highlighted by the current glow layer
  101132. */
  101133. hasMesh(mesh: AbstractMesh): boolean;
  101134. /**
  101135. * Free any resources and references associated to a mesh.
  101136. * Internal use
  101137. * @param mesh The mesh to free.
  101138. * @hidden
  101139. */
  101140. _disposeMesh(mesh: Mesh): void;
  101141. /**
  101142. * Gets the class name of the effect layer
  101143. * @returns the string with the class name of the effect layer
  101144. */
  101145. getClassName(): string;
  101146. /**
  101147. * Serializes this glow layer
  101148. * @returns a serialized glow layer object
  101149. */
  101150. serialize(): any;
  101151. /**
  101152. * Creates a Glow Layer from parsed glow layer data
  101153. * @param parsedGlowLayer defines glow layer data
  101154. * @param scene defines the current scene
  101155. * @param rootUrl defines the root URL containing the glow layer information
  101156. * @returns a parsed Glow Layer
  101157. */
  101158. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  101159. }
  101160. }
  101161. declare module BABYLON {
  101162. /** @hidden */
  101163. export var glowBlurPostProcessPixelShader: {
  101164. name: string;
  101165. shader: string;
  101166. };
  101167. }
  101168. declare module BABYLON {
  101169. interface AbstractScene {
  101170. /**
  101171. * Return a the first highlight layer of the scene with a given name.
  101172. * @param name The name of the highlight layer to look for.
  101173. * @return The highlight layer if found otherwise null.
  101174. */
  101175. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  101176. }
  101177. /**
  101178. * Highlight layer options. This helps customizing the behaviour
  101179. * of the highlight layer.
  101180. */
  101181. export interface IHighlightLayerOptions {
  101182. /**
  101183. * Multiplication factor apply to the canvas size to compute the render target size
  101184. * used to generated the glowing objects (the smaller the faster).
  101185. */
  101186. mainTextureRatio: number;
  101187. /**
  101188. * Enforces a fixed size texture to ensure resize independant blur.
  101189. */
  101190. mainTextureFixedSize?: number;
  101191. /**
  101192. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  101193. * of the picture to blur (the smaller the faster).
  101194. */
  101195. blurTextureSizeRatio: number;
  101196. /**
  101197. * How big in texel of the blur texture is the vertical blur.
  101198. */
  101199. blurVerticalSize: number;
  101200. /**
  101201. * How big in texel of the blur texture is the horizontal blur.
  101202. */
  101203. blurHorizontalSize: number;
  101204. /**
  101205. * Alpha blending mode used to apply the blur. Default is combine.
  101206. */
  101207. alphaBlendingMode: number;
  101208. /**
  101209. * The camera attached to the layer.
  101210. */
  101211. camera: Nullable<Camera>;
  101212. /**
  101213. * Should we display highlight as a solid stroke?
  101214. */
  101215. isStroke?: boolean;
  101216. /**
  101217. * The rendering group to draw the layer in.
  101218. */
  101219. renderingGroupId: number;
  101220. }
  101221. /**
  101222. * The highlight layer Helps adding a glow effect around a mesh.
  101223. *
  101224. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  101225. * glowy meshes to your scene.
  101226. *
  101227. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  101228. */
  101229. export class HighlightLayer extends EffectLayer {
  101230. name: string;
  101231. /**
  101232. * Effect Name of the highlight layer.
  101233. */
  101234. static readonly EffectName: string;
  101235. /**
  101236. * The neutral color used during the preparation of the glow effect.
  101237. * This is black by default as the blend operation is a blend operation.
  101238. */
  101239. static NeutralColor: Color4;
  101240. /**
  101241. * Stencil value used for glowing meshes.
  101242. */
  101243. static GlowingMeshStencilReference: number;
  101244. /**
  101245. * Stencil value used for the other meshes in the scene.
  101246. */
  101247. static NormalMeshStencilReference: number;
  101248. /**
  101249. * Specifies whether or not the inner glow is ACTIVE in the layer.
  101250. */
  101251. innerGlow: boolean;
  101252. /**
  101253. * Specifies whether or not the outer glow is ACTIVE in the layer.
  101254. */
  101255. outerGlow: boolean;
  101256. /**
  101257. * Specifies the horizontal size of the blur.
  101258. */
  101259. /**
  101260. * Gets the horizontal size of the blur.
  101261. */
  101262. blurHorizontalSize: number;
  101263. /**
  101264. * Specifies the vertical size of the blur.
  101265. */
  101266. /**
  101267. * Gets the vertical size of the blur.
  101268. */
  101269. blurVerticalSize: number;
  101270. /**
  101271. * An event triggered when the highlight layer is being blurred.
  101272. */
  101273. onBeforeBlurObservable: Observable<HighlightLayer>;
  101274. /**
  101275. * An event triggered when the highlight layer has been blurred.
  101276. */
  101277. onAfterBlurObservable: Observable<HighlightLayer>;
  101278. private _instanceGlowingMeshStencilReference;
  101279. private _options;
  101280. private _downSamplePostprocess;
  101281. private _horizontalBlurPostprocess;
  101282. private _verticalBlurPostprocess;
  101283. private _blurTexture;
  101284. private _meshes;
  101285. private _excludedMeshes;
  101286. /**
  101287. * Instantiates a new highlight Layer and references it to the scene..
  101288. * @param name The name of the layer
  101289. * @param scene The scene to use the layer in
  101290. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  101291. */
  101292. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  101293. /**
  101294. * Get the effect name of the layer.
  101295. * @return The effect name
  101296. */
  101297. getEffectName(): string;
  101298. /**
  101299. * Create the merge effect. This is the shader use to blit the information back
  101300. * to the main canvas at the end of the scene rendering.
  101301. */
  101302. protected _createMergeEffect(): Effect;
  101303. /**
  101304. * Creates the render target textures and post processes used in the highlight layer.
  101305. */
  101306. protected _createTextureAndPostProcesses(): void;
  101307. /**
  101308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101309. */
  101310. needStencil(): boolean;
  101311. /**
  101312. * Checks for the readiness of the element composing the layer.
  101313. * @param subMesh the mesh to check for
  101314. * @param useInstances specify wether or not to use instances to render the mesh
  101315. * @param emissiveTexture the associated emissive texture used to generate the glow
  101316. * @return true if ready otherwise, false
  101317. */
  101318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101319. /**
  101320. * Implementation specific of rendering the generating effect on the main canvas.
  101321. * @param effect The effect used to render through
  101322. */
  101323. protected _internalRender(effect: Effect): void;
  101324. /**
  101325. * Returns true if the layer contains information to display, otherwise false.
  101326. */
  101327. shouldRender(): boolean;
  101328. /**
  101329. * Returns true if the mesh should render, otherwise false.
  101330. * @param mesh The mesh to render
  101331. * @returns true if it should render otherwise false
  101332. */
  101333. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101334. /**
  101335. * Sets the required values for both the emissive texture and and the main color.
  101336. */
  101337. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101338. /**
  101339. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  101340. * @param mesh The mesh to exclude from the highlight layer
  101341. */
  101342. addExcludedMesh(mesh: Mesh): void;
  101343. /**
  101344. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  101345. * @param mesh The mesh to highlight
  101346. */
  101347. removeExcludedMesh(mesh: Mesh): void;
  101348. /**
  101349. * Determine if a given mesh will be highlighted by the current HighlightLayer
  101350. * @param mesh mesh to test
  101351. * @returns true if the mesh will be highlighted by the current HighlightLayer
  101352. */
  101353. hasMesh(mesh: AbstractMesh): boolean;
  101354. /**
  101355. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  101356. * @param mesh The mesh to highlight
  101357. * @param color The color of the highlight
  101358. * @param glowEmissiveOnly Extract the glow from the emissive texture
  101359. */
  101360. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  101361. /**
  101362. * Remove a mesh from the highlight layer in order to make it stop glowing.
  101363. * @param mesh The mesh to highlight
  101364. */
  101365. removeMesh(mesh: Mesh): void;
  101366. /**
  101367. * Force the stencil to the normal expected value for none glowing parts
  101368. */
  101369. private _defaultStencilReference;
  101370. /**
  101371. * Free any resources and references associated to a mesh.
  101372. * Internal use
  101373. * @param mesh The mesh to free.
  101374. * @hidden
  101375. */
  101376. _disposeMesh(mesh: Mesh): void;
  101377. /**
  101378. * Dispose the highlight layer and free resources.
  101379. */
  101380. dispose(): void;
  101381. /**
  101382. * Gets the class name of the effect layer
  101383. * @returns the string with the class name of the effect layer
  101384. */
  101385. getClassName(): string;
  101386. /**
  101387. * Serializes this Highlight layer
  101388. * @returns a serialized Highlight layer object
  101389. */
  101390. serialize(): any;
  101391. /**
  101392. * Creates a Highlight layer from parsed Highlight layer data
  101393. * @param parsedHightlightLayer defines the Highlight layer data
  101394. * @param scene defines the current scene
  101395. * @param rootUrl defines the root URL containing the Highlight layer information
  101396. * @returns a parsed Highlight layer
  101397. */
  101398. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  101399. }
  101400. }
  101401. declare module BABYLON {
  101402. /** @hidden */
  101403. export var lensFlarePixelShader: {
  101404. name: string;
  101405. shader: string;
  101406. };
  101407. }
  101408. declare module BABYLON {
  101409. /** @hidden */
  101410. export var lensFlareVertexShader: {
  101411. name: string;
  101412. shader: string;
  101413. };
  101414. }
  101415. declare module BABYLON {
  101416. /**
  101417. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101418. * It is usually composed of several `lensFlare`.
  101419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101420. */
  101421. export class LensFlareSystem {
  101422. /**
  101423. * Define the name of the lens flare system
  101424. */
  101425. name: string;
  101426. /**
  101427. * List of lens flares used in this system.
  101428. */
  101429. lensFlares: LensFlare[];
  101430. /**
  101431. * Define a limit from the border the lens flare can be visible.
  101432. */
  101433. borderLimit: number;
  101434. /**
  101435. * Define a viewport border we do not want to see the lens flare in.
  101436. */
  101437. viewportBorder: number;
  101438. /**
  101439. * Define a predicate which could limit the list of meshes able to occlude the effect.
  101440. */
  101441. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101442. /**
  101443. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  101444. */
  101445. layerMask: number;
  101446. /**
  101447. * Define the id of the lens flare system in the scene.
  101448. * (equal to name by default)
  101449. */
  101450. id: string;
  101451. private _scene;
  101452. private _emitter;
  101453. private _vertexBuffers;
  101454. private _indexBuffer;
  101455. private _effect;
  101456. private _positionX;
  101457. private _positionY;
  101458. private _isEnabled;
  101459. /** @hidden */
  101460. static _SceneComponentInitialization: (scene: Scene) => void;
  101461. /**
  101462. * Instantiates a lens flare system.
  101463. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101464. * It is usually composed of several `lensFlare`.
  101465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101466. * @param name Define the name of the lens flare system in the scene
  101467. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  101468. * @param scene Define the scene the lens flare system belongs to
  101469. */
  101470. constructor(
  101471. /**
  101472. * Define the name of the lens flare system
  101473. */
  101474. name: string, emitter: any, scene: Scene);
  101475. /**
  101476. * Define if the lens flare system is enabled.
  101477. */
  101478. isEnabled: boolean;
  101479. /**
  101480. * Get the scene the effects belongs to.
  101481. * @returns the scene holding the lens flare system
  101482. */
  101483. getScene(): Scene;
  101484. /**
  101485. * Get the emitter of the lens flare system.
  101486. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101487. * @returns the emitter of the lens flare system
  101488. */
  101489. getEmitter(): any;
  101490. /**
  101491. * Set the emitter of the lens flare system.
  101492. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101493. * @param newEmitter Define the new emitter of the system
  101494. */
  101495. setEmitter(newEmitter: any): void;
  101496. /**
  101497. * Get the lens flare system emitter position.
  101498. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  101499. * @returns the position
  101500. */
  101501. getEmitterPosition(): Vector3;
  101502. /**
  101503. * @hidden
  101504. */
  101505. computeEffectivePosition(globalViewport: Viewport): boolean;
  101506. /** @hidden */
  101507. _isVisible(): boolean;
  101508. /**
  101509. * @hidden
  101510. */
  101511. render(): boolean;
  101512. /**
  101513. * Dispose and release the lens flare with its associated resources.
  101514. */
  101515. dispose(): void;
  101516. /**
  101517. * Parse a lens flare system from a JSON repressentation
  101518. * @param parsedLensFlareSystem Define the JSON to parse
  101519. * @param scene Define the scene the parsed system should be instantiated in
  101520. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  101521. * @returns the parsed system
  101522. */
  101523. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  101524. /**
  101525. * Serialize the current Lens Flare System into a JSON representation.
  101526. * @returns the serialized JSON
  101527. */
  101528. serialize(): any;
  101529. }
  101530. }
  101531. declare module BABYLON {
  101532. /**
  101533. * This represents one of the lens effect in a `lensFlareSystem`.
  101534. * It controls one of the indiviual texture used in the effect.
  101535. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101536. */
  101537. export class LensFlare {
  101538. /**
  101539. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101540. */
  101541. size: number;
  101542. /**
  101543. * 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.
  101544. */
  101545. position: number;
  101546. /**
  101547. * Define the lens color.
  101548. */
  101549. color: Color3;
  101550. /**
  101551. * Define the lens texture.
  101552. */
  101553. texture: Nullable<Texture>;
  101554. /**
  101555. * Define the alpha mode to render this particular lens.
  101556. */
  101557. alphaMode: number;
  101558. private _system;
  101559. /**
  101560. * Creates a new Lens Flare.
  101561. * This represents one of the lens effect in a `lensFlareSystem`.
  101562. * It controls one of the indiviual texture used in the effect.
  101563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101564. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  101565. * @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.
  101566. * @param color Define the lens color
  101567. * @param imgUrl Define the lens texture url
  101568. * @param system Define the `lensFlareSystem` this flare is part of
  101569. * @returns The newly created Lens Flare
  101570. */
  101571. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  101572. /**
  101573. * Instantiates a new Lens Flare.
  101574. * This represents one of the lens effect in a `lensFlareSystem`.
  101575. * It controls one of the indiviual texture used in the effect.
  101576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101577. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  101578. * @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.
  101579. * @param color Define the lens color
  101580. * @param imgUrl Define the lens texture url
  101581. * @param system Define the `lensFlareSystem` this flare is part of
  101582. */
  101583. constructor(
  101584. /**
  101585. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101586. */
  101587. size: number,
  101588. /**
  101589. * 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.
  101590. */
  101591. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101592. /**
  101593. * Dispose and release the lens flare with its associated resources.
  101594. */
  101595. dispose(): void;
  101596. }
  101597. }
  101598. declare module BABYLON {
  101599. interface AbstractScene {
  101600. /**
  101601. * The list of lens flare system added to the scene
  101602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101603. */
  101604. lensFlareSystems: Array<LensFlareSystem>;
  101605. /**
  101606. * Removes the given lens flare system from this scene.
  101607. * @param toRemove The lens flare system to remove
  101608. * @returns The index of the removed lens flare system
  101609. */
  101610. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101611. /**
  101612. * Adds the given lens flare system to this scene
  101613. * @param newLensFlareSystem The lens flare system to add
  101614. */
  101615. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101616. /**
  101617. * Gets a lens flare system using its name
  101618. * @param name defines the name to look for
  101619. * @returns the lens flare system or null if not found
  101620. */
  101621. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101622. /**
  101623. * Gets a lens flare system using its id
  101624. * @param id defines the id to look for
  101625. * @returns the lens flare system or null if not found
  101626. */
  101627. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101628. }
  101629. /**
  101630. * Defines the lens flare scene component responsible to manage any lens flares
  101631. * in a given scene.
  101632. */
  101633. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101634. /**
  101635. * The component name helpfull to identify the component in the list of scene components.
  101636. */
  101637. readonly name: string;
  101638. /**
  101639. * The scene the component belongs to.
  101640. */
  101641. scene: Scene;
  101642. /**
  101643. * Creates a new instance of the component for the given scene
  101644. * @param scene Defines the scene to register the component in
  101645. */
  101646. constructor(scene: Scene);
  101647. /**
  101648. * Registers the component in a given scene
  101649. */
  101650. register(): void;
  101651. /**
  101652. * Rebuilds the elements related to this component in case of
  101653. * context lost for instance.
  101654. */
  101655. rebuild(): void;
  101656. /**
  101657. * Adds all the element from the container to the scene
  101658. * @param container the container holding the elements
  101659. */
  101660. addFromContainer(container: AbstractScene): void;
  101661. /**
  101662. * Removes all the elements in the container from the scene
  101663. * @param container contains the elements to remove
  101664. */
  101665. removeFromContainer(container: AbstractScene): void;
  101666. /**
  101667. * Serializes the component data to the specified json object
  101668. * @param serializationObject The object to serialize to
  101669. */
  101670. serialize(serializationObject: any): void;
  101671. /**
  101672. * Disposes the component and the associated ressources.
  101673. */
  101674. dispose(): void;
  101675. private _draw;
  101676. }
  101677. }
  101678. declare module BABYLON {
  101679. /**
  101680. * Defines the shadow generator component responsible to manage any shadow generators
  101681. * in a given scene.
  101682. */
  101683. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101684. /**
  101685. * The component name helpfull to identify the component in the list of scene components.
  101686. */
  101687. readonly name: string;
  101688. /**
  101689. * The scene the component belongs to.
  101690. */
  101691. scene: Scene;
  101692. /**
  101693. * Creates a new instance of the component for the given scene
  101694. * @param scene Defines the scene to register the component in
  101695. */
  101696. constructor(scene: Scene);
  101697. /**
  101698. * Registers the component in a given scene
  101699. */
  101700. register(): void;
  101701. /**
  101702. * Rebuilds the elements related to this component in case of
  101703. * context lost for instance.
  101704. */
  101705. rebuild(): void;
  101706. /**
  101707. * Serializes the component data to the specified json object
  101708. * @param serializationObject The object to serialize to
  101709. */
  101710. serialize(serializationObject: any): void;
  101711. /**
  101712. * Adds all the element from the container to the scene
  101713. * @param container the container holding the elements
  101714. */
  101715. addFromContainer(container: AbstractScene): void;
  101716. /**
  101717. * Removes all the elements in the container from the scene
  101718. * @param container contains the elements to remove
  101719. */
  101720. removeFromContainer(container: AbstractScene): void;
  101721. /**
  101722. * Rebuilds the elements related to this component in case of
  101723. * context lost for instance.
  101724. */
  101725. dispose(): void;
  101726. private _gatherRenderTargets;
  101727. }
  101728. }
  101729. declare module BABYLON {
  101730. /**
  101731. * A directional light is defined by a direction (what a surprise!).
  101732. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101733. * 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.
  101734. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101735. */
  101736. export class DirectionalLight extends ShadowLight {
  101737. private _shadowFrustumSize;
  101738. /**
  101739. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101740. */
  101741. /**
  101742. * Specifies a fix frustum size for the shadow generation.
  101743. */
  101744. shadowFrustumSize: number;
  101745. private _shadowOrthoScale;
  101746. /**
  101747. * Gets the shadow projection scale against the optimal computed one.
  101748. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101749. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101750. */
  101751. /**
  101752. * Sets the shadow projection scale against the optimal computed one.
  101753. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101754. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101755. */
  101756. shadowOrthoScale: number;
  101757. /**
  101758. * Automatically compute the projection matrix to best fit (including all the casters)
  101759. * on each frame.
  101760. */
  101761. autoUpdateExtends: boolean;
  101762. private _orthoLeft;
  101763. private _orthoRight;
  101764. private _orthoTop;
  101765. private _orthoBottom;
  101766. /**
  101767. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101768. * The directional light is emitted from everywhere in the given direction.
  101769. * It can cast shadows.
  101770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101771. * @param name The friendly name of the light
  101772. * @param direction The direction of the light
  101773. * @param scene The scene the light belongs to
  101774. */
  101775. constructor(name: string, direction: Vector3, scene: Scene);
  101776. /**
  101777. * Returns the string "DirectionalLight".
  101778. * @return The class name
  101779. */
  101780. getClassName(): string;
  101781. /**
  101782. * Returns the integer 1.
  101783. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101784. */
  101785. getTypeID(): number;
  101786. /**
  101787. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101788. * Returns the DirectionalLight Shadow projection matrix.
  101789. */
  101790. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101791. /**
  101792. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101793. * Returns the DirectionalLight Shadow projection matrix.
  101794. */
  101795. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101796. /**
  101797. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101798. * Returns the DirectionalLight Shadow projection matrix.
  101799. */
  101800. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101801. protected _buildUniformLayout(): void;
  101802. /**
  101803. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101804. * @param effect The effect to update
  101805. * @param lightIndex The index of the light in the effect to update
  101806. * @returns The directional light
  101807. */
  101808. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101809. /**
  101810. * Gets the minZ used for shadow according to both the scene and the light.
  101811. *
  101812. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101813. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101814. * @param activeCamera The camera we are returning the min for
  101815. * @returns the depth min z
  101816. */
  101817. getDepthMinZ(activeCamera: Camera): number;
  101818. /**
  101819. * Gets the maxZ used for shadow according to both the scene and the light.
  101820. *
  101821. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101822. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101823. * @param activeCamera The camera we are returning the max for
  101824. * @returns the depth max z
  101825. */
  101826. getDepthMaxZ(activeCamera: Camera): number;
  101827. /**
  101828. * Prepares the list of defines specific to the light type.
  101829. * @param defines the list of defines
  101830. * @param lightIndex defines the index of the light for the effect
  101831. */
  101832. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101833. }
  101834. }
  101835. declare module BABYLON {
  101836. /**
  101837. * A point light is a light defined by an unique point in world space.
  101838. * The light is emitted in every direction from this point.
  101839. * A good example of a point light is a standard light bulb.
  101840. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101841. */
  101842. export class PointLight extends ShadowLight {
  101843. private _shadowAngle;
  101844. /**
  101845. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101846. * This specifies what angle the shadow will use to be created.
  101847. *
  101848. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101849. */
  101850. /**
  101851. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101852. * This specifies what angle the shadow will use to be created.
  101853. *
  101854. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101855. */
  101856. shadowAngle: number;
  101857. /**
  101858. * Gets the direction if it has been set.
  101859. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101860. */
  101861. /**
  101862. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101863. */
  101864. direction: Vector3;
  101865. /**
  101866. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101867. * A PointLight emits the light in every direction.
  101868. * It can cast shadows.
  101869. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101870. * ```javascript
  101871. * var pointLight = new PointLight("pl", camera.position, scene);
  101872. * ```
  101873. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101874. * @param name The light friendly name
  101875. * @param position The position of the point light in the scene
  101876. * @param scene The scene the lights belongs to
  101877. */
  101878. constructor(name: string, position: Vector3, scene: Scene);
  101879. /**
  101880. * Returns the string "PointLight"
  101881. * @returns the class name
  101882. */
  101883. getClassName(): string;
  101884. /**
  101885. * Returns the integer 0.
  101886. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101887. */
  101888. getTypeID(): number;
  101889. /**
  101890. * Specifies wether or not the shadowmap should be a cube texture.
  101891. * @returns true if the shadowmap needs to be a cube texture.
  101892. */
  101893. needCube(): boolean;
  101894. /**
  101895. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101896. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101897. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101898. */
  101899. getShadowDirection(faceIndex?: number): Vector3;
  101900. /**
  101901. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101902. * - fov = PI / 2
  101903. * - aspect ratio : 1.0
  101904. * - z-near and far equal to the active camera minZ and maxZ.
  101905. * Returns the PointLight.
  101906. */
  101907. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101908. protected _buildUniformLayout(): void;
  101909. /**
  101910. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101911. * @param effect The effect to update
  101912. * @param lightIndex The index of the light in the effect to update
  101913. * @returns The point light
  101914. */
  101915. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101916. /**
  101917. * Prepares the list of defines specific to the light type.
  101918. * @param defines the list of defines
  101919. * @param lightIndex defines the index of the light for the effect
  101920. */
  101921. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101922. }
  101923. }
  101924. declare module BABYLON {
  101925. /**
  101926. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101927. * These values define a cone of light starting from the position, emitting toward the direction.
  101928. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101929. * and the exponent defines the speed of the decay of the light with distance (reach).
  101930. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101931. */
  101932. export class SpotLight extends ShadowLight {
  101933. private _angle;
  101934. private _innerAngle;
  101935. private _cosHalfAngle;
  101936. private _lightAngleScale;
  101937. private _lightAngleOffset;
  101938. /**
  101939. * Gets the cone angle of the spot light in Radians.
  101940. */
  101941. /**
  101942. * Sets the cone angle of the spot light in Radians.
  101943. */
  101944. angle: number;
  101945. /**
  101946. * Only used in gltf falloff mode, this defines the angle where
  101947. * the directional falloff will start before cutting at angle which could be seen
  101948. * as outer angle.
  101949. */
  101950. /**
  101951. * Only used in gltf falloff mode, this defines the angle where
  101952. * the directional falloff will start before cutting at angle which could be seen
  101953. * as outer angle.
  101954. */
  101955. innerAngle: number;
  101956. private _shadowAngleScale;
  101957. /**
  101958. * Allows scaling the angle of the light for shadow generation only.
  101959. */
  101960. /**
  101961. * Allows scaling the angle of the light for shadow generation only.
  101962. */
  101963. shadowAngleScale: number;
  101964. /**
  101965. * The light decay speed with the distance from the emission spot.
  101966. */
  101967. exponent: number;
  101968. private _projectionTextureMatrix;
  101969. /**
  101970. * Allows reading the projecton texture
  101971. */
  101972. readonly projectionTextureMatrix: Matrix;
  101973. protected _projectionTextureLightNear: number;
  101974. /**
  101975. * Gets the near clip of the Spotlight for texture projection.
  101976. */
  101977. /**
  101978. * Sets the near clip of the Spotlight for texture projection.
  101979. */
  101980. projectionTextureLightNear: number;
  101981. protected _projectionTextureLightFar: number;
  101982. /**
  101983. * Gets the far clip of the Spotlight for texture projection.
  101984. */
  101985. /**
  101986. * Sets the far clip of the Spotlight for texture projection.
  101987. */
  101988. projectionTextureLightFar: number;
  101989. protected _projectionTextureUpDirection: Vector3;
  101990. /**
  101991. * Gets the Up vector of the Spotlight for texture projection.
  101992. */
  101993. /**
  101994. * Sets the Up vector of the Spotlight for texture projection.
  101995. */
  101996. projectionTextureUpDirection: Vector3;
  101997. private _projectionTexture;
  101998. /**
  101999. * Gets the projection texture of the light.
  102000. */
  102001. /**
  102002. * Sets the projection texture of the light.
  102003. */
  102004. projectionTexture: Nullable<BaseTexture>;
  102005. private _projectionTextureViewLightDirty;
  102006. private _projectionTextureProjectionLightDirty;
  102007. private _projectionTextureDirty;
  102008. private _projectionTextureViewTargetVector;
  102009. private _projectionTextureViewLightMatrix;
  102010. private _projectionTextureProjectionLightMatrix;
  102011. private _projectionTextureScalingMatrix;
  102012. /**
  102013. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102014. * It can cast shadows.
  102015. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102016. * @param name The light friendly name
  102017. * @param position The position of the spot light in the scene
  102018. * @param direction The direction of the light in the scene
  102019. * @param angle The cone angle of the light in Radians
  102020. * @param exponent The light decay speed with the distance from the emission spot
  102021. * @param scene The scene the lights belongs to
  102022. */
  102023. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102024. /**
  102025. * Returns the string "SpotLight".
  102026. * @returns the class name
  102027. */
  102028. getClassName(): string;
  102029. /**
  102030. * Returns the integer 2.
  102031. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102032. */
  102033. getTypeID(): number;
  102034. /**
  102035. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102036. */
  102037. protected _setDirection(value: Vector3): void;
  102038. /**
  102039. * Overrides the position setter to recompute the projection texture view light Matrix.
  102040. */
  102041. protected _setPosition(value: Vector3): void;
  102042. /**
  102043. * 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.
  102044. * Returns the SpotLight.
  102045. */
  102046. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102047. protected _computeProjectionTextureViewLightMatrix(): void;
  102048. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102049. /**
  102050. * Main function for light texture projection matrix computing.
  102051. */
  102052. protected _computeProjectionTextureMatrix(): void;
  102053. protected _buildUniformLayout(): void;
  102054. private _computeAngleValues;
  102055. /**
  102056. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102057. * @param effect The effect to update
  102058. * @param lightIndex The index of the light in the effect to update
  102059. * @returns The spot light
  102060. */
  102061. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102062. /**
  102063. * Disposes the light and the associated resources.
  102064. */
  102065. dispose(): void;
  102066. /**
  102067. * Prepares the list of defines specific to the light type.
  102068. * @param defines the list of defines
  102069. * @param lightIndex defines the index of the light for the effect
  102070. */
  102071. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102072. }
  102073. }
  102074. declare module BABYLON {
  102075. /**
  102076. * Header information of HDR texture files.
  102077. */
  102078. export interface HDRInfo {
  102079. /**
  102080. * The height of the texture in pixels.
  102081. */
  102082. height: number;
  102083. /**
  102084. * The width of the texture in pixels.
  102085. */
  102086. width: number;
  102087. /**
  102088. * The index of the beginning of the data in the binary file.
  102089. */
  102090. dataPosition: number;
  102091. }
  102092. /**
  102093. * This groups tools to convert HDR texture to native colors array.
  102094. */
  102095. export class HDRTools {
  102096. private static Ldexp;
  102097. private static Rgbe2float;
  102098. private static readStringLine;
  102099. /**
  102100. * Reads header information from an RGBE texture stored in a native array.
  102101. * More information on this format are available here:
  102102. * https://en.wikipedia.org/wiki/RGBE_image_format
  102103. *
  102104. * @param uint8array The binary file stored in native array.
  102105. * @return The header information.
  102106. */
  102107. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  102108. /**
  102109. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  102110. * This RGBE texture needs to store the information as a panorama.
  102111. *
  102112. * More information on this format are available here:
  102113. * https://en.wikipedia.org/wiki/RGBE_image_format
  102114. *
  102115. * @param buffer The binary file stored in an array buffer.
  102116. * @param size The expected size of the extracted cubemap.
  102117. * @return The Cube Map information.
  102118. */
  102119. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  102120. /**
  102121. * Returns the pixels data extracted from an RGBE texture.
  102122. * This pixels will be stored left to right up to down in the R G B order in one array.
  102123. *
  102124. * More information on this format are available here:
  102125. * https://en.wikipedia.org/wiki/RGBE_image_format
  102126. *
  102127. * @param uint8array The binary file stored in an array buffer.
  102128. * @param hdrInfo The header information of the file.
  102129. * @return The pixels data in RGB right to left up to down order.
  102130. */
  102131. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  102132. private static RGBE_ReadPixels_RLE;
  102133. }
  102134. }
  102135. declare module BABYLON {
  102136. /**
  102137. * This represents a texture coming from an HDR input.
  102138. *
  102139. * The only supported format is currently panorama picture stored in RGBE format.
  102140. * Example of such files can be found on HDRLib: http://hdrlib.com/
  102141. */
  102142. export class HDRCubeTexture extends BaseTexture {
  102143. private static _facesMapping;
  102144. private _generateHarmonics;
  102145. private _noMipmap;
  102146. private _textureMatrix;
  102147. private _size;
  102148. private _onLoad;
  102149. private _onError;
  102150. /**
  102151. * The texture URL.
  102152. */
  102153. url: string;
  102154. /**
  102155. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  102156. */
  102157. coordinatesMode: number;
  102158. protected _isBlocking: boolean;
  102159. /**
  102160. * Sets wether or not the texture is blocking during loading.
  102161. */
  102162. /**
  102163. * Gets wether or not the texture is blocking during loading.
  102164. */
  102165. isBlocking: boolean;
  102166. protected _rotationY: number;
  102167. /**
  102168. * Sets texture matrix rotation angle around Y axis in radians.
  102169. */
  102170. /**
  102171. * Gets texture matrix rotation angle around Y axis radians.
  102172. */
  102173. rotationY: number;
  102174. /**
  102175. * Gets or sets the center of the bounding box associated with the cube texture
  102176. * It must define where the camera used to render the texture was set
  102177. */
  102178. boundingBoxPosition: Vector3;
  102179. private _boundingBoxSize;
  102180. /**
  102181. * Gets or sets the size of the bounding box associated with the cube texture
  102182. * When defined, the cubemap will switch to local mode
  102183. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102184. * @example https://www.babylonjs-playground.com/#RNASML
  102185. */
  102186. boundingBoxSize: Vector3;
  102187. /**
  102188. * Instantiates an HDRTexture from the following parameters.
  102189. *
  102190. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  102191. * @param scene The scene the texture will be used in
  102192. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  102193. * @param noMipmap Forces to not generate the mipmap if true
  102194. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  102195. * @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)
  102196. * @param reserved Reserved flag for internal use.
  102197. */
  102198. 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>);
  102199. /**
  102200. * Get the current class name of the texture useful for serialization or dynamic coding.
  102201. * @returns "HDRCubeTexture"
  102202. */
  102203. getClassName(): string;
  102204. /**
  102205. * Occurs when the file is raw .hdr file.
  102206. */
  102207. private loadTexture;
  102208. clone(): HDRCubeTexture;
  102209. delayLoad(): void;
  102210. /**
  102211. * Get the texture reflection matrix used to rotate/transform the reflection.
  102212. * @returns the reflection matrix
  102213. */
  102214. getReflectionTextureMatrix(): Matrix;
  102215. /**
  102216. * Set the texture reflection matrix used to rotate/transform the reflection.
  102217. * @param value Define the reflection matrix to set
  102218. */
  102219. setReflectionTextureMatrix(value: Matrix): void;
  102220. /**
  102221. * Parses a JSON representation of an HDR Texture in order to create the texture
  102222. * @param parsedTexture Define the JSON representation
  102223. * @param scene Define the scene the texture should be created in
  102224. * @param rootUrl Define the root url in case we need to load relative dependencies
  102225. * @returns the newly created texture after parsing
  102226. */
  102227. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  102228. serialize(): any;
  102229. }
  102230. }
  102231. declare module BABYLON {
  102232. /**
  102233. * Class used to control physics engine
  102234. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  102235. */
  102236. export class PhysicsEngine implements IPhysicsEngine {
  102237. private _physicsPlugin;
  102238. /**
  102239. * Global value used to control the smallest number supported by the simulation
  102240. */
  102241. static Epsilon: number;
  102242. private _impostors;
  102243. private _joints;
  102244. /**
  102245. * Gets the gravity vector used by the simulation
  102246. */
  102247. gravity: Vector3;
  102248. /**
  102249. * Factory used to create the default physics plugin.
  102250. * @returns The default physics plugin
  102251. */
  102252. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  102253. /**
  102254. * Creates a new Physics Engine
  102255. * @param gravity defines the gravity vector used by the simulation
  102256. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  102257. */
  102258. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  102259. /**
  102260. * Sets the gravity vector used by the simulation
  102261. * @param gravity defines the gravity vector to use
  102262. */
  102263. setGravity(gravity: Vector3): void;
  102264. /**
  102265. * Set the time step of the physics engine.
  102266. * Default is 1/60.
  102267. * To slow it down, enter 1/600 for example.
  102268. * To speed it up, 1/30
  102269. * @param newTimeStep defines the new timestep to apply to this world.
  102270. */
  102271. setTimeStep(newTimeStep?: number): void;
  102272. /**
  102273. * Get the time step of the physics engine.
  102274. * @returns the current time step
  102275. */
  102276. getTimeStep(): number;
  102277. /**
  102278. * Release all resources
  102279. */
  102280. dispose(): void;
  102281. /**
  102282. * Gets the name of the current physics plugin
  102283. * @returns the name of the plugin
  102284. */
  102285. getPhysicsPluginName(): string;
  102286. /**
  102287. * Adding a new impostor for the impostor tracking.
  102288. * This will be done by the impostor itself.
  102289. * @param impostor the impostor to add
  102290. */
  102291. addImpostor(impostor: PhysicsImpostor): void;
  102292. /**
  102293. * Remove an impostor from the engine.
  102294. * This impostor and its mesh will not longer be updated by the physics engine.
  102295. * @param impostor the impostor to remove
  102296. */
  102297. removeImpostor(impostor: PhysicsImpostor): void;
  102298. /**
  102299. * Add a joint to the physics engine
  102300. * @param mainImpostor defines the main impostor to which the joint is added.
  102301. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  102302. * @param joint defines the joint that will connect both impostors.
  102303. */
  102304. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102305. /**
  102306. * Removes a joint from the simulation
  102307. * @param mainImpostor defines the impostor used with the joint
  102308. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  102309. * @param joint defines the joint to remove
  102310. */
  102311. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102312. /**
  102313. * Called by the scene. No need to call it.
  102314. * @param delta defines the timespam between frames
  102315. */
  102316. _step(delta: number): void;
  102317. /**
  102318. * Gets the current plugin used to run the simulation
  102319. * @returns current plugin
  102320. */
  102321. getPhysicsPlugin(): IPhysicsEnginePlugin;
  102322. /**
  102323. * Gets the list of physic impostors
  102324. * @returns an array of PhysicsImpostor
  102325. */
  102326. getImpostors(): Array<PhysicsImpostor>;
  102327. /**
  102328. * Gets the impostor for a physics enabled object
  102329. * @param object defines the object impersonated by the impostor
  102330. * @returns the PhysicsImpostor or null if not found
  102331. */
  102332. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  102333. /**
  102334. * Gets the impostor for a physics body object
  102335. * @param body defines physics body used by the impostor
  102336. * @returns the PhysicsImpostor or null if not found
  102337. */
  102338. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  102339. }
  102340. }
  102341. declare module BABYLON {
  102342. /** @hidden */
  102343. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  102344. private _useDeltaForWorldStep;
  102345. world: any;
  102346. name: string;
  102347. private _physicsMaterials;
  102348. private _fixedTimeStep;
  102349. BJSCANNON: any;
  102350. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  102351. setGravity(gravity: Vector3): void;
  102352. setTimeStep(timeStep: number): void;
  102353. getTimeStep(): number;
  102354. executeStep(delta: number): void;
  102355. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102356. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102357. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102358. private _processChildMeshes;
  102359. removePhysicsBody(impostor: PhysicsImpostor): void;
  102360. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102361. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102362. private _addMaterial;
  102363. private _checkWithEpsilon;
  102364. private _createShape;
  102365. private _createHeightmap;
  102366. private _minus90X;
  102367. private _plus90X;
  102368. private _tmpPosition;
  102369. private _tmpDeltaPosition;
  102370. private _tmpUnityRotation;
  102371. private _updatePhysicsBodyTransformation;
  102372. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102373. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102374. isSupported(): boolean;
  102375. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102376. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102377. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102378. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102379. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102380. getBodyMass(impostor: PhysicsImpostor): number;
  102381. getBodyFriction(impostor: PhysicsImpostor): number;
  102382. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102383. getBodyRestitution(impostor: PhysicsImpostor): number;
  102384. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102385. sleepBody(impostor: PhysicsImpostor): void;
  102386. wakeUpBody(impostor: PhysicsImpostor): void;
  102387. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  102388. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  102389. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  102390. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102391. getRadius(impostor: PhysicsImpostor): number;
  102392. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102393. dispose(): void;
  102394. private _extendNamespace;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /** @hidden */
  102399. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  102400. world: any;
  102401. name: string;
  102402. BJSOIMO: any;
  102403. constructor(iterations?: number, oimoInjection?: any);
  102404. setGravity(gravity: Vector3): void;
  102405. setTimeStep(timeStep: number): void;
  102406. getTimeStep(): number;
  102407. private _tmpImpostorsArray;
  102408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  102409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102412. private _tmpPositionVector;
  102413. removePhysicsBody(impostor: PhysicsImpostor): void;
  102414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102415. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102416. isSupported(): boolean;
  102417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102424. getBodyMass(impostor: PhysicsImpostor): number;
  102425. getBodyFriction(impostor: PhysicsImpostor): number;
  102426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102427. getBodyRestitution(impostor: PhysicsImpostor): number;
  102428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102429. sleepBody(impostor: PhysicsImpostor): void;
  102430. wakeUpBody(impostor: PhysicsImpostor): void;
  102431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  102432. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  102433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  102434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102435. getRadius(impostor: PhysicsImpostor): number;
  102436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102437. dispose(): void;
  102438. }
  102439. }
  102440. declare module BABYLON {
  102441. interface AbstractScene {
  102442. /**
  102443. * The list of reflection probes added to the scene
  102444. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102445. */
  102446. reflectionProbes: Array<ReflectionProbe>;
  102447. /**
  102448. * Removes the given reflection probe from this scene.
  102449. * @param toRemove The reflection probe to remove
  102450. * @returns The index of the removed reflection probe
  102451. */
  102452. removeReflectionProbe(toRemove: ReflectionProbe): number;
  102453. /**
  102454. * Adds the given reflection probe to this scene.
  102455. * @param newReflectionProbe The reflection probe to add
  102456. */
  102457. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  102458. }
  102459. /**
  102460. * Class used to generate realtime reflection / refraction cube textures
  102461. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102462. */
  102463. export class ReflectionProbe {
  102464. /** defines the name of the probe */
  102465. name: string;
  102466. private _scene;
  102467. private _renderTargetTexture;
  102468. private _projectionMatrix;
  102469. private _viewMatrix;
  102470. private _target;
  102471. private _add;
  102472. private _attachedMesh;
  102473. private _invertYAxis;
  102474. /** Gets or sets probe position (center of the cube map) */
  102475. position: Vector3;
  102476. /**
  102477. * Creates a new reflection probe
  102478. * @param name defines the name of the probe
  102479. * @param size defines the texture resolution (for each face)
  102480. * @param scene defines the hosting scene
  102481. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  102482. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  102483. */
  102484. constructor(
  102485. /** defines the name of the probe */
  102486. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  102487. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  102488. samples: number;
  102489. /** Gets or sets the refresh rate to use (on every frame by default) */
  102490. refreshRate: number;
  102491. /**
  102492. * Gets the hosting scene
  102493. * @returns a Scene
  102494. */
  102495. getScene(): Scene;
  102496. /** Gets the internal CubeTexture used to render to */
  102497. readonly cubeTexture: RenderTargetTexture;
  102498. /** Gets the list of meshes to render */
  102499. readonly renderList: Nullable<AbstractMesh[]>;
  102500. /**
  102501. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  102502. * @param mesh defines the mesh to attach to
  102503. */
  102504. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102505. /**
  102506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  102507. * @param renderingGroupId The rendering group id corresponding to its index
  102508. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102509. */
  102510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102511. /**
  102512. * Clean all associated resources
  102513. */
  102514. dispose(): void;
  102515. /**
  102516. * Converts the reflection probe information to a readable string for debug purpose.
  102517. * @param fullDetails Supports for multiple levels of logging within scene loading
  102518. * @returns the human readable reflection probe info
  102519. */
  102520. toString(fullDetails?: boolean): string;
  102521. /**
  102522. * Get the class name of the relfection probe.
  102523. * @returns "ReflectionProbe"
  102524. */
  102525. getClassName(): string;
  102526. /**
  102527. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  102528. * @returns The JSON representation of the texture
  102529. */
  102530. serialize(): any;
  102531. /**
  102532. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  102533. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  102534. * @param scene Define the scene the parsed reflection probe should be instantiated in
  102535. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102536. * @returns The parsed reflection probe if successful
  102537. */
  102538. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  102539. }
  102540. }
  102541. declare module BABYLON {
  102542. /** @hidden */
  102543. export var _BabylonLoaderRegistered: boolean;
  102544. }
  102545. declare module BABYLON {
  102546. /**
  102547. * The Physically based simple base material of BJS.
  102548. *
  102549. * This enables better naming and convention enforcements on top of the pbrMaterial.
  102550. * It is used as the base class for both the specGloss and metalRough conventions.
  102551. */
  102552. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  102553. /**
  102554. * Number of Simultaneous lights allowed on the material.
  102555. */
  102556. maxSimultaneousLights: number;
  102557. /**
  102558. * If sets to true, disables all the lights affecting the material.
  102559. */
  102560. disableLighting: boolean;
  102561. /**
  102562. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  102563. */
  102564. environmentTexture: BaseTexture;
  102565. /**
  102566. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102567. */
  102568. invertNormalMapX: boolean;
  102569. /**
  102570. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102571. */
  102572. invertNormalMapY: boolean;
  102573. /**
  102574. * Normal map used in the model.
  102575. */
  102576. normalTexture: BaseTexture;
  102577. /**
  102578. * Emissivie color used to self-illuminate the model.
  102579. */
  102580. emissiveColor: Color3;
  102581. /**
  102582. * Emissivie texture used to self-illuminate the model.
  102583. */
  102584. emissiveTexture: BaseTexture;
  102585. /**
  102586. * Occlusion Channel Strenght.
  102587. */
  102588. occlusionStrength: number;
  102589. /**
  102590. * Occlusion Texture of the material (adding extra occlusion effects).
  102591. */
  102592. occlusionTexture: BaseTexture;
  102593. /**
  102594. * Defines the alpha limits in alpha test mode.
  102595. */
  102596. alphaCutOff: number;
  102597. /**
  102598. * Gets the current double sided mode.
  102599. */
  102600. /**
  102601. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102602. */
  102603. doubleSided: boolean;
  102604. /**
  102605. * Stores the pre-calculated light information of a mesh in a texture.
  102606. */
  102607. lightmapTexture: BaseTexture;
  102608. /**
  102609. * If true, the light map contains occlusion information instead of lighting info.
  102610. */
  102611. useLightmapAsShadowmap: boolean;
  102612. /**
  102613. * Instantiates a new PBRMaterial instance.
  102614. *
  102615. * @param name The material name
  102616. * @param scene The scene the material will be use in.
  102617. */
  102618. constructor(name: string, scene: Scene);
  102619. getClassName(): string;
  102620. }
  102621. }
  102622. declare module BABYLON {
  102623. /**
  102624. * The PBR material of BJS following the metal roughness convention.
  102625. *
  102626. * This fits to the PBR convention in the GLTF definition:
  102627. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102628. */
  102629. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102630. /**
  102631. * The base color has two different interpretations depending on the value of metalness.
  102632. * When the material is a metal, the base color is the specific measured reflectance value
  102633. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102634. * of the material.
  102635. */
  102636. baseColor: Color3;
  102637. /**
  102638. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102639. * well as opacity information in the alpha channel.
  102640. */
  102641. baseTexture: BaseTexture;
  102642. /**
  102643. * Specifies the metallic scalar value of the material.
  102644. * Can also be used to scale the metalness values of the metallic texture.
  102645. */
  102646. metallic: number;
  102647. /**
  102648. * Specifies the roughness scalar value of the material.
  102649. * Can also be used to scale the roughness values of the metallic texture.
  102650. */
  102651. roughness: number;
  102652. /**
  102653. * Texture containing both the metallic value in the B channel and the
  102654. * roughness value in the G channel to keep better precision.
  102655. */
  102656. metallicRoughnessTexture: BaseTexture;
  102657. /**
  102658. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102659. *
  102660. * @param name The material name
  102661. * @param scene The scene the material will be use in.
  102662. */
  102663. constructor(name: string, scene: Scene);
  102664. /**
  102665. * Return the currrent class name of the material.
  102666. */
  102667. getClassName(): string;
  102668. /**
  102669. * Makes a duplicate of the current material.
  102670. * @param name - name to use for the new material.
  102671. */
  102672. clone(name: string): PBRMetallicRoughnessMaterial;
  102673. /**
  102674. * Serialize the material to a parsable JSON object.
  102675. */
  102676. serialize(): any;
  102677. /**
  102678. * Parses a JSON object correponding to the serialize function.
  102679. */
  102680. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102681. }
  102682. }
  102683. declare module BABYLON {
  102684. /**
  102685. * The PBR material of BJS following the specular glossiness convention.
  102686. *
  102687. * This fits to the PBR convention in the GLTF definition:
  102688. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102689. */
  102690. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102691. /**
  102692. * Specifies the diffuse color of the material.
  102693. */
  102694. diffuseColor: Color3;
  102695. /**
  102696. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102697. * channel.
  102698. */
  102699. diffuseTexture: BaseTexture;
  102700. /**
  102701. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102702. */
  102703. specularColor: Color3;
  102704. /**
  102705. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102706. */
  102707. glossiness: number;
  102708. /**
  102709. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102710. */
  102711. specularGlossinessTexture: BaseTexture;
  102712. /**
  102713. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102714. *
  102715. * @param name The material name
  102716. * @param scene The scene the material will be use in.
  102717. */
  102718. constructor(name: string, scene: Scene);
  102719. /**
  102720. * Return the currrent class name of the material.
  102721. */
  102722. getClassName(): string;
  102723. /**
  102724. * Makes a duplicate of the current material.
  102725. * @param name - name to use for the new material.
  102726. */
  102727. clone(name: string): PBRSpecularGlossinessMaterial;
  102728. /**
  102729. * Serialize the material to a parsable JSON object.
  102730. */
  102731. serialize(): any;
  102732. /**
  102733. * Parses a JSON object correponding to the serialize function.
  102734. */
  102735. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102736. }
  102737. }
  102738. declare module BABYLON {
  102739. /**
  102740. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102741. * It can help converting any input color in a desired output one. This can then be used to create effects
  102742. * from sepia, black and white to sixties or futuristic rendering...
  102743. *
  102744. * The only supported format is currently 3dl.
  102745. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102746. */
  102747. export class ColorGradingTexture extends BaseTexture {
  102748. /**
  102749. * The current texture matrix. (will always be identity in color grading texture)
  102750. */
  102751. private _textureMatrix;
  102752. /**
  102753. * The texture URL.
  102754. */
  102755. url: string;
  102756. /**
  102757. * Empty line regex stored for GC.
  102758. */
  102759. private static _noneEmptyLineRegex;
  102760. private _engine;
  102761. /**
  102762. * Instantiates a ColorGradingTexture from the following parameters.
  102763. *
  102764. * @param url The location of the color gradind data (currently only supporting 3dl)
  102765. * @param scene The scene the texture will be used in
  102766. */
  102767. constructor(url: string, scene: Scene);
  102768. /**
  102769. * Returns the texture matrix used in most of the material.
  102770. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102771. */
  102772. getTextureMatrix(): Matrix;
  102773. /**
  102774. * Occurs when the file being loaded is a .3dl LUT file.
  102775. */
  102776. private load3dlTexture;
  102777. /**
  102778. * Starts the loading process of the texture.
  102779. */
  102780. private loadTexture;
  102781. /**
  102782. * Clones the color gradind texture.
  102783. */
  102784. clone(): ColorGradingTexture;
  102785. /**
  102786. * Called during delayed load for textures.
  102787. */
  102788. delayLoad(): void;
  102789. /**
  102790. * Parses a color grading texture serialized by Babylon.
  102791. * @param parsedTexture The texture information being parsedTexture
  102792. * @param scene The scene to load the texture in
  102793. * @param rootUrl The root url of the data assets to load
  102794. * @return A color gradind texture
  102795. */
  102796. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102797. /**
  102798. * Serializes the LUT texture to json format.
  102799. */
  102800. serialize(): any;
  102801. }
  102802. }
  102803. declare module BABYLON {
  102804. /**
  102805. * Direct draw surface info
  102806. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102807. */
  102808. export interface DDSInfo {
  102809. /**
  102810. * Width of the texture
  102811. */
  102812. width: number;
  102813. /**
  102814. * Width of the texture
  102815. */
  102816. height: number;
  102817. /**
  102818. * Number of Mipmaps for the texture
  102819. * @see https://en.wikipedia.org/wiki/Mipmap
  102820. */
  102821. mipmapCount: number;
  102822. /**
  102823. * If the textures format is a known fourCC format
  102824. * @see https://www.fourcc.org/
  102825. */
  102826. isFourCC: boolean;
  102827. /**
  102828. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102829. */
  102830. isRGB: boolean;
  102831. /**
  102832. * If the texture is a lumincance format
  102833. */
  102834. isLuminance: boolean;
  102835. /**
  102836. * If this is a cube texture
  102837. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102838. */
  102839. isCube: boolean;
  102840. /**
  102841. * If the texture is a compressed format eg. FOURCC_DXT1
  102842. */
  102843. isCompressed: boolean;
  102844. /**
  102845. * The dxgiFormat of the texture
  102846. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102847. */
  102848. dxgiFormat: number;
  102849. /**
  102850. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102851. */
  102852. textureType: number;
  102853. /**
  102854. * Sphericle polynomial created for the dds texture
  102855. */
  102856. sphericalPolynomial?: SphericalPolynomial;
  102857. }
  102858. /**
  102859. * Class used to provide DDS decompression tools
  102860. */
  102861. export class DDSTools {
  102862. /**
  102863. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102864. */
  102865. static StoreLODInAlphaChannel: boolean;
  102866. /**
  102867. * Gets DDS information from an array buffer
  102868. * @param arrayBuffer defines the array buffer to read data from
  102869. * @returns the DDS information
  102870. */
  102871. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102872. private static _FloatView;
  102873. private static _Int32View;
  102874. private static _ToHalfFloat;
  102875. private static _FromHalfFloat;
  102876. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102877. private static _GetHalfFloatRGBAArrayBuffer;
  102878. private static _GetFloatRGBAArrayBuffer;
  102879. private static _GetFloatAsUIntRGBAArrayBuffer;
  102880. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102881. private static _GetRGBAArrayBuffer;
  102882. private static _ExtractLongWordOrder;
  102883. private static _GetRGBArrayBuffer;
  102884. private static _GetLuminanceArrayBuffer;
  102885. /**
  102886. * Uploads DDS Levels to a Babylon Texture
  102887. * @hidden
  102888. */
  102889. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102890. }
  102891. interface Engine {
  102892. /**
  102893. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102894. * @param rootUrl defines the url where the file to load is located
  102895. * @param scene defines the current scene
  102896. * @param lodScale defines scale to apply to the mip map selection
  102897. * @param lodOffset defines offset to apply to the mip map selection
  102898. * @param onLoad defines an optional callback raised when the texture is loaded
  102899. * @param onError defines an optional callback raised if there is an issue to load the texture
  102900. * @param format defines the format of the data
  102901. * @param forcedExtension defines the extension to use to pick the right loader
  102902. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102903. * @returns the cube texture as an InternalTexture
  102904. */
  102905. 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;
  102906. }
  102907. }
  102908. declare module BABYLON {
  102909. /**
  102910. * Implementation of the DDS Texture Loader.
  102911. * @hidden
  102912. */
  102913. export class _DDSTextureLoader implements IInternalTextureLoader {
  102914. /**
  102915. * Defines wether the loader supports cascade loading the different faces.
  102916. */
  102917. readonly supportCascades: boolean;
  102918. /**
  102919. * This returns if the loader support the current file information.
  102920. * @param extension defines the file extension of the file being loaded
  102921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102922. * @param fallback defines the fallback internal texture if any
  102923. * @param isBase64 defines whether the texture is encoded as a base64
  102924. * @param isBuffer defines whether the texture data are stored as a buffer
  102925. * @returns true if the loader can load the specified file
  102926. */
  102927. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102928. /**
  102929. * Transform the url before loading if required.
  102930. * @param rootUrl the url of the texture
  102931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102932. * @returns the transformed texture
  102933. */
  102934. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102935. /**
  102936. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102937. * @param rootUrl the url of the texture
  102938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102939. * @returns the fallback texture
  102940. */
  102941. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102942. /**
  102943. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102944. * @param data contains the texture data
  102945. * @param texture defines the BabylonJS internal texture
  102946. * @param createPolynomials will be true if polynomials have been requested
  102947. * @param onLoad defines the callback to trigger once the texture is ready
  102948. * @param onError defines the callback to trigger in case of error
  102949. */
  102950. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102951. /**
  102952. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102953. * @param data contains the texture data
  102954. * @param texture defines the BabylonJS internal texture
  102955. * @param callback defines the method to call once ready to upload
  102956. */
  102957. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102958. }
  102959. }
  102960. declare module BABYLON {
  102961. /** @hidden */
  102962. export var rgbdEncodePixelShader: {
  102963. name: string;
  102964. shader: string;
  102965. };
  102966. }
  102967. declare module BABYLON {
  102968. /** @hidden */
  102969. export var rgbdDecodePixelShader: {
  102970. name: string;
  102971. shader: string;
  102972. };
  102973. }
  102974. declare module BABYLON {
  102975. /**
  102976. * Raw texture data and descriptor sufficient for WebGL texture upload
  102977. */
  102978. export interface EnvironmentTextureInfo {
  102979. /**
  102980. * Version of the environment map
  102981. */
  102982. version: number;
  102983. /**
  102984. * Width of image
  102985. */
  102986. width: number;
  102987. /**
  102988. * Irradiance information stored in the file.
  102989. */
  102990. irradiance: any;
  102991. /**
  102992. * Specular information stored in the file.
  102993. */
  102994. specular: any;
  102995. }
  102996. /**
  102997. * Sets of helpers addressing the serialization and deserialization of environment texture
  102998. * stored in a BabylonJS env file.
  102999. * Those files are usually stored as .env files.
  103000. */
  103001. export class EnvironmentTextureTools {
  103002. /**
  103003. * Magic number identifying the env file.
  103004. */
  103005. private static _MagicBytes;
  103006. /**
  103007. * Gets the environment info from an env file.
  103008. * @param data The array buffer containing the .env bytes.
  103009. * @returns the environment file info (the json header) if successfully parsed.
  103010. */
  103011. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103012. /**
  103013. * Creates an environment texture from a loaded cube texture.
  103014. * @param texture defines the cube texture to convert in env file
  103015. * @return a promise containing the environment data if succesfull.
  103016. */
  103017. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103018. /**
  103019. * Creates a JSON representation of the spherical data.
  103020. * @param texture defines the texture containing the polynomials
  103021. * @return the JSON representation of the spherical info
  103022. */
  103023. private static _CreateEnvTextureIrradiance;
  103024. /**
  103025. * Uploads the texture info contained in the env file to the GPU.
  103026. * @param texture defines the internal texture to upload to
  103027. * @param arrayBuffer defines the buffer cotaining the data to load
  103028. * @param info defines the texture info retrieved through the GetEnvInfo method
  103029. * @returns a promise
  103030. */
  103031. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103032. /**
  103033. * Uploads the levels of image data to the GPU.
  103034. * @param texture defines the internal texture to upload to
  103035. * @param imageData defines the array buffer views of image data [mipmap][face]
  103036. * @returns a promise
  103037. */
  103038. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103039. /**
  103040. * Uploads spherical polynomials information to the texture.
  103041. * @param texture defines the texture we are trying to upload the information to
  103042. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103043. */
  103044. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103045. /** @hidden */
  103046. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103047. }
  103048. }
  103049. declare module BABYLON {
  103050. /**
  103051. * Implementation of the ENV Texture Loader.
  103052. * @hidden
  103053. */
  103054. export class _ENVTextureLoader implements IInternalTextureLoader {
  103055. /**
  103056. * Defines wether the loader supports cascade loading the different faces.
  103057. */
  103058. readonly supportCascades: boolean;
  103059. /**
  103060. * This returns if the loader support the current file information.
  103061. * @param extension defines the file extension of the file being loaded
  103062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103063. * @param fallback defines the fallback internal texture if any
  103064. * @param isBase64 defines whether the texture is encoded as a base64
  103065. * @param isBuffer defines whether the texture data are stored as a buffer
  103066. * @returns true if the loader can load the specified file
  103067. */
  103068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103069. /**
  103070. * Transform the url before loading if required.
  103071. * @param rootUrl the url of the texture
  103072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103073. * @returns the transformed texture
  103074. */
  103075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103076. /**
  103077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103078. * @param rootUrl the url of the texture
  103079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103080. * @returns the fallback texture
  103081. */
  103082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103083. /**
  103084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103085. * @param data contains the texture data
  103086. * @param texture defines the BabylonJS internal texture
  103087. * @param createPolynomials will be true if polynomials have been requested
  103088. * @param onLoad defines the callback to trigger once the texture is ready
  103089. * @param onError defines the callback to trigger in case of error
  103090. */
  103091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103092. /**
  103093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103094. * @param data contains the texture data
  103095. * @param texture defines the BabylonJS internal texture
  103096. * @param callback defines the method to call once ready to upload
  103097. */
  103098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103099. }
  103100. }
  103101. declare module BABYLON {
  103102. /**
  103103. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103104. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103105. */
  103106. export class KhronosTextureContainer {
  103107. /** contents of the KTX container file */
  103108. arrayBuffer: any;
  103109. private static HEADER_LEN;
  103110. private static COMPRESSED_2D;
  103111. private static COMPRESSED_3D;
  103112. private static TEX_2D;
  103113. private static TEX_3D;
  103114. /**
  103115. * Gets the openGL type
  103116. */
  103117. glType: number;
  103118. /**
  103119. * Gets the openGL type size
  103120. */
  103121. glTypeSize: number;
  103122. /**
  103123. * Gets the openGL format
  103124. */
  103125. glFormat: number;
  103126. /**
  103127. * Gets the openGL internal format
  103128. */
  103129. glInternalFormat: number;
  103130. /**
  103131. * Gets the base internal format
  103132. */
  103133. glBaseInternalFormat: number;
  103134. /**
  103135. * Gets image width in pixel
  103136. */
  103137. pixelWidth: number;
  103138. /**
  103139. * Gets image height in pixel
  103140. */
  103141. pixelHeight: number;
  103142. /**
  103143. * Gets image depth in pixels
  103144. */
  103145. pixelDepth: number;
  103146. /**
  103147. * Gets the number of array elements
  103148. */
  103149. numberOfArrayElements: number;
  103150. /**
  103151. * Gets the number of faces
  103152. */
  103153. numberOfFaces: number;
  103154. /**
  103155. * Gets the number of mipmap levels
  103156. */
  103157. numberOfMipmapLevels: number;
  103158. /**
  103159. * Gets the bytes of key value data
  103160. */
  103161. bytesOfKeyValueData: number;
  103162. /**
  103163. * Gets the load type
  103164. */
  103165. loadType: number;
  103166. /**
  103167. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103168. */
  103169. isInvalid: boolean;
  103170. /**
  103171. * Creates a new KhronosTextureContainer
  103172. * @param arrayBuffer contents of the KTX container file
  103173. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103174. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103175. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103176. */
  103177. constructor(
  103178. /** contents of the KTX container file */
  103179. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103180. /**
  103181. * Uploads KTX content to a Babylon Texture.
  103182. * It is assumed that the texture has already been created & is currently bound
  103183. * @hidden
  103184. */
  103185. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103186. private _upload2DCompressedLevels;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Implementation of the KTX Texture Loader.
  103192. * @hidden
  103193. */
  103194. export class _KTXTextureLoader implements IInternalTextureLoader {
  103195. /**
  103196. * Defines wether the loader supports cascade loading the different faces.
  103197. */
  103198. readonly supportCascades: boolean;
  103199. /**
  103200. * This returns if the loader support the current file information.
  103201. * @param extension defines the file extension of the file being loaded
  103202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103203. * @param fallback defines the fallback internal texture if any
  103204. * @param isBase64 defines whether the texture is encoded as a base64
  103205. * @param isBuffer defines whether the texture data are stored as a buffer
  103206. * @returns true if the loader can load the specified file
  103207. */
  103208. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103209. /**
  103210. * Transform the url before loading if required.
  103211. * @param rootUrl the url of the texture
  103212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103213. * @returns the transformed texture
  103214. */
  103215. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103216. /**
  103217. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103218. * @param rootUrl the url of the texture
  103219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103220. * @returns the fallback texture
  103221. */
  103222. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103223. /**
  103224. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103225. * @param data contains the texture data
  103226. * @param texture defines the BabylonJS internal texture
  103227. * @param createPolynomials will be true if polynomials have been requested
  103228. * @param onLoad defines the callback to trigger once the texture is ready
  103229. * @param onError defines the callback to trigger in case of error
  103230. */
  103231. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103232. /**
  103233. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103234. * @param data contains the texture data
  103235. * @param texture defines the BabylonJS internal texture
  103236. * @param callback defines the method to call once ready to upload
  103237. */
  103238. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103239. }
  103240. }
  103241. declare module BABYLON {
  103242. /**
  103243. * Based on jsTGALoader - Javascript loader for TGA file
  103244. * By Vincent Thibault
  103245. * @see http://blog.robrowser.com/javascript-tga-loader.html
  103246. */
  103247. export class TGATools {
  103248. private static _TYPE_INDEXED;
  103249. private static _TYPE_RGB;
  103250. private static _TYPE_GREY;
  103251. private static _TYPE_RLE_INDEXED;
  103252. private static _TYPE_RLE_RGB;
  103253. private static _TYPE_RLE_GREY;
  103254. private static _ORIGIN_MASK;
  103255. private static _ORIGIN_SHIFT;
  103256. private static _ORIGIN_BL;
  103257. private static _ORIGIN_BR;
  103258. private static _ORIGIN_UL;
  103259. private static _ORIGIN_UR;
  103260. /**
  103261. * Gets the header of a TGA file
  103262. * @param data defines the TGA data
  103263. * @returns the header
  103264. */
  103265. static GetTGAHeader(data: Uint8Array): any;
  103266. /**
  103267. * Uploads TGA content to a Babylon Texture
  103268. * @hidden
  103269. */
  103270. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  103271. /** @hidden */
  103272. 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;
  103273. /** @hidden */
  103274. 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;
  103275. /** @hidden */
  103276. 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;
  103277. /** @hidden */
  103278. 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;
  103279. /** @hidden */
  103280. 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;
  103281. /** @hidden */
  103282. 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;
  103283. }
  103284. }
  103285. declare module BABYLON {
  103286. /**
  103287. * Implementation of the TGA Texture Loader.
  103288. * @hidden
  103289. */
  103290. export class _TGATextureLoader implements IInternalTextureLoader {
  103291. /**
  103292. * Defines wether the loader supports cascade loading the different faces.
  103293. */
  103294. readonly supportCascades: boolean;
  103295. /**
  103296. * This returns if the loader support the current file information.
  103297. * @param extension defines the file extension of the file being loaded
  103298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103299. * @param fallback defines the fallback internal texture if any
  103300. * @param isBase64 defines whether the texture is encoded as a base64
  103301. * @param isBuffer defines whether the texture data are stored as a buffer
  103302. * @returns true if the loader can load the specified file
  103303. */
  103304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103305. /**
  103306. * Transform the url before loading if required.
  103307. * @param rootUrl the url of the texture
  103308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103309. * @returns the transformed texture
  103310. */
  103311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103312. /**
  103313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103314. * @param rootUrl the url of the texture
  103315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103316. * @returns the fallback texture
  103317. */
  103318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103319. /**
  103320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103321. * @param data contains the texture data
  103322. * @param texture defines the BabylonJS internal texture
  103323. * @param createPolynomials will be true if polynomials have been requested
  103324. * @param onLoad defines the callback to trigger once the texture is ready
  103325. * @param onError defines the callback to trigger in case of error
  103326. */
  103327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103328. /**
  103329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103330. * @param data contains the texture data
  103331. * @param texture defines the BabylonJS internal texture
  103332. * @param callback defines the method to call once ready to upload
  103333. */
  103334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * 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.
  103340. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103341. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103342. */
  103343. export class CustomProceduralTexture extends ProceduralTexture {
  103344. private _animate;
  103345. private _time;
  103346. private _config;
  103347. private _texturePath;
  103348. /**
  103349. * Instantiates a new Custom Procedural Texture.
  103350. * 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.
  103351. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103352. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103353. * @param name Define the name of the texture
  103354. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  103355. * @param size Define the size of the texture to create
  103356. * @param scene Define the scene the texture belongs to
  103357. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  103358. * @param generateMipMaps Define if the texture should creates mip maps or not
  103359. */
  103360. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103361. private _loadJson;
  103362. /**
  103363. * Is the texture ready to be used ? (rendered at least once)
  103364. * @returns true if ready, otherwise, false.
  103365. */
  103366. isReady(): boolean;
  103367. /**
  103368. * Render the texture to its associated render target.
  103369. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  103370. */
  103371. render(useCameraPostProcess?: boolean): void;
  103372. /**
  103373. * Update the list of dependant textures samplers in the shader.
  103374. */
  103375. updateTextures(): void;
  103376. /**
  103377. * Update the uniform values of the procedural texture in the shader.
  103378. */
  103379. updateShaderUniforms(): void;
  103380. /**
  103381. * Define if the texture animates or not.
  103382. */
  103383. animate: boolean;
  103384. }
  103385. }
  103386. declare module BABYLON {
  103387. /** @hidden */
  103388. export var noisePixelShader: {
  103389. name: string;
  103390. shader: string;
  103391. };
  103392. }
  103393. declare module BABYLON {
  103394. /**
  103395. * Class used to generate noise procedural textures
  103396. */
  103397. export class NoiseProceduralTexture extends ProceduralTexture {
  103398. private _time;
  103399. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  103400. brightness: number;
  103401. /** Defines the number of octaves to process */
  103402. octaves: number;
  103403. /** Defines the level of persistence (0.8 by default) */
  103404. persistence: number;
  103405. /** Gets or sets animation speed factor (default is 1) */
  103406. animationSpeedFactor: number;
  103407. /**
  103408. * Creates a new NoiseProceduralTexture
  103409. * @param name defines the name fo the texture
  103410. * @param size defines the size of the texture (default is 256)
  103411. * @param scene defines the hosting scene
  103412. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  103413. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  103414. */
  103415. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103416. private _updateShaderUniforms;
  103417. protected _getDefines(): string;
  103418. /** Generate the current state of the procedural texture */
  103419. render(useCameraPostProcess?: boolean): void;
  103420. /**
  103421. * Serializes this noise procedural texture
  103422. * @returns a serialized noise procedural texture object
  103423. */
  103424. serialize(): any;
  103425. /**
  103426. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  103427. * @param parsedTexture defines parsed texture data
  103428. * @param scene defines the current scene
  103429. * @param rootUrl defines the root URL containing noise procedural texture information
  103430. * @returns a parsed NoiseProceduralTexture
  103431. */
  103432. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  103433. }
  103434. }
  103435. declare module BABYLON {
  103436. /**
  103437. * Raw cube texture where the raw buffers are passed in
  103438. */
  103439. export class RawCubeTexture extends CubeTexture {
  103440. /**
  103441. * Creates a cube texture where the raw buffers are passed in.
  103442. * @param scene defines the scene the texture is attached to
  103443. * @param data defines the array of data to use to create each face
  103444. * @param size defines the size of the textures
  103445. * @param format defines the format of the data
  103446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  103447. * @param generateMipMaps defines if the engine should generate the mip levels
  103448. * @param invertY defines if data must be stored with Y axis inverted
  103449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  103450. * @param compression defines the compression used (null by default)
  103451. */
  103452. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  103453. /**
  103454. * Updates the raw cube texture.
  103455. * @param data defines the data to store
  103456. * @param format defines the data format
  103457. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  103458. * @param invertY defines if data must be stored with Y axis inverted
  103459. * @param compression defines the compression used (null by default)
  103460. * @param level defines which level of the texture to update
  103461. */
  103462. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  103463. /**
  103464. * Updates a raw cube texture with RGBD encoded data.
  103465. * @param data defines the array of data [mipmap][face] to use to create each face
  103466. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  103467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  103468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  103469. * @returns a promsie that resolves when the operation is complete
  103470. */
  103471. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  103472. /**
  103473. * Clones the raw cube texture.
  103474. * @return a new cube texture
  103475. */
  103476. clone(): CubeTexture;
  103477. /** @hidden */
  103478. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103479. }
  103480. }
  103481. declare module BABYLON {
  103482. /**
  103483. * Class used to store 3D textures containing user data
  103484. */
  103485. export class RawTexture3D extends Texture {
  103486. /** Gets or sets the texture format to use */
  103487. format: number;
  103488. private _engine;
  103489. /**
  103490. * Create a new RawTexture3D
  103491. * @param data defines the data of the texture
  103492. * @param width defines the width of the texture
  103493. * @param height defines the height of the texture
  103494. * @param depth defines the depth of the texture
  103495. * @param format defines the texture format to use
  103496. * @param scene defines the hosting scene
  103497. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  103498. * @param invertY defines if texture must be stored with Y axis inverted
  103499. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  103500. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  103501. */
  103502. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  103503. /** Gets or sets the texture format to use */
  103504. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  103505. /**
  103506. * Update the texture with new data
  103507. * @param data defines the data to store in the texture
  103508. */
  103509. update(data: ArrayBufferView): void;
  103510. }
  103511. }
  103512. declare module BABYLON {
  103513. /**
  103514. * Creates a refraction texture used by refraction channel of the standard material.
  103515. * It is like a mirror but to see through a material.
  103516. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103517. */
  103518. export class RefractionTexture extends RenderTargetTexture {
  103519. /**
  103520. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  103521. * 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.
  103522. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103523. */
  103524. refractionPlane: Plane;
  103525. /**
  103526. * Define how deep under the surface we should see.
  103527. */
  103528. depth: number;
  103529. /**
  103530. * Creates a refraction texture used by refraction channel of the standard material.
  103531. * It is like a mirror but to see through a material.
  103532. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103533. * @param name Define the texture name
  103534. * @param size Define the size of the underlying texture
  103535. * @param scene Define the scene the refraction belongs to
  103536. * @param generateMipMaps Define if we need to generate mips level for the refraction
  103537. */
  103538. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  103539. /**
  103540. * Clone the refraction texture.
  103541. * @returns the cloned texture
  103542. */
  103543. clone(): RefractionTexture;
  103544. /**
  103545. * Serialize the texture to a JSON representation you could use in Parse later on
  103546. * @returns the serialized JSON representation
  103547. */
  103548. serialize(): any;
  103549. }
  103550. }
  103551. declare module BABYLON {
  103552. /**
  103553. * Configuration for Draco compression
  103554. */
  103555. export interface IDracoCompressionConfiguration {
  103556. /**
  103557. * Configuration for the decoder.
  103558. */
  103559. decoder?: {
  103560. /**
  103561. * The url to the WebAssembly module.
  103562. */
  103563. wasmUrl?: string;
  103564. /**
  103565. * The url to the WebAssembly binary.
  103566. */
  103567. wasmBinaryUrl?: string;
  103568. /**
  103569. * The url to the fallback JavaScript module.
  103570. */
  103571. fallbackUrl?: string;
  103572. };
  103573. }
  103574. /**
  103575. * Draco compression (https://google.github.io/draco/)
  103576. *
  103577. * This class wraps the Draco module.
  103578. *
  103579. * **Encoder**
  103580. *
  103581. * The encoder is not currently implemented.
  103582. *
  103583. * **Decoder**
  103584. *
  103585. * 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.
  103586. *
  103587. * To update the configuration, use the following code:
  103588. * ```javascript
  103589. * DracoCompression.Configuration = {
  103590. * decoder: {
  103591. * wasmUrl: "<url to the WebAssembly library>",
  103592. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103593. * fallbackUrl: "<url to the fallback JavaScript library>",
  103594. * }
  103595. * };
  103596. * ```
  103597. *
  103598. * 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.
  103599. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103600. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103601. *
  103602. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103603. * ```javascript
  103604. * var dracoCompression = new DracoCompression();
  103605. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103606. * [VertexBuffer.PositionKind]: 0
  103607. * });
  103608. * ```
  103609. *
  103610. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103611. */
  103612. export class DracoCompression implements IDisposable {
  103613. private static _DecoderModulePromise;
  103614. /**
  103615. * The configuration. Defaults to the following urls:
  103616. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103617. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103618. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103619. */
  103620. static Configuration: IDracoCompressionConfiguration;
  103621. /**
  103622. * Returns true if the decoder is available.
  103623. */
  103624. static readonly DecoderAvailable: boolean;
  103625. /**
  103626. * Constructor
  103627. */
  103628. constructor();
  103629. /**
  103630. * Stop all async operations and release resources.
  103631. */
  103632. dispose(): void;
  103633. /**
  103634. * Decode Draco compressed mesh data to vertex data.
  103635. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103636. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103637. * @returns A promise that resolves with the decoded vertex data
  103638. */
  103639. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103640. [kind: string]: number;
  103641. }): Promise<VertexData>;
  103642. private static _GetDecoderModule;
  103643. private static _LoadScriptAsync;
  103644. private static _LoadFileAsync;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * Class for building Constructive Solid Geometry
  103650. */
  103651. export class CSG {
  103652. private polygons;
  103653. /**
  103654. * The world matrix
  103655. */
  103656. matrix: Matrix;
  103657. /**
  103658. * Stores the position
  103659. */
  103660. position: Vector3;
  103661. /**
  103662. * Stores the rotation
  103663. */
  103664. rotation: Vector3;
  103665. /**
  103666. * Stores the rotation quaternion
  103667. */
  103668. rotationQuaternion: Nullable<Quaternion>;
  103669. /**
  103670. * Stores the scaling vector
  103671. */
  103672. scaling: Vector3;
  103673. /**
  103674. * Convert the Mesh to CSG
  103675. * @param mesh The Mesh to convert to CSG
  103676. * @returns A new CSG from the Mesh
  103677. */
  103678. static FromMesh(mesh: Mesh): CSG;
  103679. /**
  103680. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103681. * @param polygons Polygons used to construct a CSG solid
  103682. */
  103683. private static FromPolygons;
  103684. /**
  103685. * Clones, or makes a deep copy, of the CSG
  103686. * @returns A new CSG
  103687. */
  103688. clone(): CSG;
  103689. /**
  103690. * Unions this CSG with another CSG
  103691. * @param csg The CSG to union against this CSG
  103692. * @returns The unioned CSG
  103693. */
  103694. union(csg: CSG): CSG;
  103695. /**
  103696. * Unions this CSG with another CSG in place
  103697. * @param csg The CSG to union against this CSG
  103698. */
  103699. unionInPlace(csg: CSG): void;
  103700. /**
  103701. * Subtracts this CSG with another CSG
  103702. * @param csg The CSG to subtract against this CSG
  103703. * @returns A new CSG
  103704. */
  103705. subtract(csg: CSG): CSG;
  103706. /**
  103707. * Subtracts this CSG with another CSG in place
  103708. * @param csg The CSG to subtact against this CSG
  103709. */
  103710. subtractInPlace(csg: CSG): void;
  103711. /**
  103712. * Intersect this CSG with another CSG
  103713. * @param csg The CSG to intersect against this CSG
  103714. * @returns A new CSG
  103715. */
  103716. intersect(csg: CSG): CSG;
  103717. /**
  103718. * Intersects this CSG with another CSG in place
  103719. * @param csg The CSG to intersect against this CSG
  103720. */
  103721. intersectInPlace(csg: CSG): void;
  103722. /**
  103723. * Return a new CSG solid with solid and empty space switched. This solid is
  103724. * not modified.
  103725. * @returns A new CSG solid with solid and empty space switched
  103726. */
  103727. inverse(): CSG;
  103728. /**
  103729. * Inverses the CSG in place
  103730. */
  103731. inverseInPlace(): void;
  103732. /**
  103733. * This is used to keep meshes transformations so they can be restored
  103734. * when we build back a Babylon Mesh
  103735. * NB : All CSG operations are performed in world coordinates
  103736. * @param csg The CSG to copy the transform attributes from
  103737. * @returns This CSG
  103738. */
  103739. copyTransformAttributes(csg: CSG): CSG;
  103740. /**
  103741. * Build Raw mesh from CSG
  103742. * Coordinates here are in world space
  103743. * @param name The name of the mesh geometry
  103744. * @param scene The Scene
  103745. * @param keepSubMeshes Specifies if the submeshes should be kept
  103746. * @returns A new Mesh
  103747. */
  103748. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103749. /**
  103750. * Build Mesh from CSG taking material and transforms into account
  103751. * @param name The name of the Mesh
  103752. * @param material The material of the Mesh
  103753. * @param scene The Scene
  103754. * @param keepSubMeshes Specifies if submeshes should be kept
  103755. * @returns The new Mesh
  103756. */
  103757. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103758. }
  103759. }
  103760. declare module BABYLON {
  103761. /**
  103762. * Class containing static functions to help procedurally build meshes
  103763. */
  103764. export class RibbonBuilder {
  103765. /**
  103766. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103767. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103768. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103769. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103770. * * 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
  103771. * * 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
  103772. * * 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
  103773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103776. * * 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
  103777. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103778. * * 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
  103779. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103781. * @param name defines the name of the mesh
  103782. * @param options defines the options used to create the mesh
  103783. * @param scene defines the hosting scene
  103784. * @returns the ribbon mesh
  103785. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103786. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103787. */
  103788. static CreateRibbon(name: string, options: {
  103789. pathArray: Vector3[][];
  103790. closeArray?: boolean;
  103791. closePath?: boolean;
  103792. offset?: number;
  103793. updatable?: boolean;
  103794. sideOrientation?: number;
  103795. frontUVs?: Vector4;
  103796. backUVs?: Vector4;
  103797. instance?: Mesh;
  103798. invertUV?: boolean;
  103799. uvs?: Vector2[];
  103800. colors?: Color4[];
  103801. }, scene?: Nullable<Scene>): Mesh;
  103802. }
  103803. }
  103804. declare module BABYLON {
  103805. /**
  103806. * Class containing static functions to help procedurally build meshes
  103807. */
  103808. export class TorusKnotBuilder {
  103809. /**
  103810. * Creates a torus knot mesh
  103811. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103812. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103813. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103814. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103818. * @param name defines the name of the mesh
  103819. * @param options defines the options used to create the mesh
  103820. * @param scene defines the hosting scene
  103821. * @returns the torus knot mesh
  103822. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103823. */
  103824. static CreateTorusKnot(name: string, options: {
  103825. radius?: number;
  103826. tube?: number;
  103827. radialSegments?: number;
  103828. tubularSegments?: number;
  103829. p?: number;
  103830. q?: number;
  103831. updatable?: boolean;
  103832. sideOrientation?: number;
  103833. frontUVs?: Vector4;
  103834. backUVs?: Vector4;
  103835. }, scene: any): Mesh;
  103836. }
  103837. }
  103838. declare module BABYLON {
  103839. /**
  103840. * Polygon
  103841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103842. */
  103843. export class Polygon {
  103844. /**
  103845. * Creates a rectangle
  103846. * @param xmin bottom X coord
  103847. * @param ymin bottom Y coord
  103848. * @param xmax top X coord
  103849. * @param ymax top Y coord
  103850. * @returns points that make the resulting rectation
  103851. */
  103852. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103853. /**
  103854. * Creates a circle
  103855. * @param radius radius of circle
  103856. * @param cx scale in x
  103857. * @param cy scale in y
  103858. * @param numberOfSides number of sides that make up the circle
  103859. * @returns points that make the resulting circle
  103860. */
  103861. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103862. /**
  103863. * Creates a polygon from input string
  103864. * @param input Input polygon data
  103865. * @returns the parsed points
  103866. */
  103867. static Parse(input: string): Vector2[];
  103868. /**
  103869. * Starts building a polygon from x and y coordinates
  103870. * @param x x coordinate
  103871. * @param y y coordinate
  103872. * @returns the started path2
  103873. */
  103874. static StartingAt(x: number, y: number): Path2;
  103875. }
  103876. /**
  103877. * Builds a polygon
  103878. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103879. */
  103880. export class PolygonMeshBuilder {
  103881. private _points;
  103882. private _outlinepoints;
  103883. private _holes;
  103884. private _name;
  103885. private _scene;
  103886. private _epoints;
  103887. private _eholes;
  103888. private _addToepoint;
  103889. /**
  103890. * Babylon reference to the earcut plugin.
  103891. */
  103892. bjsEarcut: any;
  103893. /**
  103894. * Creates a PolygonMeshBuilder
  103895. * @param name name of the builder
  103896. * @param contours Path of the polygon
  103897. * @param scene scene to add to
  103898. * @param earcutInjection can be used to inject your own earcut reference
  103899. */
  103900. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103901. /**
  103902. * Adds a whole within the polygon
  103903. * @param hole Array of points defining the hole
  103904. * @returns this
  103905. */
  103906. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103907. /**
  103908. * Creates the polygon
  103909. * @param updatable If the mesh should be updatable
  103910. * @param depth The depth of the mesh created
  103911. * @returns the created mesh
  103912. */
  103913. build(updatable?: boolean, depth?: number): Mesh;
  103914. /**
  103915. * Adds a side to the polygon
  103916. * @param positions points that make the polygon
  103917. * @param normals normals of the polygon
  103918. * @param uvs uvs of the polygon
  103919. * @param indices indices of the polygon
  103920. * @param bounds bounds of the polygon
  103921. * @param points points of the polygon
  103922. * @param depth depth of the polygon
  103923. * @param flip flip of the polygon
  103924. */
  103925. private addSide;
  103926. }
  103927. }
  103928. declare module BABYLON {
  103929. /**
  103930. * Class containing static functions to help procedurally build meshes
  103931. */
  103932. export class PolygonBuilder {
  103933. /**
  103934. * Creates a polygon mesh
  103935. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103936. * * 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
  103937. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103940. * * Remember you can only change the shape positions, not their number when updating a polygon
  103941. * @param name defines the name of the mesh
  103942. * @param options defines the options used to create the mesh
  103943. * @param scene defines the hosting scene
  103944. * @param earcutInjection can be used to inject your own earcut reference
  103945. * @returns the polygon mesh
  103946. */
  103947. static CreatePolygon(name: string, options: {
  103948. shape: Vector3[];
  103949. holes?: Vector3[][];
  103950. depth?: number;
  103951. faceUV?: Vector4[];
  103952. faceColors?: Color4[];
  103953. updatable?: boolean;
  103954. sideOrientation?: number;
  103955. frontUVs?: Vector4;
  103956. backUVs?: Vector4;
  103957. }, scene: Scene, earcutInjection?: any): Mesh;
  103958. /**
  103959. * Creates an extruded polygon mesh, with depth in the Y direction.
  103960. * * 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)
  103961. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103962. * @param name defines the name of the mesh
  103963. * @param options defines the options used to create the mesh
  103964. * @param scene defines the hosting scene
  103965. * @param earcutInjection can be used to inject your own earcut reference
  103966. * @returns the polygon mesh
  103967. */
  103968. static ExtrudePolygon(name: string, options: {
  103969. shape: Vector3[];
  103970. holes?: Vector3[][];
  103971. depth?: number;
  103972. faceUV?: Vector4[];
  103973. faceColors?: Color4[];
  103974. updatable?: boolean;
  103975. sideOrientation?: number;
  103976. frontUVs?: Vector4;
  103977. backUVs?: Vector4;
  103978. }, scene: Scene, earcutInjection?: any): Mesh;
  103979. }
  103980. }
  103981. declare module BABYLON {
  103982. /**
  103983. * Class containing static functions to help procedurally build meshes
  103984. */
  103985. export class ShapeBuilder {
  103986. /**
  103987. * 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.
  103988. * * 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.
  103989. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103990. * * 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.
  103991. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103992. * * 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
  103993. * * 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
  103994. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103999. * @param name defines the name of the mesh
  104000. * @param options defines the options used to create the mesh
  104001. * @param scene defines the hosting scene
  104002. * @returns the extruded shape mesh
  104003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104005. */
  104006. static ExtrudeShape(name: string, options: {
  104007. shape: Vector3[];
  104008. path: Vector3[];
  104009. scale?: number;
  104010. rotation?: number;
  104011. cap?: number;
  104012. updatable?: boolean;
  104013. sideOrientation?: number;
  104014. frontUVs?: Vector4;
  104015. backUVs?: Vector4;
  104016. instance?: Mesh;
  104017. invertUV?: boolean;
  104018. }, scene?: Nullable<Scene>): Mesh;
  104019. /**
  104020. * Creates an custom extruded shape mesh.
  104021. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104022. * * 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.
  104023. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104024. * * 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
  104025. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104026. * * 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
  104027. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104028. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104029. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104030. * * 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
  104031. * * 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
  104032. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104037. * @param name defines the name of the mesh
  104038. * @param options defines the options used to create the mesh
  104039. * @param scene defines the hosting scene
  104040. * @returns the custom extruded shape mesh
  104041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104044. */
  104045. static ExtrudeShapeCustom(name: string, options: {
  104046. shape: Vector3[];
  104047. path: Vector3[];
  104048. scaleFunction?: any;
  104049. rotationFunction?: any;
  104050. ribbonCloseArray?: boolean;
  104051. ribbonClosePath?: boolean;
  104052. cap?: number;
  104053. updatable?: boolean;
  104054. sideOrientation?: number;
  104055. frontUVs?: Vector4;
  104056. backUVs?: Vector4;
  104057. instance?: Mesh;
  104058. invertUV?: boolean;
  104059. }, scene: Scene): Mesh;
  104060. private static _ExtrudeShapeGeneric;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. /**
  104065. * Class containing static functions to help procedurally build meshes
  104066. */
  104067. export class LatheBuilder {
  104068. /**
  104069. * Creates lathe mesh.
  104070. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104071. * * 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
  104072. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104073. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104074. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104075. * * 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
  104076. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104077. * * 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
  104078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104082. * @param name defines the name of the mesh
  104083. * @param options defines the options used to create the mesh
  104084. * @param scene defines the hosting scene
  104085. * @returns the lathe mesh
  104086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104087. */
  104088. static CreateLathe(name: string, options: {
  104089. shape: Vector3[];
  104090. radius?: number;
  104091. tessellation?: number;
  104092. clip?: number;
  104093. arc?: number;
  104094. closed?: boolean;
  104095. updatable?: boolean;
  104096. sideOrientation?: number;
  104097. frontUVs?: Vector4;
  104098. backUVs?: Vector4;
  104099. cap?: number;
  104100. invertUV?: boolean;
  104101. }, scene: Scene): Mesh;
  104102. }
  104103. }
  104104. declare module BABYLON {
  104105. /**
  104106. * Class containing static functions to help procedurally build meshes
  104107. */
  104108. export class TubeBuilder {
  104109. /**
  104110. * Creates a tube mesh.
  104111. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104112. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104113. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104114. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104115. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104116. * * 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)
  104117. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104118. * * 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
  104119. * * 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
  104120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104124. * @param name defines the name of the mesh
  104125. * @param options defines the options used to create the mesh
  104126. * @param scene defines the hosting scene
  104127. * @returns the tube mesh
  104128. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104129. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104130. */
  104131. static CreateTube(name: string, options: {
  104132. path: Vector3[];
  104133. radius?: number;
  104134. tessellation?: number;
  104135. radiusFunction?: {
  104136. (i: number, distance: number): number;
  104137. };
  104138. cap?: number;
  104139. arc?: number;
  104140. updatable?: boolean;
  104141. sideOrientation?: number;
  104142. frontUVs?: Vector4;
  104143. backUVs?: Vector4;
  104144. instance?: Mesh;
  104145. invertUV?: boolean;
  104146. }, scene: Scene): Mesh;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. /**
  104151. * Class containing static functions to help procedurally build meshes
  104152. */
  104153. export class IcoSphereBuilder {
  104154. /**
  104155. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104156. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104157. * * 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`)
  104158. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104159. * * 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
  104160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104163. * @param name defines the name of the mesh
  104164. * @param options defines the options used to create the mesh
  104165. * @param scene defines the hosting scene
  104166. * @returns the icosahedron mesh
  104167. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104168. */
  104169. static CreateIcoSphere(name: string, options: {
  104170. radius?: number;
  104171. radiusX?: number;
  104172. radiusY?: number;
  104173. radiusZ?: number;
  104174. flat?: boolean;
  104175. subdivisions?: number;
  104176. sideOrientation?: number;
  104177. frontUVs?: Vector4;
  104178. backUVs?: Vector4;
  104179. updatable?: boolean;
  104180. }, scene: Scene): Mesh;
  104181. }
  104182. }
  104183. declare module BABYLON {
  104184. /**
  104185. * Class containing static functions to help procedurally build meshes
  104186. */
  104187. export class DecalBuilder {
  104188. /**
  104189. * Creates a decal mesh.
  104190. * 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
  104191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104195. * @param name defines the name of the mesh
  104196. * @param sourceMesh defines the mesh where the decal must be applied
  104197. * @param options defines the options used to create the mesh
  104198. * @param scene defines the hosting scene
  104199. * @returns the decal mesh
  104200. * @see https://doc.babylonjs.com/how_to/decals
  104201. */
  104202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104203. position?: Vector3;
  104204. normal?: Vector3;
  104205. size?: Vector3;
  104206. angle?: number;
  104207. }): Mesh;
  104208. }
  104209. }
  104210. declare module BABYLON {
  104211. /**
  104212. * Class containing static functions to help procedurally build meshes
  104213. */
  104214. export class MeshBuilder {
  104215. /**
  104216. * Creates a box mesh
  104217. * * The parameter `size` sets the size (float) of each box side (default 1)
  104218. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104219. * * 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)
  104220. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104224. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104225. * @param name defines the name of the mesh
  104226. * @param options defines the options used to create the mesh
  104227. * @param scene defines the hosting scene
  104228. * @returns the box mesh
  104229. */
  104230. static CreateBox(name: string, options: {
  104231. size?: number;
  104232. width?: number;
  104233. height?: number;
  104234. depth?: number;
  104235. faceUV?: Vector4[];
  104236. faceColors?: Color4[];
  104237. sideOrientation?: number;
  104238. frontUVs?: Vector4;
  104239. backUVs?: Vector4;
  104240. updatable?: boolean;
  104241. }, scene?: Nullable<Scene>): Mesh;
  104242. /**
  104243. * Creates a sphere mesh
  104244. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104245. * * 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`)
  104246. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104247. * * 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
  104248. * * 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)
  104249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104252. * @param name defines the name of the mesh
  104253. * @param options defines the options used to create the mesh
  104254. * @param scene defines the hosting scene
  104255. * @returns the sphere mesh
  104256. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104257. */
  104258. static CreateSphere(name: string, options: {
  104259. segments?: number;
  104260. diameter?: number;
  104261. diameterX?: number;
  104262. diameterY?: number;
  104263. diameterZ?: number;
  104264. arc?: number;
  104265. slice?: number;
  104266. sideOrientation?: number;
  104267. frontUVs?: Vector4;
  104268. backUVs?: Vector4;
  104269. updatable?: boolean;
  104270. }, scene: any): Mesh;
  104271. /**
  104272. * Creates a plane polygonal mesh. By default, this is a disc
  104273. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  104274. * * 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
  104275. * * 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
  104276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104279. * @param name defines the name of the mesh
  104280. * @param options defines the options used to create the mesh
  104281. * @param scene defines the hosting scene
  104282. * @returns the plane polygonal mesh
  104283. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  104284. */
  104285. static CreateDisc(name: string, options: {
  104286. radius?: number;
  104287. tessellation?: number;
  104288. arc?: number;
  104289. updatable?: boolean;
  104290. sideOrientation?: number;
  104291. frontUVs?: Vector4;
  104292. backUVs?: Vector4;
  104293. }, scene?: Nullable<Scene>): Mesh;
  104294. /**
  104295. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104296. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104297. * * 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`)
  104298. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104299. * * 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
  104300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104303. * @param name defines the name of the mesh
  104304. * @param options defines the options used to create the mesh
  104305. * @param scene defines the hosting scene
  104306. * @returns the icosahedron mesh
  104307. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104308. */
  104309. static CreateIcoSphere(name: string, options: {
  104310. radius?: number;
  104311. radiusX?: number;
  104312. radiusY?: number;
  104313. radiusZ?: number;
  104314. flat?: boolean;
  104315. subdivisions?: number;
  104316. sideOrientation?: number;
  104317. frontUVs?: Vector4;
  104318. backUVs?: Vector4;
  104319. updatable?: boolean;
  104320. }, scene: Scene): Mesh;
  104321. /**
  104322. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104323. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104324. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104325. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104326. * * 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
  104327. * * 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
  104328. * * 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
  104329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104332. * * 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
  104333. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104334. * * 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
  104335. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104337. * @param name defines the name of the mesh
  104338. * @param options defines the options used to create the mesh
  104339. * @param scene defines the hosting scene
  104340. * @returns the ribbon mesh
  104341. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104343. */
  104344. static CreateRibbon(name: string, options: {
  104345. pathArray: Vector3[][];
  104346. closeArray?: boolean;
  104347. closePath?: boolean;
  104348. offset?: number;
  104349. updatable?: boolean;
  104350. sideOrientation?: number;
  104351. frontUVs?: Vector4;
  104352. backUVs?: Vector4;
  104353. instance?: Mesh;
  104354. invertUV?: boolean;
  104355. uvs?: Vector2[];
  104356. colors?: Color4[];
  104357. }, scene?: Nullable<Scene>): Mesh;
  104358. /**
  104359. * Creates a cylinder or a cone mesh
  104360. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104361. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104362. * * 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.
  104363. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104364. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104365. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104366. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104367. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104368. * * 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).
  104369. * * 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
  104370. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104371. * * 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
  104372. * * 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.
  104373. * * If `enclose` is false, a ring surface is one element.
  104374. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104375. * * 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
  104376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104379. * @param name defines the name of the mesh
  104380. * @param options defines the options used to create the mesh
  104381. * @param scene defines the hosting scene
  104382. * @returns the cylinder mesh
  104383. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104384. */
  104385. static CreateCylinder(name: string, options: {
  104386. height?: number;
  104387. diameterTop?: number;
  104388. diameterBottom?: number;
  104389. diameter?: number;
  104390. tessellation?: number;
  104391. subdivisions?: number;
  104392. arc?: number;
  104393. faceColors?: Color4[];
  104394. faceUV?: Vector4[];
  104395. updatable?: boolean;
  104396. hasRings?: boolean;
  104397. enclose?: boolean;
  104398. sideOrientation?: number;
  104399. frontUVs?: Vector4;
  104400. backUVs?: Vector4;
  104401. }, scene: any): Mesh;
  104402. /**
  104403. * Creates a torus mesh
  104404. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104405. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104406. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104410. * @param name defines the name of the mesh
  104411. * @param options defines the options used to create the mesh
  104412. * @param scene defines the hosting scene
  104413. * @returns the torus mesh
  104414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104415. */
  104416. static CreateTorus(name: string, options: {
  104417. diameter?: number;
  104418. thickness?: number;
  104419. tessellation?: number;
  104420. updatable?: boolean;
  104421. sideOrientation?: number;
  104422. frontUVs?: Vector4;
  104423. backUVs?: Vector4;
  104424. }, scene: any): Mesh;
  104425. /**
  104426. * Creates a torus knot mesh
  104427. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104428. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104429. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104430. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104434. * @param name defines the name of the mesh
  104435. * @param options defines the options used to create the mesh
  104436. * @param scene defines the hosting scene
  104437. * @returns the torus knot mesh
  104438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104439. */
  104440. static CreateTorusKnot(name: string, options: {
  104441. radius?: number;
  104442. tube?: number;
  104443. radialSegments?: number;
  104444. tubularSegments?: number;
  104445. p?: number;
  104446. q?: number;
  104447. updatable?: boolean;
  104448. sideOrientation?: number;
  104449. frontUVs?: Vector4;
  104450. backUVs?: Vector4;
  104451. }, scene: any): Mesh;
  104452. /**
  104453. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104454. * * 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
  104455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104456. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104457. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104458. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104460. * * 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
  104461. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104464. * @param name defines the name of the new line system
  104465. * @param options defines the options used to create the line system
  104466. * @param scene defines the hosting scene
  104467. * @returns a new line system mesh
  104468. */
  104469. static CreateLineSystem(name: string, options: {
  104470. lines: Vector3[][];
  104471. updatable?: boolean;
  104472. instance?: Nullable<LinesMesh>;
  104473. colors?: Nullable<Color4[][]>;
  104474. useVertexAlpha?: boolean;
  104475. }, scene: Nullable<Scene>): LinesMesh;
  104476. /**
  104477. * Creates a line mesh
  104478. * 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
  104479. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104480. * * The parameter `points` is an array successive Vector3
  104481. * * 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
  104482. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104484. * * When updating an instance, remember that only point positions can change, not the number of points
  104485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104487. * @param name defines the name of the new line system
  104488. * @param options defines the options used to create the line system
  104489. * @param scene defines the hosting scene
  104490. * @returns a new line mesh
  104491. */
  104492. static CreateLines(name: string, options: {
  104493. points: Vector3[];
  104494. updatable?: boolean;
  104495. instance?: Nullable<LinesMesh>;
  104496. colors?: Color4[];
  104497. useVertexAlpha?: boolean;
  104498. }, scene?: Nullable<Scene>): LinesMesh;
  104499. /**
  104500. * Creates a dashed line mesh
  104501. * * 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
  104502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104503. * * The parameter `points` is an array successive Vector3
  104504. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104505. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104506. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104507. * * 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
  104508. * * When updating an instance, remember that only point positions can change, not the number of points
  104509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104510. * @param name defines the name of the mesh
  104511. * @param options defines the options used to create the mesh
  104512. * @param scene defines the hosting scene
  104513. * @returns the dashed line mesh
  104514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104515. */
  104516. static CreateDashedLines(name: string, options: {
  104517. points: Vector3[];
  104518. dashSize?: number;
  104519. gapSize?: number;
  104520. dashNb?: number;
  104521. updatable?: boolean;
  104522. instance?: LinesMesh;
  104523. }, scene?: Nullable<Scene>): LinesMesh;
  104524. /**
  104525. * 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.
  104526. * * 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.
  104527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104528. * * 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.
  104529. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  104530. * * 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
  104531. * * 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
  104532. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104537. * @param name defines the name of the mesh
  104538. * @param options defines the options used to create the mesh
  104539. * @param scene defines the hosting scene
  104540. * @returns the extruded shape mesh
  104541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104543. */
  104544. static ExtrudeShape(name: string, options: {
  104545. shape: Vector3[];
  104546. path: Vector3[];
  104547. scale?: number;
  104548. rotation?: number;
  104549. cap?: number;
  104550. updatable?: boolean;
  104551. sideOrientation?: number;
  104552. frontUVs?: Vector4;
  104553. backUVs?: Vector4;
  104554. instance?: Mesh;
  104555. invertUV?: boolean;
  104556. }, scene?: Nullable<Scene>): Mesh;
  104557. /**
  104558. * Creates an custom extruded shape mesh.
  104559. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104560. * * 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.
  104561. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104562. * * 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
  104563. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104564. * * 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
  104565. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104566. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104567. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104568. * * 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
  104569. * * 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
  104570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104575. * @param name defines the name of the mesh
  104576. * @param options defines the options used to create the mesh
  104577. * @param scene defines the hosting scene
  104578. * @returns the custom extruded shape mesh
  104579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104582. */
  104583. static ExtrudeShapeCustom(name: string, options: {
  104584. shape: Vector3[];
  104585. path: Vector3[];
  104586. scaleFunction?: any;
  104587. rotationFunction?: any;
  104588. ribbonCloseArray?: boolean;
  104589. ribbonClosePath?: boolean;
  104590. cap?: number;
  104591. updatable?: boolean;
  104592. sideOrientation?: number;
  104593. frontUVs?: Vector4;
  104594. backUVs?: Vector4;
  104595. instance?: Mesh;
  104596. invertUV?: boolean;
  104597. }, scene: Scene): Mesh;
  104598. /**
  104599. * Creates lathe mesh.
  104600. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104601. * * 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
  104602. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104603. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104604. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104605. * * 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
  104606. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104607. * * 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
  104608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104612. * @param name defines the name of the mesh
  104613. * @param options defines the options used to create the mesh
  104614. * @param scene defines the hosting scene
  104615. * @returns the lathe mesh
  104616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104617. */
  104618. static CreateLathe(name: string, options: {
  104619. shape: Vector3[];
  104620. radius?: number;
  104621. tessellation?: number;
  104622. clip?: number;
  104623. arc?: number;
  104624. closed?: boolean;
  104625. updatable?: boolean;
  104626. sideOrientation?: number;
  104627. frontUVs?: Vector4;
  104628. backUVs?: Vector4;
  104629. cap?: number;
  104630. invertUV?: boolean;
  104631. }, scene: Scene): Mesh;
  104632. /**
  104633. * Creates a plane mesh
  104634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104640. * @param name defines the name of the mesh
  104641. * @param options defines the options used to create the mesh
  104642. * @param scene defines the hosting scene
  104643. * @returns the plane mesh
  104644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104645. */
  104646. static CreatePlane(name: string, options: {
  104647. size?: number;
  104648. width?: number;
  104649. height?: number;
  104650. sideOrientation?: number;
  104651. frontUVs?: Vector4;
  104652. backUVs?: Vector4;
  104653. updatable?: boolean;
  104654. sourcePlane?: Plane;
  104655. }, scene: Scene): Mesh;
  104656. /**
  104657. * Creates a ground mesh
  104658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104661. * @param name defines the name of the mesh
  104662. * @param options defines the options used to create the mesh
  104663. * @param scene defines the hosting scene
  104664. * @returns the ground mesh
  104665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104666. */
  104667. static CreateGround(name: string, options: {
  104668. width?: number;
  104669. height?: number;
  104670. subdivisions?: number;
  104671. subdivisionsX?: number;
  104672. subdivisionsY?: number;
  104673. updatable?: boolean;
  104674. }, scene: any): Mesh;
  104675. /**
  104676. * Creates a tiled ground mesh
  104677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104679. * * 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
  104680. * * 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
  104681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104682. * @param name defines the name of the mesh
  104683. * @param options defines the options used to create the mesh
  104684. * @param scene defines the hosting scene
  104685. * @returns the tiled ground mesh
  104686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104687. */
  104688. static CreateTiledGround(name: string, options: {
  104689. xmin: number;
  104690. zmin: number;
  104691. xmax: number;
  104692. zmax: number;
  104693. subdivisions?: {
  104694. w: number;
  104695. h: number;
  104696. };
  104697. precision?: {
  104698. w: number;
  104699. h: number;
  104700. };
  104701. updatable?: boolean;
  104702. }, scene: Scene): Mesh;
  104703. /**
  104704. * Creates a ground mesh from a height map
  104705. * * The parameter `url` sets the URL of the height map image resource.
  104706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104710. * * 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.
  104711. * * 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).
  104712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104714. * @param name defines the name of the mesh
  104715. * @param url defines the url to the height map
  104716. * @param options defines the options used to create the mesh
  104717. * @param scene defines the hosting scene
  104718. * @returns the ground mesh
  104719. * @see https://doc.babylonjs.com/babylon101/height_map
  104720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104721. */
  104722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104723. width?: number;
  104724. height?: number;
  104725. subdivisions?: number;
  104726. minHeight?: number;
  104727. maxHeight?: number;
  104728. colorFilter?: Color3;
  104729. alphaFilter?: number;
  104730. updatable?: boolean;
  104731. onReady?: (mesh: GroundMesh) => void;
  104732. }, scene: Scene): GroundMesh;
  104733. /**
  104734. * Creates a polygon mesh
  104735. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104736. * * 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
  104737. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104740. * * Remember you can only change the shape positions, not their number when updating a polygon
  104741. * @param name defines the name of the mesh
  104742. * @param options defines the options used to create the mesh
  104743. * @param scene defines the hosting scene
  104744. * @param earcutInjection can be used to inject your own earcut reference
  104745. * @returns the polygon mesh
  104746. */
  104747. static CreatePolygon(name: string, options: {
  104748. shape: Vector3[];
  104749. holes?: Vector3[][];
  104750. depth?: number;
  104751. faceUV?: Vector4[];
  104752. faceColors?: Color4[];
  104753. updatable?: boolean;
  104754. sideOrientation?: number;
  104755. frontUVs?: Vector4;
  104756. backUVs?: Vector4;
  104757. }, scene: Scene, earcutInjection?: any): Mesh;
  104758. /**
  104759. * Creates an extruded polygon mesh, with depth in the Y direction.
  104760. * * 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)
  104761. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104762. * @param name defines the name of the mesh
  104763. * @param options defines the options used to create the mesh
  104764. * @param scene defines the hosting scene
  104765. * @param earcutInjection can be used to inject your own earcut reference
  104766. * @returns the polygon mesh
  104767. */
  104768. static ExtrudePolygon(name: string, options: {
  104769. shape: Vector3[];
  104770. holes?: Vector3[][];
  104771. depth?: number;
  104772. faceUV?: Vector4[];
  104773. faceColors?: Color4[];
  104774. updatable?: boolean;
  104775. sideOrientation?: number;
  104776. frontUVs?: Vector4;
  104777. backUVs?: Vector4;
  104778. }, scene: Scene, earcutInjection?: any): Mesh;
  104779. /**
  104780. * Creates a tube mesh.
  104781. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104782. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104783. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104784. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104785. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104786. * * 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)
  104787. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104788. * * 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
  104789. * * 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
  104790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104794. * @param name defines the name of the mesh
  104795. * @param options defines the options used to create the mesh
  104796. * @param scene defines the hosting scene
  104797. * @returns the tube mesh
  104798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104799. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104800. */
  104801. static CreateTube(name: string, options: {
  104802. path: Vector3[];
  104803. radius?: number;
  104804. tessellation?: number;
  104805. radiusFunction?: {
  104806. (i: number, distance: number): number;
  104807. };
  104808. cap?: number;
  104809. arc?: number;
  104810. updatable?: boolean;
  104811. sideOrientation?: number;
  104812. frontUVs?: Vector4;
  104813. backUVs?: Vector4;
  104814. instance?: Mesh;
  104815. invertUV?: boolean;
  104816. }, scene: Scene): Mesh;
  104817. /**
  104818. * Creates a polyhedron mesh
  104819. * * 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
  104820. * * The parameter `size` (positive float, default 1) sets the polygon size
  104821. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104822. * * 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`
  104823. * * 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
  104824. * * 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)`)
  104825. * * 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
  104826. * * 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
  104827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104830. * @param name defines the name of the mesh
  104831. * @param options defines the options used to create the mesh
  104832. * @param scene defines the hosting scene
  104833. * @returns the polyhedron mesh
  104834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104835. */
  104836. static CreatePolyhedron(name: string, options: {
  104837. type?: number;
  104838. size?: number;
  104839. sizeX?: number;
  104840. sizeY?: number;
  104841. sizeZ?: number;
  104842. custom?: any;
  104843. faceUV?: Vector4[];
  104844. faceColors?: Color4[];
  104845. flat?: boolean;
  104846. updatable?: boolean;
  104847. sideOrientation?: number;
  104848. frontUVs?: Vector4;
  104849. backUVs?: Vector4;
  104850. }, scene: Scene): Mesh;
  104851. /**
  104852. * Creates a decal mesh.
  104853. * 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
  104854. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104855. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104856. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104857. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104858. * @param name defines the name of the mesh
  104859. * @param sourceMesh defines the mesh where the decal must be applied
  104860. * @param options defines the options used to create the mesh
  104861. * @param scene defines the hosting scene
  104862. * @returns the decal mesh
  104863. * @see https://doc.babylonjs.com/how_to/decals
  104864. */
  104865. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104866. position?: Vector3;
  104867. normal?: Vector3;
  104868. size?: Vector3;
  104869. angle?: number;
  104870. }): Mesh;
  104871. }
  104872. }
  104873. declare module BABYLON {
  104874. /**
  104875. * A simplifier interface for future simplification implementations
  104876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104877. */
  104878. export interface ISimplifier {
  104879. /**
  104880. * Simplification of a given mesh according to the given settings.
  104881. * Since this requires computation, it is assumed that the function runs async.
  104882. * @param settings The settings of the simplification, including quality and distance
  104883. * @param successCallback A callback that will be called after the mesh was simplified.
  104884. * @param errorCallback in case of an error, this callback will be called. optional.
  104885. */
  104886. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104887. }
  104888. /**
  104889. * Expected simplification settings.
  104890. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104892. */
  104893. export interface ISimplificationSettings {
  104894. /**
  104895. * Gets or sets the expected quality
  104896. */
  104897. quality: number;
  104898. /**
  104899. * Gets or sets the distance when this optimized version should be used
  104900. */
  104901. distance: number;
  104902. /**
  104903. * Gets an already optimized mesh
  104904. */
  104905. optimizeMesh?: boolean;
  104906. }
  104907. /**
  104908. * Class used to specify simplification options
  104909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104910. */
  104911. export class SimplificationSettings implements ISimplificationSettings {
  104912. /** expected quality */
  104913. quality: number;
  104914. /** distance when this optimized version should be used */
  104915. distance: number;
  104916. /** already optimized mesh */
  104917. optimizeMesh?: boolean | undefined;
  104918. /**
  104919. * Creates a SimplificationSettings
  104920. * @param quality expected quality
  104921. * @param distance distance when this optimized version should be used
  104922. * @param optimizeMesh already optimized mesh
  104923. */
  104924. constructor(
  104925. /** expected quality */
  104926. quality: number,
  104927. /** distance when this optimized version should be used */
  104928. distance: number,
  104929. /** already optimized mesh */
  104930. optimizeMesh?: boolean | undefined);
  104931. }
  104932. /**
  104933. * Interface used to define a simplification task
  104934. */
  104935. export interface ISimplificationTask {
  104936. /**
  104937. * Array of settings
  104938. */
  104939. settings: Array<ISimplificationSettings>;
  104940. /**
  104941. * Simplification type
  104942. */
  104943. simplificationType: SimplificationType;
  104944. /**
  104945. * Mesh to simplify
  104946. */
  104947. mesh: Mesh;
  104948. /**
  104949. * Callback called on success
  104950. */
  104951. successCallback?: () => void;
  104952. /**
  104953. * Defines if parallel processing can be used
  104954. */
  104955. parallelProcessing: boolean;
  104956. }
  104957. /**
  104958. * Queue used to order the simplification tasks
  104959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104960. */
  104961. export class SimplificationQueue {
  104962. private _simplificationArray;
  104963. /**
  104964. * Gets a boolean indicating that the process is still running
  104965. */
  104966. running: boolean;
  104967. /**
  104968. * Creates a new queue
  104969. */
  104970. constructor();
  104971. /**
  104972. * Adds a new simplification task
  104973. * @param task defines a task to add
  104974. */
  104975. addTask(task: ISimplificationTask): void;
  104976. /**
  104977. * Execute next task
  104978. */
  104979. executeNext(): void;
  104980. /**
  104981. * Execute a simplification task
  104982. * @param task defines the task to run
  104983. */
  104984. runSimplification(task: ISimplificationTask): void;
  104985. private getSimplifier;
  104986. }
  104987. /**
  104988. * The implemented types of simplification
  104989. * At the moment only Quadratic Error Decimation is implemented
  104990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104991. */
  104992. export enum SimplificationType {
  104993. /** Quadratic error decimation */
  104994. QUADRATIC = 0
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. interface Scene {
  104999. /** @hidden (Backing field) */
  105000. _simplificationQueue: SimplificationQueue;
  105001. /**
  105002. * Gets or sets the simplification queue attached to the scene
  105003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105004. */
  105005. simplificationQueue: SimplificationQueue;
  105006. }
  105007. interface Mesh {
  105008. /**
  105009. * Simplify the mesh according to the given array of settings.
  105010. * Function will return immediately and will simplify async
  105011. * @param settings a collection of simplification settings
  105012. * @param parallelProcessing should all levels calculate parallel or one after the other
  105013. * @param simplificationType the type of simplification to run
  105014. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  105015. * @returns the current mesh
  105016. */
  105017. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  105018. }
  105019. /**
  105020. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  105021. * created in a scene
  105022. */
  105023. export class SimplicationQueueSceneComponent implements ISceneComponent {
  105024. /**
  105025. * The component name helpfull to identify the component in the list of scene components.
  105026. */
  105027. readonly name: string;
  105028. /**
  105029. * The scene the component belongs to.
  105030. */
  105031. scene: Scene;
  105032. /**
  105033. * Creates a new instance of the component for the given scene
  105034. * @param scene Defines the scene to register the component in
  105035. */
  105036. constructor(scene: Scene);
  105037. /**
  105038. * Registers the component in a given scene
  105039. */
  105040. register(): void;
  105041. /**
  105042. * Rebuilds the elements related to this component in case of
  105043. * context lost for instance.
  105044. */
  105045. rebuild(): void;
  105046. /**
  105047. * Disposes the component and the associated ressources
  105048. */
  105049. dispose(): void;
  105050. private _beforeCameraUpdate;
  105051. }
  105052. }
  105053. declare module BABYLON {
  105054. /**
  105055. * Class used to enable access to IndexedDB
  105056. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105057. */
  105058. export class Database implements IOfflineProvider {
  105059. private _callbackManifestChecked;
  105060. private _currentSceneUrl;
  105061. private _db;
  105062. private _enableSceneOffline;
  105063. private _enableTexturesOffline;
  105064. private _manifestVersionFound;
  105065. private _mustUpdateRessources;
  105066. private _hasReachedQuota;
  105067. private _isSupported;
  105068. private _idbFactory;
  105069. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  105070. private static IsUASupportingBlobStorage;
  105071. /**
  105072. * Gets a boolean indicating if Database storate is enabled (off by default)
  105073. */
  105074. static IDBStorageEnabled: boolean;
  105075. /**
  105076. * Gets a boolean indicating if scene must be saved in the database
  105077. */
  105078. readonly enableSceneOffline: boolean;
  105079. /**
  105080. * Gets a boolean indicating if textures must be saved in the database
  105081. */
  105082. readonly enableTexturesOffline: boolean;
  105083. /**
  105084. * Creates a new Database
  105085. * @param urlToScene defines the url to load the scene
  105086. * @param callbackManifestChecked defines the callback to use when manifest is checked
  105087. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  105088. */
  105089. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  105090. private static _ParseURL;
  105091. private static _ReturnFullUrlLocation;
  105092. private _checkManifestFile;
  105093. /**
  105094. * Open the database and make it available
  105095. * @param successCallback defines the callback to call on success
  105096. * @param errorCallback defines the callback to call on error
  105097. */
  105098. open(successCallback: () => void, errorCallback: () => void): void;
  105099. /**
  105100. * Loads an image from the database
  105101. * @param url defines the url to load from
  105102. * @param image defines the target DOM image
  105103. */
  105104. loadImage(url: string, image: HTMLImageElement): void;
  105105. private _loadImageFromDBAsync;
  105106. private _saveImageIntoDBAsync;
  105107. private _checkVersionFromDB;
  105108. private _loadVersionFromDBAsync;
  105109. private _saveVersionIntoDBAsync;
  105110. /**
  105111. * Loads a file from database
  105112. * @param url defines the URL to load from
  105113. * @param sceneLoaded defines a callback to call on success
  105114. * @param progressCallBack defines a callback to call when progress changed
  105115. * @param errorCallback defines a callback to call on error
  105116. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  105117. */
  105118. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  105119. private _loadFileAsync;
  105120. private _saveFileAsync;
  105121. /**
  105122. * Validates if xhr data is correct
  105123. * @param xhr defines the request to validate
  105124. * @param dataType defines the expected data type
  105125. * @returns true if data is correct
  105126. */
  105127. private static _ValidateXHRData;
  105128. }
  105129. }
  105130. declare module BABYLON {
  105131. /** @hidden */
  105132. export var gpuUpdateParticlesPixelShader: {
  105133. name: string;
  105134. shader: string;
  105135. };
  105136. }
  105137. declare module BABYLON {
  105138. /** @hidden */
  105139. export var gpuUpdateParticlesVertexShader: {
  105140. name: string;
  105141. shader: string;
  105142. };
  105143. }
  105144. declare module BABYLON {
  105145. /** @hidden */
  105146. export var clipPlaneFragmentDeclaration2: {
  105147. name: string;
  105148. shader: string;
  105149. };
  105150. }
  105151. declare module BABYLON {
  105152. /** @hidden */
  105153. export var gpuRenderParticlesPixelShader: {
  105154. name: string;
  105155. shader: string;
  105156. };
  105157. }
  105158. declare module BABYLON {
  105159. /** @hidden */
  105160. export var clipPlaneVertexDeclaration2: {
  105161. name: string;
  105162. shader: string;
  105163. };
  105164. }
  105165. declare module BABYLON {
  105166. /** @hidden */
  105167. export var gpuRenderParticlesVertexShader: {
  105168. name: string;
  105169. shader: string;
  105170. };
  105171. }
  105172. declare module BABYLON {
  105173. /**
  105174. * This represents a GPU particle system in Babylon
  105175. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  105176. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  105177. */
  105178. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  105179. /**
  105180. * The layer mask we are rendering the particles through.
  105181. */
  105182. layerMask: number;
  105183. private _capacity;
  105184. private _activeCount;
  105185. private _currentActiveCount;
  105186. private _accumulatedCount;
  105187. private _renderEffect;
  105188. private _updateEffect;
  105189. private _buffer0;
  105190. private _buffer1;
  105191. private _spriteBuffer;
  105192. private _updateVAO;
  105193. private _renderVAO;
  105194. private _targetIndex;
  105195. private _sourceBuffer;
  105196. private _targetBuffer;
  105197. private _engine;
  105198. private _currentRenderId;
  105199. private _started;
  105200. private _stopped;
  105201. private _timeDelta;
  105202. private _randomTexture;
  105203. private _randomTexture2;
  105204. private _attributesStrideSize;
  105205. private _updateEffectOptions;
  105206. private _randomTextureSize;
  105207. private _actualFrame;
  105208. private readonly _rawTextureWidth;
  105209. /**
  105210. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  105211. */
  105212. static readonly IsSupported: boolean;
  105213. /**
  105214. * An event triggered when the system is disposed.
  105215. */
  105216. onDisposeObservable: Observable<GPUParticleSystem>;
  105217. /**
  105218. * Gets the maximum number of particles active at the same time.
  105219. * @returns The max number of active particles.
  105220. */
  105221. getCapacity(): number;
  105222. /**
  105223. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105224. * to override the particles.
  105225. */
  105226. forceDepthWrite: boolean;
  105227. /**
  105228. * Gets or set the number of active particles
  105229. */
  105230. activeParticleCount: number;
  105231. private _preWarmDone;
  105232. /**
  105233. * Is this system ready to be used/rendered
  105234. * @return true if the system is ready
  105235. */
  105236. isReady(): boolean;
  105237. /**
  105238. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105239. * @returns True if it has been started, otherwise false.
  105240. */
  105241. isStarted(): boolean;
  105242. /**
  105243. * Starts the particle system and begins to emit
  105244. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105245. */
  105246. start(delay?: number): void;
  105247. /**
  105248. * Stops the particle system.
  105249. */
  105250. stop(): void;
  105251. /**
  105252. * Remove all active particles
  105253. */
  105254. reset(): void;
  105255. /**
  105256. * Returns the string "GPUParticleSystem"
  105257. * @returns a string containing the class name
  105258. */
  105259. getClassName(): string;
  105260. private _colorGradientsTexture;
  105261. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  105262. /**
  105263. * Adds a new color gradient
  105264. * @param gradient defines the gradient to use (between 0 and 1)
  105265. * @param color1 defines the color to affect to the specified gradient
  105266. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105267. * @returns the current particle system
  105268. */
  105269. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  105270. /**
  105271. * Remove a specific color gradient
  105272. * @param gradient defines the gradient to remove
  105273. * @returns the current particle system
  105274. */
  105275. removeColorGradient(gradient: number): GPUParticleSystem;
  105276. private _angularSpeedGradientsTexture;
  105277. private _sizeGradientsTexture;
  105278. private _velocityGradientsTexture;
  105279. private _limitVelocityGradientsTexture;
  105280. private _dragGradientsTexture;
  105281. private _addFactorGradient;
  105282. /**
  105283. * Adds a new size gradient
  105284. * @param gradient defines the gradient to use (between 0 and 1)
  105285. * @param factor defines the size factor to affect to the specified gradient
  105286. * @returns the current particle system
  105287. */
  105288. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  105289. /**
  105290. * Remove a specific size gradient
  105291. * @param gradient defines the gradient to remove
  105292. * @returns the current particle system
  105293. */
  105294. removeSizeGradient(gradient: number): GPUParticleSystem;
  105295. /**
  105296. * Adds a new angular speed gradient
  105297. * @param gradient defines the gradient to use (between 0 and 1)
  105298. * @param factor defines the angular speed to affect to the specified gradient
  105299. * @returns the current particle system
  105300. */
  105301. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  105302. /**
  105303. * Remove a specific angular speed gradient
  105304. * @param gradient defines the gradient to remove
  105305. * @returns the current particle system
  105306. */
  105307. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  105308. /**
  105309. * Adds a new velocity gradient
  105310. * @param gradient defines the gradient to use (between 0 and 1)
  105311. * @param factor defines the velocity to affect to the specified gradient
  105312. * @returns the current particle system
  105313. */
  105314. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105315. /**
  105316. * Remove a specific velocity gradient
  105317. * @param gradient defines the gradient to remove
  105318. * @returns the current particle system
  105319. */
  105320. removeVelocityGradient(gradient: number): GPUParticleSystem;
  105321. /**
  105322. * Adds a new limit velocity gradient
  105323. * @param gradient defines the gradient to use (between 0 and 1)
  105324. * @param factor defines the limit velocity value to affect to the specified gradient
  105325. * @returns the current particle system
  105326. */
  105327. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105328. /**
  105329. * Remove a specific limit velocity gradient
  105330. * @param gradient defines the gradient to remove
  105331. * @returns the current particle system
  105332. */
  105333. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  105334. /**
  105335. * Adds a new drag gradient
  105336. * @param gradient defines the gradient to use (between 0 and 1)
  105337. * @param factor defines the drag value to affect to the specified gradient
  105338. * @returns the current particle system
  105339. */
  105340. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  105341. /**
  105342. * Remove a specific drag gradient
  105343. * @param gradient defines the gradient to remove
  105344. * @returns the current particle system
  105345. */
  105346. removeDragGradient(gradient: number): GPUParticleSystem;
  105347. /**
  105348. * Not supported by GPUParticleSystem
  105349. * @param gradient defines the gradient to use (between 0 and 1)
  105350. * @param factor defines the emit rate value to affect to the specified gradient
  105351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105352. * @returns the current particle system
  105353. */
  105354. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105355. /**
  105356. * Not supported by GPUParticleSystem
  105357. * @param gradient defines the gradient to remove
  105358. * @returns the current particle system
  105359. */
  105360. removeEmitRateGradient(gradient: number): IParticleSystem;
  105361. /**
  105362. * Not supported by GPUParticleSystem
  105363. * @param gradient defines the gradient to use (between 0 and 1)
  105364. * @param factor defines the start size value to affect to the specified gradient
  105365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105366. * @returns the current particle system
  105367. */
  105368. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105369. /**
  105370. * Not supported by GPUParticleSystem
  105371. * @param gradient defines the gradient to remove
  105372. * @returns the current particle system
  105373. */
  105374. removeStartSizeGradient(gradient: number): IParticleSystem;
  105375. /**
  105376. * Not supported by GPUParticleSystem
  105377. * @param gradient defines the gradient to use (between 0 and 1)
  105378. * @param min defines the color remap minimal range
  105379. * @param max defines the color remap maximal range
  105380. * @returns the current particle system
  105381. */
  105382. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105383. /**
  105384. * Not supported by GPUParticleSystem
  105385. * @param gradient defines the gradient to remove
  105386. * @returns the current particle system
  105387. */
  105388. removeColorRemapGradient(): IParticleSystem;
  105389. /**
  105390. * Not supported by GPUParticleSystem
  105391. * @param gradient defines the gradient to use (between 0 and 1)
  105392. * @param min defines the alpha remap minimal range
  105393. * @param max defines the alpha remap maximal range
  105394. * @returns the current particle system
  105395. */
  105396. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105397. /**
  105398. * Not supported by GPUParticleSystem
  105399. * @param gradient defines the gradient to remove
  105400. * @returns the current particle system
  105401. */
  105402. removeAlphaRemapGradient(): IParticleSystem;
  105403. /**
  105404. * Not supported by GPUParticleSystem
  105405. * @param gradient defines the gradient to use (between 0 and 1)
  105406. * @param color defines the color to affect to the specified gradient
  105407. * @returns the current particle system
  105408. */
  105409. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  105410. /**
  105411. * Not supported by GPUParticleSystem
  105412. * @param gradient defines the gradient to remove
  105413. * @returns the current particle system
  105414. */
  105415. removeRampGradient(): IParticleSystem;
  105416. /**
  105417. * Not supported by GPUParticleSystem
  105418. * @returns the list of ramp gradients
  105419. */
  105420. getRampGradients(): Nullable<Array<Color3Gradient>>;
  105421. /**
  105422. * Not supported by GPUParticleSystem
  105423. * Gets or sets a boolean indicating that ramp gradients must be used
  105424. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105425. */
  105426. useRampGradients: boolean;
  105427. /**
  105428. * Not supported by GPUParticleSystem
  105429. * @param gradient defines the gradient to use (between 0 and 1)
  105430. * @param factor defines the life time factor to affect to the specified gradient
  105431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105432. * @returns the current particle system
  105433. */
  105434. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105435. /**
  105436. * Not supported by GPUParticleSystem
  105437. * @param gradient defines the gradient to remove
  105438. * @returns the current particle system
  105439. */
  105440. removeLifeTimeGradient(gradient: number): IParticleSystem;
  105441. /**
  105442. * Instantiates a GPU particle system.
  105443. * 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.
  105444. * @param name The name of the particle system
  105445. * @param options The options used to create the system
  105446. * @param scene The scene the particle system belongs to
  105447. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105448. */
  105449. constructor(name: string, options: Partial<{
  105450. capacity: number;
  105451. randomTextureSize: number;
  105452. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  105453. protected _reset(): void;
  105454. private _createUpdateVAO;
  105455. private _createRenderVAO;
  105456. private _initialize;
  105457. /** @hidden */
  105458. _recreateUpdateEffect(): void;
  105459. /** @hidden */
  105460. _recreateRenderEffect(): void;
  105461. /**
  105462. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105463. * @param preWarm defines if we are in the pre-warmimg phase
  105464. */
  105465. animate(preWarm?: boolean): void;
  105466. private _createFactorGradientTexture;
  105467. private _createSizeGradientTexture;
  105468. private _createAngularSpeedGradientTexture;
  105469. private _createVelocityGradientTexture;
  105470. private _createLimitVelocityGradientTexture;
  105471. private _createDragGradientTexture;
  105472. private _createColorGradientTexture;
  105473. /**
  105474. * Renders the particle system in its current state
  105475. * @param preWarm defines if the system should only update the particles but not render them
  105476. * @returns the current number of particles
  105477. */
  105478. render(preWarm?: boolean): number;
  105479. /**
  105480. * Rebuilds the particle system
  105481. */
  105482. rebuild(): void;
  105483. private _releaseBuffers;
  105484. private _releaseVAOs;
  105485. /**
  105486. * Disposes the particle system and free the associated resources
  105487. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105488. */
  105489. dispose(disposeTexture?: boolean): void;
  105490. /**
  105491. * Clones the particle system.
  105492. * @param name The name of the cloned object
  105493. * @param newEmitter The new emitter to use
  105494. * @returns the cloned particle system
  105495. */
  105496. clone(name: string, newEmitter: any): GPUParticleSystem;
  105497. /**
  105498. * Serializes the particle system to a JSON object.
  105499. * @returns the JSON object
  105500. */
  105501. serialize(): any;
  105502. /**
  105503. * Parses a JSON object to create a GPU particle system.
  105504. * @param parsedParticleSystem The JSON object to parse
  105505. * @param scene The scene to create the particle system in
  105506. * @param rootUrl The root url to use to load external dependencies like texture
  105507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  105508. * @returns the parsed GPU particle system
  105509. */
  105510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  105511. }
  105512. }
  105513. declare module BABYLON {
  105514. /**
  105515. * Represents a set of particle systems working together to create a specific effect
  105516. */
  105517. export class ParticleSystemSet implements IDisposable {
  105518. private _emitterCreationOptions;
  105519. private _emitterNode;
  105520. /**
  105521. * Gets the particle system list
  105522. */
  105523. systems: IParticleSystem[];
  105524. /**
  105525. * Gets the emitter node used with this set
  105526. */
  105527. readonly emitterNode: Nullable<TransformNode>;
  105528. /**
  105529. * Creates a new emitter mesh as a sphere
  105530. * @param options defines the options used to create the sphere
  105531. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  105532. * @param scene defines the hosting scene
  105533. */
  105534. setEmitterAsSphere(options: {
  105535. diameter: number;
  105536. segments: number;
  105537. color: Color3;
  105538. }, renderingGroupId: number, scene: Scene): void;
  105539. /**
  105540. * Starts all particle systems of the set
  105541. * @param emitter defines an optional mesh to use as emitter for the particle systems
  105542. */
  105543. start(emitter?: AbstractMesh): void;
  105544. /**
  105545. * Release all associated resources
  105546. */
  105547. dispose(): void;
  105548. /**
  105549. * Serialize the set into a JSON compatible object
  105550. * @returns a JSON compatible representation of the set
  105551. */
  105552. serialize(): any;
  105553. /**
  105554. * Parse a new ParticleSystemSet from a serialized source
  105555. * @param data defines a JSON compatible representation of the set
  105556. * @param scene defines the hosting scene
  105557. * @param gpu defines if we want GPU particles or CPU particles
  105558. * @returns a new ParticleSystemSet
  105559. */
  105560. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  105561. }
  105562. }
  105563. declare module BABYLON {
  105564. /**
  105565. * This class is made for on one-liner static method to help creating particle system set.
  105566. */
  105567. export class ParticleHelper {
  105568. /**
  105569. * Gets or sets base Assets URL
  105570. */
  105571. static BaseAssetsUrl: string;
  105572. /**
  105573. * Create a default particle system that you can tweak
  105574. * @param emitter defines the emitter to use
  105575. * @param capacity defines the system capacity (default is 500 particles)
  105576. * @param scene defines the hosting scene
  105577. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105578. * @returns the new Particle system
  105579. */
  105580. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  105581. /**
  105582. * This is the main static method (one-liner) of this helper to create different particle systems
  105583. * @param type This string represents the type to the particle system to create
  105584. * @param scene The scene where the particle system should live
  105585. * @param gpu If the system will use gpu
  105586. * @returns the ParticleSystemSet created
  105587. */
  105588. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  105589. /**
  105590. * Static function used to export a particle system to a ParticleSystemSet variable.
  105591. * Please note that the emitter shape is not exported
  105592. * @param systems defines the particle systems to export
  105593. * @returns the created particle system set
  105594. */
  105595. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  105596. }
  105597. }
  105598. declare module BABYLON {
  105599. interface Engine {
  105600. /**
  105601. * Create an effect to use with particle systems.
  105602. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  105603. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  105604. * @param uniformsNames defines a list of attribute names
  105605. * @param samplers defines an array of string used to represent textures
  105606. * @param defines defines the string containing the defines to use to compile the shaders
  105607. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105608. * @param onCompiled defines a function to call when the effect creation is successful
  105609. * @param onError defines a function to call when the effect creation has failed
  105610. * @returns the new Effect
  105611. */
  105612. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  105613. }
  105614. interface Mesh {
  105615. /**
  105616. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  105617. * @returns an array of IParticleSystem
  105618. */
  105619. getEmittedParticleSystems(): IParticleSystem[];
  105620. /**
  105621. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  105622. * @returns an array of IParticleSystem
  105623. */
  105624. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  105625. }
  105626. /**
  105627. * @hidden
  105628. */
  105629. export var _IDoNeedToBeInTheBuild: number;
  105630. }
  105631. declare module BABYLON {
  105632. interface Scene {
  105633. /** @hidden (Backing field) */
  105634. _physicsEngine: Nullable<IPhysicsEngine>;
  105635. /**
  105636. * Gets the current physics engine
  105637. * @returns a IPhysicsEngine or null if none attached
  105638. */
  105639. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105640. /**
  105641. * Enables physics to the current scene
  105642. * @param gravity defines the scene's gravity for the physics engine
  105643. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105644. * @return a boolean indicating if the physics engine was initialized
  105645. */
  105646. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105647. /**
  105648. * Disables and disposes the physics engine associated with the scene
  105649. */
  105650. disablePhysicsEngine(): void;
  105651. /**
  105652. * Gets a boolean indicating if there is an active physics engine
  105653. * @returns a boolean indicating if there is an active physics engine
  105654. */
  105655. isPhysicsEnabled(): boolean;
  105656. /**
  105657. * Deletes a physics compound impostor
  105658. * @param compound defines the compound to delete
  105659. */
  105660. deleteCompoundImpostor(compound: any): void;
  105661. /**
  105662. * An event triggered when physic simulation is about to be run
  105663. */
  105664. onBeforePhysicsObservable: Observable<Scene>;
  105665. /**
  105666. * An event triggered when physic simulation has been done
  105667. */
  105668. onAfterPhysicsObservable: Observable<Scene>;
  105669. }
  105670. interface AbstractMesh {
  105671. /** @hidden */
  105672. _physicsImpostor: Nullable<PhysicsImpostor>;
  105673. /**
  105674. * Gets or sets impostor used for physic simulation
  105675. * @see http://doc.babylonjs.com/features/physics_engine
  105676. */
  105677. physicsImpostor: Nullable<PhysicsImpostor>;
  105678. /**
  105679. * Gets the current physics impostor
  105680. * @see http://doc.babylonjs.com/features/physics_engine
  105681. * @returns a physics impostor or null
  105682. */
  105683. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105684. /** Apply a physic impulse to the mesh
  105685. * @param force defines the force to apply
  105686. * @param contactPoint defines where to apply the force
  105687. * @returns the current mesh
  105688. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105689. */
  105690. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105691. /**
  105692. * Creates a physic joint between two meshes
  105693. * @param otherMesh defines the other mesh to use
  105694. * @param pivot1 defines the pivot to use on this mesh
  105695. * @param pivot2 defines the pivot to use on the other mesh
  105696. * @param options defines additional options (can be plugin dependent)
  105697. * @returns the current mesh
  105698. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105699. */
  105700. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105701. /** @hidden */
  105702. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105703. }
  105704. /**
  105705. * Defines the physics engine scene component responsible to manage a physics engine
  105706. */
  105707. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105708. /**
  105709. * The component name helpful to identify the component in the list of scene components.
  105710. */
  105711. readonly name: string;
  105712. /**
  105713. * The scene the component belongs to.
  105714. */
  105715. scene: Scene;
  105716. /**
  105717. * Creates a new instance of the component for the given scene
  105718. * @param scene Defines the scene to register the component in
  105719. */
  105720. constructor(scene: Scene);
  105721. /**
  105722. * Registers the component in a given scene
  105723. */
  105724. register(): void;
  105725. /**
  105726. * Rebuilds the elements related to this component in case of
  105727. * context lost for instance.
  105728. */
  105729. rebuild(): void;
  105730. /**
  105731. * Disposes the component and the associated ressources
  105732. */
  105733. dispose(): void;
  105734. }
  105735. }
  105736. declare module BABYLON {
  105737. /**
  105738. * A helper for physics simulations
  105739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105740. */
  105741. export class PhysicsHelper {
  105742. private _scene;
  105743. private _physicsEngine;
  105744. /**
  105745. * Initializes the Physics helper
  105746. * @param scene Babylon.js scene
  105747. */
  105748. constructor(scene: Scene);
  105749. /**
  105750. * Applies a radial explosion impulse
  105751. * @param origin the origin of the explosion
  105752. * @param radius the explosion radius
  105753. * @param strength the explosion strength
  105754. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105755. * @returns A physics radial explosion event, or null
  105756. */
  105757. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105758. /**
  105759. * Applies a radial explosion force
  105760. * @param origin the origin of the explosion
  105761. * @param radius the explosion radius
  105762. * @param strength the explosion strength
  105763. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105764. * @returns A physics radial explosion event, or null
  105765. */
  105766. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105767. /**
  105768. * Creates a gravitational field
  105769. * @param origin the origin of the explosion
  105770. * @param radius the explosion radius
  105771. * @param strength the explosion strength
  105772. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105773. * @returns A physics gravitational field event, or null
  105774. */
  105775. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105776. /**
  105777. * Creates a physics updraft event
  105778. * @param origin the origin of the updraft
  105779. * @param radius the radius of the updraft
  105780. * @param strength the strength of the updraft
  105781. * @param height the height of the updraft
  105782. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105783. * @returns A physics updraft event, or null
  105784. */
  105785. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105786. /**
  105787. * Creates a physics vortex event
  105788. * @param origin the of the vortex
  105789. * @param radius the radius of the vortex
  105790. * @param strength the strength of the vortex
  105791. * @param height the height of the vortex
  105792. * @returns a Physics vortex event, or null
  105793. * A physics vortex event or null
  105794. */
  105795. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105796. }
  105797. /**
  105798. * Represents a physics radial explosion event
  105799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105800. */
  105801. export class PhysicsRadialExplosionEvent {
  105802. private _scene;
  105803. private _sphere;
  105804. private _sphereOptions;
  105805. private _rays;
  105806. private _dataFetched;
  105807. /**
  105808. * Initializes a radial explosioin event
  105809. * @param scene BabylonJS scene
  105810. */
  105811. constructor(scene: Scene);
  105812. /**
  105813. * Returns the data related to the radial explosion event (sphere & rays).
  105814. * @returns The radial explosion event data
  105815. */
  105816. getData(): PhysicsRadialExplosionEventData;
  105817. /**
  105818. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105819. * @param impostor A physics imposter
  105820. * @param origin the origin of the explosion
  105821. * @param radius the explosion radius
  105822. * @param strength the explosion strength
  105823. * @param falloff possible options: Constant & Linear
  105824. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105825. */
  105826. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105827. /**
  105828. * Disposes the sphere.
  105829. * @param force Specifies if the sphere should be disposed by force
  105830. */
  105831. dispose(force?: boolean): void;
  105832. /*** Helpers ***/
  105833. private _prepareSphere;
  105834. private _intersectsWithSphere;
  105835. }
  105836. /**
  105837. * Represents a gravitational field event
  105838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105839. */
  105840. export class PhysicsGravitationalFieldEvent {
  105841. private _physicsHelper;
  105842. private _scene;
  105843. private _origin;
  105844. private _radius;
  105845. private _strength;
  105846. private _falloff;
  105847. private _tickCallback;
  105848. private _sphere;
  105849. private _dataFetched;
  105850. /**
  105851. * Initializes the physics gravitational field event
  105852. * @param physicsHelper A physics helper
  105853. * @param scene BabylonJS scene
  105854. * @param origin The origin position of the gravitational field event
  105855. * @param radius The radius of the gravitational field event
  105856. * @param strength The strength of the gravitational field event
  105857. * @param falloff The falloff for the gravitational field event
  105858. */
  105859. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105860. /**
  105861. * Returns the data related to the gravitational field event (sphere).
  105862. * @returns A gravitational field event
  105863. */
  105864. getData(): PhysicsGravitationalFieldEventData;
  105865. /**
  105866. * Enables the gravitational field.
  105867. */
  105868. enable(): void;
  105869. /**
  105870. * Disables the gravitational field.
  105871. */
  105872. disable(): void;
  105873. /**
  105874. * Disposes the sphere.
  105875. * @param force The force to dispose from the gravitational field event
  105876. */
  105877. dispose(force?: boolean): void;
  105878. private _tick;
  105879. }
  105880. /**
  105881. * Represents a physics updraft event
  105882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105883. */
  105884. export class PhysicsUpdraftEvent {
  105885. private _scene;
  105886. private _origin;
  105887. private _radius;
  105888. private _strength;
  105889. private _height;
  105890. private _updraftMode;
  105891. private _physicsEngine;
  105892. private _originTop;
  105893. private _originDirection;
  105894. private _tickCallback;
  105895. private _cylinder;
  105896. private _cylinderPosition;
  105897. private _dataFetched;
  105898. /**
  105899. * Initializes the physics updraft event
  105900. * @param _scene BabylonJS scene
  105901. * @param _origin The origin position of the updraft
  105902. * @param _radius The radius of the updraft
  105903. * @param _strength The strength of the updraft
  105904. * @param _height The height of the updraft
  105905. * @param _updraftMode The mode of the updraft
  105906. */
  105907. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105908. /**
  105909. * Returns the data related to the updraft event (cylinder).
  105910. * @returns A physics updraft event
  105911. */
  105912. getData(): PhysicsUpdraftEventData;
  105913. /**
  105914. * Enables the updraft.
  105915. */
  105916. enable(): void;
  105917. /**
  105918. * Disables the cortex.
  105919. */
  105920. disable(): void;
  105921. /**
  105922. * Disposes the sphere.
  105923. * @param force Specifies if the updraft should be disposed by force
  105924. */
  105925. dispose(force?: boolean): void;
  105926. private getImpostorForceAndContactPoint;
  105927. private _tick;
  105928. /*** Helpers ***/
  105929. private _prepareCylinder;
  105930. private _intersectsWithCylinder;
  105931. }
  105932. /**
  105933. * Represents a physics vortex event
  105934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105935. */
  105936. export class PhysicsVortexEvent {
  105937. private _scene;
  105938. private _origin;
  105939. private _radius;
  105940. private _strength;
  105941. private _height;
  105942. private _physicsEngine;
  105943. private _originTop;
  105944. private _centripetalForceThreshold;
  105945. private _updraftMultiplier;
  105946. private _tickCallback;
  105947. private _cylinder;
  105948. private _cylinderPosition;
  105949. private _dataFetched;
  105950. /**
  105951. * Initializes the physics vortex event
  105952. * @param _scene The BabylonJS scene
  105953. * @param _origin The origin position of the vortex
  105954. * @param _radius The radius of the vortex
  105955. * @param _strength The strength of the vortex
  105956. * @param _height The height of the vortex
  105957. */
  105958. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105959. /**
  105960. * Returns the data related to the vortex event (cylinder).
  105961. * @returns The physics vortex event data
  105962. */
  105963. getData(): PhysicsVortexEventData;
  105964. /**
  105965. * Enables the vortex.
  105966. */
  105967. enable(): void;
  105968. /**
  105969. * Disables the cortex.
  105970. */
  105971. disable(): void;
  105972. /**
  105973. * Disposes the sphere.
  105974. * @param force
  105975. */
  105976. dispose(force?: boolean): void;
  105977. private getImpostorForceAndContactPoint;
  105978. private _tick;
  105979. /*** Helpers ***/
  105980. private _prepareCylinder;
  105981. private _intersectsWithCylinder;
  105982. }
  105983. /**
  105984. * The strenght of the force in correspondence to the distance of the affected object
  105985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105986. */
  105987. export enum PhysicsRadialImpulseFalloff {
  105988. /** Defines that impulse is constant in strength across it's whole radius */
  105989. Constant = 0,
  105990. /** DEfines that impulse gets weaker if it's further from the origin */
  105991. Linear = 1
  105992. }
  105993. /**
  105994. * The strength of the force in correspondence to the distance of the affected object
  105995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105996. */
  105997. export enum PhysicsUpdraftMode {
  105998. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105999. Center = 0,
  106000. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  106001. Perpendicular = 1
  106002. }
  106003. /**
  106004. * Interface for a physics force and contact point
  106005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106006. */
  106007. export interface PhysicsForceAndContactPoint {
  106008. /**
  106009. * The force applied at the contact point
  106010. */
  106011. force: Vector3;
  106012. /**
  106013. * The contact point
  106014. */
  106015. contactPoint: Vector3;
  106016. }
  106017. /**
  106018. * Interface for radial explosion event data
  106019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106020. */
  106021. export interface PhysicsRadialExplosionEventData {
  106022. /**
  106023. * A sphere used for the radial explosion event
  106024. */
  106025. sphere: Mesh;
  106026. /**
  106027. * An array of rays for the radial explosion event
  106028. */
  106029. rays: Array<Ray>;
  106030. }
  106031. /**
  106032. * Interface for gravitational field event data
  106033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106034. */
  106035. export interface PhysicsGravitationalFieldEventData {
  106036. /**
  106037. * A sphere mesh used for the gravitational field event
  106038. */
  106039. sphere: Mesh;
  106040. }
  106041. /**
  106042. * Interface for updraft event data
  106043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106044. */
  106045. export interface PhysicsUpdraftEventData {
  106046. /**
  106047. * A cylinder used for the updraft event
  106048. */
  106049. cylinder: Mesh;
  106050. }
  106051. /**
  106052. * Interface for vortex event data
  106053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106054. */
  106055. export interface PhysicsVortexEventData {
  106056. /**
  106057. * A cylinder used for the vortex event
  106058. */
  106059. cylinder: Mesh;
  106060. }
  106061. }
  106062. declare module BABYLON {
  106063. /**
  106064. * AmmoJS Physics plugin
  106065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106066. * @see https://github.com/kripken/ammo.js/
  106067. */
  106068. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106069. private _useDeltaForWorldStep;
  106070. /**
  106071. * Reference to the Ammo library
  106072. */
  106073. bjsAMMO: any;
  106074. /**
  106075. * Created ammoJS world which physics bodies are added to
  106076. */
  106077. world: any;
  106078. /**
  106079. * Name of the plugin
  106080. */
  106081. name: string;
  106082. private _timeStep;
  106083. private _fixedTimeStep;
  106084. private _maxSteps;
  106085. private _tmpQuaternion;
  106086. private _tmpAmmoTransform;
  106087. private _tmpAmmoQuaternion;
  106088. private _tmpAmmoConcreteContactResultCallback;
  106089. private _collisionConfiguration;
  106090. private _dispatcher;
  106091. private _overlappingPairCache;
  106092. private _solver;
  106093. private _tmpAmmoVectorA;
  106094. private _tmpAmmoVectorB;
  106095. private _tmpAmmoVectorC;
  106096. private _tmpContactCallbackResult;
  106097. private static readonly DISABLE_COLLISION_FLAG;
  106098. private static readonly KINEMATIC_FLAG;
  106099. private static readonly DISABLE_DEACTIVATION_FLAG;
  106100. /**
  106101. * Initializes the ammoJS plugin
  106102. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  106103. * @param ammoInjection can be used to inject your own ammo reference
  106104. */
  106105. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  106106. /**
  106107. * Sets the gravity of the physics world (m/(s^2))
  106108. * @param gravity Gravity to set
  106109. */
  106110. setGravity(gravity: Vector3): void;
  106111. /**
  106112. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  106113. * @param timeStep timestep to use in seconds
  106114. */
  106115. setTimeStep(timeStep: number): void;
  106116. /**
  106117. * 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)
  106118. * @param fixedTimeStep fixedTimeStep to use in seconds
  106119. */
  106120. setFixedTimeStep(fixedTimeStep: number): void;
  106121. /**
  106122. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  106123. * @param maxSteps the maximum number of steps by the physics engine per frame
  106124. */
  106125. setMaxSteps(maxSteps: number): void;
  106126. /**
  106127. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  106128. * @returns the current timestep in seconds
  106129. */
  106130. getTimeStep(): number;
  106131. private _isImpostorInContact;
  106132. private _isImpostorPairInContact;
  106133. private _stepSimulation;
  106134. /**
  106135. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  106136. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  106137. * After the step the babylon meshes are set to the position of the physics imposters
  106138. * @param delta amount of time to step forward
  106139. * @param impostors array of imposters to update before/after the step
  106140. */
  106141. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106142. private _tmpVector;
  106143. private _tmpMatrix;
  106144. /**
  106145. * Applies an implulse on the imposter
  106146. * @param impostor imposter to apply impulse
  106147. * @param force amount of force to be applied to the imposter
  106148. * @param contactPoint the location to apply the impulse on the imposter
  106149. */
  106150. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106151. /**
  106152. * Applies a force on the imposter
  106153. * @param impostor imposter to apply force
  106154. * @param force amount of force to be applied to the imposter
  106155. * @param contactPoint the location to apply the force on the imposter
  106156. */
  106157. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106158. /**
  106159. * Creates a physics body using the plugin
  106160. * @param impostor the imposter to create the physics body on
  106161. */
  106162. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106163. /**
  106164. * Removes the physics body from the imposter and disposes of the body's memory
  106165. * @param impostor imposter to remove the physics body from
  106166. */
  106167. removePhysicsBody(impostor: PhysicsImpostor): void;
  106168. /**
  106169. * Generates a joint
  106170. * @param impostorJoint the imposter joint to create the joint with
  106171. */
  106172. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106173. /**
  106174. * Removes a joint
  106175. * @param impostorJoint the imposter joint to remove the joint from
  106176. */
  106177. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106178. private _addMeshVerts;
  106179. private _createShape;
  106180. /**
  106181. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  106182. * @param impostor imposter containing the physics body and babylon object
  106183. */
  106184. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106185. /**
  106186. * Sets the babylon object's position/rotation from the physics body's position/rotation
  106187. * @param impostor imposter containing the physics body and babylon object
  106188. * @param newPosition new position
  106189. * @param newRotation new rotation
  106190. */
  106191. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106192. /**
  106193. * If this plugin is supported
  106194. * @returns true if its supported
  106195. */
  106196. isSupported(): boolean;
  106197. /**
  106198. * Sets the linear velocity of the physics body
  106199. * @param impostor imposter to set the velocity on
  106200. * @param velocity velocity to set
  106201. */
  106202. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106203. /**
  106204. * Sets the angular velocity of the physics body
  106205. * @param impostor imposter to set the velocity on
  106206. * @param velocity velocity to set
  106207. */
  106208. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106209. /**
  106210. * gets the linear velocity
  106211. * @param impostor imposter to get linear velocity from
  106212. * @returns linear velocity
  106213. */
  106214. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106215. /**
  106216. * gets the angular velocity
  106217. * @param impostor imposter to get angular velocity from
  106218. * @returns angular velocity
  106219. */
  106220. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106221. /**
  106222. * Sets the mass of physics body
  106223. * @param impostor imposter to set the mass on
  106224. * @param mass mass to set
  106225. */
  106226. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106227. /**
  106228. * Gets the mass of the physics body
  106229. * @param impostor imposter to get the mass from
  106230. * @returns mass
  106231. */
  106232. getBodyMass(impostor: PhysicsImpostor): number;
  106233. /**
  106234. * Gets friction of the impostor
  106235. * @param impostor impostor to get friction from
  106236. * @returns friction value
  106237. */
  106238. getBodyFriction(impostor: PhysicsImpostor): number;
  106239. /**
  106240. * Sets friction of the impostor
  106241. * @param impostor impostor to set friction on
  106242. * @param friction friction value
  106243. */
  106244. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106245. /**
  106246. * Gets restitution of the impostor
  106247. * @param impostor impostor to get restitution from
  106248. * @returns restitution value
  106249. */
  106250. getBodyRestitution(impostor: PhysicsImpostor): number;
  106251. /**
  106252. * Sets resitution of the impostor
  106253. * @param impostor impostor to set resitution on
  106254. * @param restitution resitution value
  106255. */
  106256. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106257. /**
  106258. * Sleeps the physics body and stops it from being active
  106259. * @param impostor impostor to sleep
  106260. */
  106261. sleepBody(impostor: PhysicsImpostor): void;
  106262. /**
  106263. * Activates the physics body
  106264. * @param impostor impostor to activate
  106265. */
  106266. wakeUpBody(impostor: PhysicsImpostor): void;
  106267. /**
  106268. * Updates the distance parameters of the joint
  106269. * @param joint joint to update
  106270. * @param maxDistance maximum distance of the joint
  106271. * @param minDistance minimum distance of the joint
  106272. */
  106273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106274. /**
  106275. * Sets a motor on the joint
  106276. * @param joint joint to set motor on
  106277. * @param speed speed of the motor
  106278. * @param maxForce maximum force of the motor
  106279. * @param motorIndex index of the motor
  106280. */
  106281. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106282. /**
  106283. * Sets the motors limit
  106284. * @param joint joint to set limit on
  106285. * @param upperLimit upper limit
  106286. * @param lowerLimit lower limit
  106287. */
  106288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106289. /**
  106290. * Syncs the position and rotation of a mesh with the impostor
  106291. * @param mesh mesh to sync
  106292. * @param impostor impostor to update the mesh with
  106293. */
  106294. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106295. /**
  106296. * Gets the radius of the impostor
  106297. * @param impostor impostor to get radius from
  106298. * @returns the radius
  106299. */
  106300. getRadius(impostor: PhysicsImpostor): number;
  106301. /**
  106302. * Gets the box size of the impostor
  106303. * @param impostor impostor to get box size from
  106304. * @param result the resulting box size
  106305. */
  106306. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106307. /**
  106308. * Disposes of the impostor
  106309. */
  106310. dispose(): void;
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. /** @hidden */
  106315. export var blackAndWhitePixelShader: {
  106316. name: string;
  106317. shader: string;
  106318. };
  106319. }
  106320. declare module BABYLON {
  106321. /**
  106322. * Post process used to render in black and white
  106323. */
  106324. export class BlackAndWhitePostProcess extends PostProcess {
  106325. /**
  106326. * Linear about to convert he result to black and white (default: 1)
  106327. */
  106328. degree: number;
  106329. /**
  106330. * Creates a black and white post process
  106331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  106332. * @param name The name of the effect.
  106333. * @param options The required width/height ratio to downsize to before computing the render pass.
  106334. * @param camera The camera to apply the render pass to.
  106335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106336. * @param engine The engine which the post process will be applied. (default: current engine)
  106337. * @param reusable If the post process can be reused on the same frame. (default: false)
  106338. */
  106339. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106340. }
  106341. }
  106342. declare module BABYLON {
  106343. /**
  106344. * This represents a set of one or more post processes in Babylon.
  106345. * A post process can be used to apply a shader to a texture after it is rendered.
  106346. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106347. */
  106348. export class PostProcessRenderEffect {
  106349. private _postProcesses;
  106350. private _getPostProcesses;
  106351. private _singleInstance;
  106352. private _cameras;
  106353. private _indicesForCamera;
  106354. /**
  106355. * Name of the effect
  106356. * @hidden
  106357. */
  106358. _name: string;
  106359. /**
  106360. * Instantiates a post process render effect.
  106361. * A post process can be used to apply a shader to a texture after it is rendered.
  106362. * @param engine The engine the effect is tied to
  106363. * @param name The name of the effect
  106364. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  106365. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  106366. */
  106367. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  106368. /**
  106369. * Checks if all the post processes in the effect are supported.
  106370. */
  106371. readonly isSupported: boolean;
  106372. /**
  106373. * Updates the current state of the effect
  106374. * @hidden
  106375. */
  106376. _update(): void;
  106377. /**
  106378. * Attaches the effect on cameras
  106379. * @param cameras The camera to attach to.
  106380. * @hidden
  106381. */
  106382. _attachCameras(cameras: Camera): void;
  106383. /**
  106384. * Attaches the effect on cameras
  106385. * @param cameras The camera to attach to.
  106386. * @hidden
  106387. */
  106388. _attachCameras(cameras: Camera[]): void;
  106389. /**
  106390. * Detatches the effect on cameras
  106391. * @param cameras The camera to detatch from.
  106392. * @hidden
  106393. */
  106394. _detachCameras(cameras: Camera): void;
  106395. /**
  106396. * Detatches the effect on cameras
  106397. * @param cameras The camera to detatch from.
  106398. * @hidden
  106399. */
  106400. _detachCameras(cameras: Camera[]): void;
  106401. /**
  106402. * Enables the effect on given cameras
  106403. * @param cameras The camera to enable.
  106404. * @hidden
  106405. */
  106406. _enable(cameras: Camera): void;
  106407. /**
  106408. * Enables the effect on given cameras
  106409. * @param cameras The camera to enable.
  106410. * @hidden
  106411. */
  106412. _enable(cameras: Nullable<Camera[]>): void;
  106413. /**
  106414. * Disables the effect on the given cameras
  106415. * @param cameras The camera to disable.
  106416. * @hidden
  106417. */
  106418. _disable(cameras: Camera): void;
  106419. /**
  106420. * Disables the effect on the given cameras
  106421. * @param cameras The camera to disable.
  106422. * @hidden
  106423. */
  106424. _disable(cameras: Nullable<Camera[]>): void;
  106425. /**
  106426. * Gets a list of the post processes contained in the effect.
  106427. * @param camera The camera to get the post processes on.
  106428. * @returns The list of the post processes in the effect.
  106429. */
  106430. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  106431. }
  106432. }
  106433. declare module BABYLON {
  106434. /** @hidden */
  106435. export var extractHighlightsPixelShader: {
  106436. name: string;
  106437. shader: string;
  106438. };
  106439. }
  106440. declare module BABYLON {
  106441. /**
  106442. * 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.
  106443. */
  106444. export class ExtractHighlightsPostProcess extends PostProcess {
  106445. /**
  106446. * The luminance threshold, pixels below this value will be set to black.
  106447. */
  106448. threshold: number;
  106449. /** @hidden */
  106450. _exposure: number;
  106451. /**
  106452. * Post process which has the input texture to be used when performing highlight extraction
  106453. * @hidden
  106454. */
  106455. _inputPostProcess: Nullable<PostProcess>;
  106456. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106457. }
  106458. }
  106459. declare module BABYLON {
  106460. /** @hidden */
  106461. export var bloomMergePixelShader: {
  106462. name: string;
  106463. shader: string;
  106464. };
  106465. }
  106466. declare module BABYLON {
  106467. /**
  106468. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106469. */
  106470. export class BloomMergePostProcess extends PostProcess {
  106471. /** Weight of the bloom to be added to the original input. */
  106472. weight: number;
  106473. /**
  106474. * Creates a new instance of @see BloomMergePostProcess
  106475. * @param name The name of the effect.
  106476. * @param originalFromInput Post process which's input will be used for the merge.
  106477. * @param blurred Blurred highlights post process which's output will be used.
  106478. * @param weight Weight of the bloom to be added to the original input.
  106479. * @param options The required width/height ratio to downsize to before computing the render pass.
  106480. * @param camera The camera to apply the render pass to.
  106481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106482. * @param engine The engine which the post process will be applied. (default: current engine)
  106483. * @param reusable If the post process can be reused on the same frame. (default: false)
  106484. * @param textureType Type of textures used when performing the post process. (default: 0)
  106485. * @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)
  106486. */
  106487. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  106488. /** Weight of the bloom to be added to the original input. */
  106489. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106490. }
  106491. }
  106492. declare module BABYLON {
  106493. /**
  106494. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  106495. */
  106496. export class BloomEffect extends PostProcessRenderEffect {
  106497. private bloomScale;
  106498. /**
  106499. * @hidden Internal
  106500. */
  106501. _effects: Array<PostProcess>;
  106502. /**
  106503. * @hidden Internal
  106504. */
  106505. _downscale: ExtractHighlightsPostProcess;
  106506. private _blurX;
  106507. private _blurY;
  106508. private _merge;
  106509. /**
  106510. * The luminance threshold to find bright areas of the image to bloom.
  106511. */
  106512. threshold: number;
  106513. /**
  106514. * The strength of the bloom.
  106515. */
  106516. weight: number;
  106517. /**
  106518. * Specifies the size of the bloom blur kernel, relative to the final output size
  106519. */
  106520. kernel: number;
  106521. /**
  106522. * Creates a new instance of @see BloomEffect
  106523. * @param scene The scene the effect belongs to.
  106524. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  106525. * @param bloomKernel The size of the kernel to be used when applying the blur.
  106526. * @param bloomWeight The the strength of bloom.
  106527. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106528. * @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)
  106529. */
  106530. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  106531. /**
  106532. * Disposes each of the internal effects for a given camera.
  106533. * @param camera The camera to dispose the effect on.
  106534. */
  106535. disposeEffects(camera: Camera): void;
  106536. /**
  106537. * @hidden Internal
  106538. */
  106539. _updateEffects(): void;
  106540. /**
  106541. * Internal
  106542. * @returns if all the contained post processes are ready.
  106543. * @hidden
  106544. */
  106545. _isReady(): boolean;
  106546. }
  106547. }
  106548. declare module BABYLON {
  106549. /** @hidden */
  106550. export var chromaticAberrationPixelShader: {
  106551. name: string;
  106552. shader: string;
  106553. };
  106554. }
  106555. declare module BABYLON {
  106556. /**
  106557. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  106558. */
  106559. export class ChromaticAberrationPostProcess extends PostProcess {
  106560. /**
  106561. * The amount of seperation of rgb channels (default: 30)
  106562. */
  106563. aberrationAmount: number;
  106564. /**
  106565. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  106566. */
  106567. radialIntensity: number;
  106568. /**
  106569. * 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))
  106570. */
  106571. direction: Vector2;
  106572. /**
  106573. * 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))
  106574. */
  106575. centerPosition: Vector2;
  106576. /**
  106577. * Creates a new instance ChromaticAberrationPostProcess
  106578. * @param name The name of the effect.
  106579. * @param screenWidth The width of the screen to apply the effect on.
  106580. * @param screenHeight The height of the screen to apply the effect on.
  106581. * @param options The required width/height ratio to downsize to before computing the render pass.
  106582. * @param camera The camera to apply the render pass to.
  106583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106584. * @param engine The engine which the post process will be applied. (default: current engine)
  106585. * @param reusable If the post process can be reused on the same frame. (default: false)
  106586. * @param textureType Type of textures used when performing the post process. (default: 0)
  106587. * @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)
  106588. */
  106589. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106590. }
  106591. }
  106592. declare module BABYLON {
  106593. /** @hidden */
  106594. export var circleOfConfusionPixelShader: {
  106595. name: string;
  106596. shader: string;
  106597. };
  106598. }
  106599. declare module BABYLON {
  106600. /**
  106601. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  106602. */
  106603. export class CircleOfConfusionPostProcess extends PostProcess {
  106604. /**
  106605. * 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.
  106606. */
  106607. lensSize: number;
  106608. /**
  106609. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106610. */
  106611. fStop: number;
  106612. /**
  106613. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106614. */
  106615. focusDistance: number;
  106616. /**
  106617. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  106618. */
  106619. focalLength: number;
  106620. private _depthTexture;
  106621. /**
  106622. * Creates a new instance CircleOfConfusionPostProcess
  106623. * @param name The name of the effect.
  106624. * @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.
  106625. * @param options The required width/height ratio to downsize to before computing the render pass.
  106626. * @param camera The camera to apply the render pass to.
  106627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106628. * @param engine The engine which the post process will be applied. (default: current engine)
  106629. * @param reusable If the post process can be reused on the same frame. (default: false)
  106630. * @param textureType Type of textures used when performing the post process. (default: 0)
  106631. * @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)
  106632. */
  106633. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106634. /**
  106635. * 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.
  106636. */
  106637. depthTexture: RenderTargetTexture;
  106638. }
  106639. }
  106640. declare module BABYLON {
  106641. /** @hidden */
  106642. export var colorCorrectionPixelShader: {
  106643. name: string;
  106644. shader: string;
  106645. };
  106646. }
  106647. declare module BABYLON {
  106648. /**
  106649. *
  106650. * This post-process allows the modification of rendered colors by using
  106651. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106652. *
  106653. * The object needs to be provided an url to a texture containing the color
  106654. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106655. * Use an image editing software to tweak the LUT to match your needs.
  106656. *
  106657. * For an example of a color LUT, see here:
  106658. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106659. * For explanations on color grading, see here:
  106660. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106661. *
  106662. */
  106663. export class ColorCorrectionPostProcess extends PostProcess {
  106664. private _colorTableTexture;
  106665. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106666. }
  106667. }
  106668. declare module BABYLON {
  106669. /** @hidden */
  106670. export var convolutionPixelShader: {
  106671. name: string;
  106672. shader: string;
  106673. };
  106674. }
  106675. declare module BABYLON {
  106676. /**
  106677. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106678. * input texture to perform effects such as edge detection or sharpening
  106679. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106680. */
  106681. export class ConvolutionPostProcess extends PostProcess {
  106682. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106683. kernel: number[];
  106684. /**
  106685. * Creates a new instance ConvolutionPostProcess
  106686. * @param name The name of the effect.
  106687. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106688. * @param options The required width/height ratio to downsize to before computing the render pass.
  106689. * @param camera The camera to apply the render pass to.
  106690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106691. * @param engine The engine which the post process will be applied. (default: current engine)
  106692. * @param reusable If the post process can be reused on the same frame. (default: false)
  106693. * @param textureType Type of textures used when performing the post process. (default: 0)
  106694. */
  106695. constructor(name: string,
  106696. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106697. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106698. /**
  106699. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106700. */
  106701. static EdgeDetect0Kernel: number[];
  106702. /**
  106703. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106704. */
  106705. static EdgeDetect1Kernel: number[];
  106706. /**
  106707. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106708. */
  106709. static EdgeDetect2Kernel: number[];
  106710. /**
  106711. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106712. */
  106713. static SharpenKernel: number[];
  106714. /**
  106715. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106716. */
  106717. static EmbossKernel: number[];
  106718. /**
  106719. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106720. */
  106721. static GaussianKernel: number[];
  106722. }
  106723. }
  106724. declare module BABYLON {
  106725. /**
  106726. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106727. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106728. * based on samples that have a large difference in distance than the center pixel.
  106729. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106730. */
  106731. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106732. direction: Vector2;
  106733. /**
  106734. * Creates a new instance CircleOfConfusionPostProcess
  106735. * @param name The name of the effect.
  106736. * @param scene The scene the effect belongs to.
  106737. * @param direction The direction the blur should be applied.
  106738. * @param kernel The size of the kernel used to blur.
  106739. * @param options The required width/height ratio to downsize to before computing the render pass.
  106740. * @param camera The camera to apply the render pass to.
  106741. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106742. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106744. * @param engine The engine which the post process will be applied. (default: current engine)
  106745. * @param reusable If the post process can be reused on the same frame. (default: false)
  106746. * @param textureType Type of textures used when performing the post process. (default: 0)
  106747. * @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)
  106748. */
  106749. 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);
  106750. }
  106751. }
  106752. declare module BABYLON {
  106753. /** @hidden */
  106754. export var depthOfFieldMergePixelShader: {
  106755. name: string;
  106756. shader: string;
  106757. };
  106758. }
  106759. declare module BABYLON {
  106760. /**
  106761. * Options to be set when merging outputs from the default pipeline.
  106762. */
  106763. export class DepthOfFieldMergePostProcessOptions {
  106764. /**
  106765. * The original image to merge on top of
  106766. */
  106767. originalFromInput: PostProcess;
  106768. /**
  106769. * Parameters to perform the merge of the depth of field effect
  106770. */
  106771. depthOfField?: {
  106772. circleOfConfusion: PostProcess;
  106773. blurSteps: Array<PostProcess>;
  106774. };
  106775. /**
  106776. * Parameters to perform the merge of bloom effect
  106777. */
  106778. bloom?: {
  106779. blurred: PostProcess;
  106780. weight: number;
  106781. };
  106782. }
  106783. /**
  106784. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106785. */
  106786. export class DepthOfFieldMergePostProcess extends PostProcess {
  106787. private blurSteps;
  106788. /**
  106789. * Creates a new instance of DepthOfFieldMergePostProcess
  106790. * @param name The name of the effect.
  106791. * @param originalFromInput Post process which's input will be used for the merge.
  106792. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106793. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106794. * @param options The required width/height ratio to downsize to before computing the render pass.
  106795. * @param camera The camera to apply the render pass to.
  106796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106797. * @param engine The engine which the post process will be applied. (default: current engine)
  106798. * @param reusable If the post process can be reused on the same frame. (default: false)
  106799. * @param textureType Type of textures used when performing the post process. (default: 0)
  106800. * @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)
  106801. */
  106802. 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);
  106803. /**
  106804. * Updates the effect with the current post process compile time values and recompiles the shader.
  106805. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106806. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106807. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106808. * @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
  106809. * @param onCompiled Called when the shader has been compiled.
  106810. * @param onError Called if there is an error when compiling a shader.
  106811. */
  106812. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106813. }
  106814. }
  106815. declare module BABYLON {
  106816. /**
  106817. * Specifies the level of max blur that should be applied when using the depth of field effect
  106818. */
  106819. export enum DepthOfFieldEffectBlurLevel {
  106820. /**
  106821. * Subtle blur
  106822. */
  106823. Low = 0,
  106824. /**
  106825. * Medium blur
  106826. */
  106827. Medium = 1,
  106828. /**
  106829. * Large blur
  106830. */
  106831. High = 2
  106832. }
  106833. /**
  106834. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106835. */
  106836. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106837. private _circleOfConfusion;
  106838. /**
  106839. * @hidden Internal, blurs from high to low
  106840. */
  106841. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106842. private _depthOfFieldBlurY;
  106843. private _dofMerge;
  106844. /**
  106845. * @hidden Internal post processes in depth of field effect
  106846. */
  106847. _effects: Array<PostProcess>;
  106848. /**
  106849. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106850. */
  106851. focalLength: number;
  106852. /**
  106853. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106854. */
  106855. fStop: number;
  106856. /**
  106857. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106858. */
  106859. focusDistance: number;
  106860. /**
  106861. * 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.
  106862. */
  106863. lensSize: number;
  106864. /**
  106865. * Creates a new instance DepthOfFieldEffect
  106866. * @param scene The scene the effect belongs to.
  106867. * @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.
  106868. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106869. * @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)
  106870. */
  106871. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106872. /**
  106873. * 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.
  106874. */
  106875. depthTexture: RenderTargetTexture;
  106876. /**
  106877. * Disposes each of the internal effects for a given camera.
  106878. * @param camera The camera to dispose the effect on.
  106879. */
  106880. disposeEffects(camera: Camera): void;
  106881. /**
  106882. * @hidden Internal
  106883. */
  106884. _updateEffects(): void;
  106885. /**
  106886. * Internal
  106887. * @returns if all the contained post processes are ready.
  106888. * @hidden
  106889. */
  106890. _isReady(): boolean;
  106891. }
  106892. }
  106893. declare module BABYLON {
  106894. /** @hidden */
  106895. export var displayPassPixelShader: {
  106896. name: string;
  106897. shader: string;
  106898. };
  106899. }
  106900. declare module BABYLON {
  106901. /**
  106902. * DisplayPassPostProcess which produces an output the same as it's input
  106903. */
  106904. export class DisplayPassPostProcess extends PostProcess {
  106905. /**
  106906. * Creates the DisplayPassPostProcess
  106907. * @param name The name of the effect.
  106908. * @param options The required width/height ratio to downsize to before computing the render pass.
  106909. * @param camera The camera to apply the render pass to.
  106910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106911. * @param engine The engine which the post process will be applied. (default: current engine)
  106912. * @param reusable If the post process can be reused on the same frame. (default: false)
  106913. */
  106914. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106915. }
  106916. }
  106917. declare module BABYLON {
  106918. /** @hidden */
  106919. export var filterPixelShader: {
  106920. name: string;
  106921. shader: string;
  106922. };
  106923. }
  106924. declare module BABYLON {
  106925. /**
  106926. * Applies a kernel filter to the image
  106927. */
  106928. export class FilterPostProcess extends PostProcess {
  106929. /** The matrix to be applied to the image */
  106930. kernelMatrix: Matrix;
  106931. /**
  106932. *
  106933. * @param name The name of the effect.
  106934. * @param kernelMatrix The matrix to be applied to the image
  106935. * @param options The required width/height ratio to downsize to before computing the render pass.
  106936. * @param camera The camera to apply the render pass to.
  106937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106938. * @param engine The engine which the post process will be applied. (default: current engine)
  106939. * @param reusable If the post process can be reused on the same frame. (default: false)
  106940. */
  106941. constructor(name: string,
  106942. /** The matrix to be applied to the image */
  106943. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106944. }
  106945. }
  106946. declare module BABYLON {
  106947. /** @hidden */
  106948. export var fxaaPixelShader: {
  106949. name: string;
  106950. shader: string;
  106951. };
  106952. }
  106953. declare module BABYLON {
  106954. /** @hidden */
  106955. export var fxaaVertexShader: {
  106956. name: string;
  106957. shader: string;
  106958. };
  106959. }
  106960. declare module BABYLON {
  106961. /**
  106962. * Fxaa post process
  106963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106964. */
  106965. export class FxaaPostProcess extends PostProcess {
  106966. /** @hidden */
  106967. texelWidth: number;
  106968. /** @hidden */
  106969. texelHeight: number;
  106970. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106971. private _getDefines;
  106972. }
  106973. }
  106974. declare module BABYLON {
  106975. /** @hidden */
  106976. export var grainPixelShader: {
  106977. name: string;
  106978. shader: string;
  106979. };
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * The GrainPostProcess adds noise to the image at mid luminance levels
  106984. */
  106985. export class GrainPostProcess extends PostProcess {
  106986. /**
  106987. * The intensity of the grain added (default: 30)
  106988. */
  106989. intensity: number;
  106990. /**
  106991. * If the grain should be randomized on every frame
  106992. */
  106993. animated: boolean;
  106994. /**
  106995. * Creates a new instance of @see GrainPostProcess
  106996. * @param name The name of the effect.
  106997. * @param options The required width/height ratio to downsize to before computing the render pass.
  106998. * @param camera The camera to apply the render pass to.
  106999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107000. * @param engine The engine which the post process will be applied. (default: current engine)
  107001. * @param reusable If the post process can be reused on the same frame. (default: false)
  107002. * @param textureType Type of textures used when performing the post process. (default: 0)
  107003. * @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)
  107004. */
  107005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107006. }
  107007. }
  107008. declare module BABYLON {
  107009. /** @hidden */
  107010. export var highlightsPixelShader: {
  107011. name: string;
  107012. shader: string;
  107013. };
  107014. }
  107015. declare module BABYLON {
  107016. /**
  107017. * Extracts highlights from the image
  107018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107019. */
  107020. export class HighlightsPostProcess extends PostProcess {
  107021. /**
  107022. * Extracts highlights from the image
  107023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107024. * @param name The name of the effect.
  107025. * @param options The required width/height ratio to downsize to before computing the render pass.
  107026. * @param camera The camera to apply the render pass to.
  107027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107028. * @param engine The engine which the post process will be applied. (default: current engine)
  107029. * @param reusable If the post process can be reused on the same frame. (default: false)
  107030. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  107031. */
  107032. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107033. }
  107034. }
  107035. declare module BABYLON {
  107036. /** @hidden */
  107037. export var mrtFragmentDeclaration: {
  107038. name: string;
  107039. shader: string;
  107040. };
  107041. }
  107042. declare module BABYLON {
  107043. /** @hidden */
  107044. export var geometryPixelShader: {
  107045. name: string;
  107046. shader: string;
  107047. };
  107048. }
  107049. declare module BABYLON {
  107050. /** @hidden */
  107051. export var geometryVertexShader: {
  107052. name: string;
  107053. shader: string;
  107054. };
  107055. }
  107056. declare module BABYLON {
  107057. /**
  107058. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107059. */
  107060. export class GeometryBufferRenderer {
  107061. /**
  107062. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107063. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107064. */
  107065. static readonly POSITION_TEXTURE_TYPE: number;
  107066. /**
  107067. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107068. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107069. */
  107070. static readonly VELOCITY_TEXTURE_TYPE: number;
  107071. /**
  107072. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107073. * in order to compute objects velocities when enableVelocity is set to "true"
  107074. * @hidden
  107075. */
  107076. _previousTransformationMatrices: {
  107077. [index: number]: Matrix;
  107078. };
  107079. private _scene;
  107080. private _multiRenderTarget;
  107081. private _ratio;
  107082. private _enablePosition;
  107083. private _enableVelocity;
  107084. private _positionIndex;
  107085. private _velocityIndex;
  107086. protected _effect: Effect;
  107087. protected _cachedDefines: string;
  107088. /**
  107089. * Set the render list (meshes to be rendered) used in the G buffer.
  107090. */
  107091. renderList: Mesh[];
  107092. /**
  107093. * Gets wether or not G buffer are supported by the running hardware.
  107094. * This requires draw buffer supports
  107095. */
  107096. readonly isSupported: boolean;
  107097. /**
  107098. * Returns the index of the given texture type in the G-Buffer textures array
  107099. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107100. * @returns the index of the given texture type in the G-Buffer textures array
  107101. */
  107102. getTextureIndex(textureType: number): number;
  107103. /**
  107104. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107105. */
  107106. /**
  107107. * Sets whether or not objects positions are enabled for the G buffer.
  107108. */
  107109. enablePosition: boolean;
  107110. /**
  107111. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107112. */
  107113. /**
  107114. * Sets wether or not objects velocities are enabled for the G buffer.
  107115. */
  107116. enableVelocity: boolean;
  107117. /**
  107118. * Gets the scene associated with the buffer.
  107119. */
  107120. readonly scene: Scene;
  107121. /**
  107122. * Gets the ratio used by the buffer during its creation.
  107123. * How big is the buffer related to the main canvas.
  107124. */
  107125. readonly ratio: number;
  107126. /** @hidden */
  107127. static _SceneComponentInitialization: (scene: Scene) => void;
  107128. /**
  107129. * Creates a new G Buffer for the scene
  107130. * @param scene The scene the buffer belongs to
  107131. * @param ratio How big is the buffer related to the main canvas.
  107132. */
  107133. constructor(scene: Scene, ratio?: number);
  107134. /**
  107135. * Checks wether everything is ready to render a submesh to the G buffer.
  107136. * @param subMesh the submesh to check readiness for
  107137. * @param useInstances is the mesh drawn using instance or not
  107138. * @returns true if ready otherwise false
  107139. */
  107140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107141. /**
  107142. * Gets the current underlying G Buffer.
  107143. * @returns the buffer
  107144. */
  107145. getGBuffer(): MultiRenderTarget;
  107146. /**
  107147. * Gets the number of samples used to render the buffer (anti aliasing).
  107148. */
  107149. /**
  107150. * Sets the number of samples used to render the buffer (anti aliasing).
  107151. */
  107152. samples: number;
  107153. /**
  107154. * Disposes the renderer and frees up associated resources.
  107155. */
  107156. dispose(): void;
  107157. protected _createRenderTargets(): void;
  107158. }
  107159. }
  107160. declare module BABYLON {
  107161. /** @hidden */
  107162. export var motionBlurPixelShader: {
  107163. name: string;
  107164. shader: string;
  107165. };
  107166. }
  107167. declare module BABYLON {
  107168. /**
  107169. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  107170. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  107171. * As an example, all you have to do is to create the post-process:
  107172. * var mb = new BABYLON.MotionBlurPostProcess(
  107173. * 'mb', // The name of the effect.
  107174. * scene, // The scene containing the objects to blur according to their velocity.
  107175. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  107176. * camera // The camera to apply the render pass to.
  107177. * );
  107178. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  107179. */
  107180. export class MotionBlurPostProcess extends PostProcess {
  107181. /**
  107182. * Defines how much the image is blurred by the movement. Default value is equal to 1
  107183. */
  107184. motionStrength: number;
  107185. /**
  107186. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  107187. */
  107188. /**
  107189. * Sets the number of iterations to be used for motion blur quality
  107190. */
  107191. motionBlurSamples: number;
  107192. private _motionBlurSamples;
  107193. private _geometryBufferRenderer;
  107194. /**
  107195. * Creates a new instance MotionBlurPostProcess
  107196. * @param name The name of the effect.
  107197. * @param scene The scene containing the objects to blur according to their velocity.
  107198. * @param options The required width/height ratio to downsize to before computing the render pass.
  107199. * @param camera The camera to apply the render pass to.
  107200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107201. * @param engine The engine which the post process will be applied. (default: current engine)
  107202. * @param reusable If the post process can be reused on the same frame. (default: false)
  107203. * @param textureType Type of textures used when performing the post process. (default: 0)
  107204. * @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)
  107205. */
  107206. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107207. /**
  107208. * Disposes the post process.
  107209. * @param camera The camera to dispose the post process on.
  107210. */
  107211. dispose(camera?: Camera): void;
  107212. }
  107213. }
  107214. declare module BABYLON {
  107215. /** @hidden */
  107216. export var refractionPixelShader: {
  107217. name: string;
  107218. shader: string;
  107219. };
  107220. }
  107221. declare module BABYLON {
  107222. /**
  107223. * Post process which applies a refractin texture
  107224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107225. */
  107226. export class RefractionPostProcess extends PostProcess {
  107227. /** the base color of the refraction (used to taint the rendering) */
  107228. color: Color3;
  107229. /** simulated refraction depth */
  107230. depth: number;
  107231. /** the coefficient of the base color (0 to remove base color tainting) */
  107232. colorLevel: number;
  107233. private _refTexture;
  107234. private _ownRefractionTexture;
  107235. /**
  107236. * Gets or sets the refraction texture
  107237. * Please note that you are responsible for disposing the texture if you set it manually
  107238. */
  107239. refractionTexture: Texture;
  107240. /**
  107241. * Initializes the RefractionPostProcess
  107242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107243. * @param name The name of the effect.
  107244. * @param refractionTextureUrl Url of the refraction texture to use
  107245. * @param color the base color of the refraction (used to taint the rendering)
  107246. * @param depth simulated refraction depth
  107247. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  107248. * @param camera The camera to apply the render pass to.
  107249. * @param options The required width/height ratio to downsize to before computing the render pass.
  107250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107251. * @param engine The engine which the post process will be applied. (default: current engine)
  107252. * @param reusable If the post process can be reused on the same frame. (default: false)
  107253. */
  107254. constructor(name: string, refractionTextureUrl: string,
  107255. /** the base color of the refraction (used to taint the rendering) */
  107256. color: Color3,
  107257. /** simulated refraction depth */
  107258. depth: number,
  107259. /** the coefficient of the base color (0 to remove base color tainting) */
  107260. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107261. /**
  107262. * Disposes of the post process
  107263. * @param camera Camera to dispose post process on
  107264. */
  107265. dispose(camera: Camera): void;
  107266. }
  107267. }
  107268. declare module BABYLON {
  107269. /** @hidden */
  107270. export var sharpenPixelShader: {
  107271. name: string;
  107272. shader: string;
  107273. };
  107274. }
  107275. declare module BABYLON {
  107276. /**
  107277. * The SharpenPostProcess applies a sharpen kernel to every pixel
  107278. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107279. */
  107280. export class SharpenPostProcess extends PostProcess {
  107281. /**
  107282. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  107283. */
  107284. colorAmount: number;
  107285. /**
  107286. * How much sharpness should be applied (default: 0.3)
  107287. */
  107288. edgeAmount: number;
  107289. /**
  107290. * Creates a new instance ConvolutionPostProcess
  107291. * @param name The name of the effect.
  107292. * @param options The required width/height ratio to downsize to before computing the render pass.
  107293. * @param camera The camera to apply the render pass to.
  107294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107295. * @param engine The engine which the post process will be applied. (default: current engine)
  107296. * @param reusable If the post process can be reused on the same frame. (default: false)
  107297. * @param textureType Type of textures used when performing the post process. (default: 0)
  107298. * @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)
  107299. */
  107300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107301. }
  107302. }
  107303. declare module BABYLON {
  107304. /**
  107305. * PostProcessRenderPipeline
  107306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107307. */
  107308. export class PostProcessRenderPipeline {
  107309. private engine;
  107310. private _renderEffects;
  107311. private _renderEffectsForIsolatedPass;
  107312. /**
  107313. * @hidden
  107314. */
  107315. protected _cameras: Camera[];
  107316. /** @hidden */
  107317. _name: string;
  107318. /**
  107319. * Gets pipeline name
  107320. */
  107321. readonly name: string;
  107322. /**
  107323. * Initializes a PostProcessRenderPipeline
  107324. * @param engine engine to add the pipeline to
  107325. * @param name name of the pipeline
  107326. */
  107327. constructor(engine: Engine, name: string);
  107328. /**
  107329. * Gets the class name
  107330. * @returns "PostProcessRenderPipeline"
  107331. */
  107332. getClassName(): string;
  107333. /**
  107334. * If all the render effects in the pipeline are supported
  107335. */
  107336. readonly isSupported: boolean;
  107337. /**
  107338. * Adds an effect to the pipeline
  107339. * @param renderEffect the effect to add
  107340. */
  107341. addEffect(renderEffect: PostProcessRenderEffect): void;
  107342. /** @hidden */
  107343. _rebuild(): void;
  107344. /** @hidden */
  107345. _enableEffect(renderEffectName: string, cameras: Camera): void;
  107346. /** @hidden */
  107347. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  107348. /** @hidden */
  107349. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107350. /** @hidden */
  107351. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107352. /** @hidden */
  107353. _attachCameras(cameras: Camera, unique: boolean): void;
  107354. /** @hidden */
  107355. _attachCameras(cameras: Camera[], unique: boolean): void;
  107356. /** @hidden */
  107357. _detachCameras(cameras: Camera): void;
  107358. /** @hidden */
  107359. _detachCameras(cameras: Nullable<Camera[]>): void;
  107360. /** @hidden */
  107361. _update(): void;
  107362. /** @hidden */
  107363. _reset(): void;
  107364. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  107365. /**
  107366. * Disposes of the pipeline
  107367. */
  107368. dispose(): void;
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /**
  107373. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  107374. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107375. */
  107376. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107377. private _scene;
  107378. private _camerasToBeAttached;
  107379. /**
  107380. * ID of the sharpen post process,
  107381. */
  107382. private readonly SharpenPostProcessId;
  107383. /**
  107384. * @ignore
  107385. * ID of the image processing post process;
  107386. */
  107387. readonly ImageProcessingPostProcessId: string;
  107388. /**
  107389. * @ignore
  107390. * ID of the Fast Approximate Anti-Aliasing post process;
  107391. */
  107392. readonly FxaaPostProcessId: string;
  107393. /**
  107394. * ID of the chromatic aberration post process,
  107395. */
  107396. private readonly ChromaticAberrationPostProcessId;
  107397. /**
  107398. * ID of the grain post process
  107399. */
  107400. private readonly GrainPostProcessId;
  107401. /**
  107402. * Sharpen post process which will apply a sharpen convolution to enhance edges
  107403. */
  107404. sharpen: SharpenPostProcess;
  107405. private _sharpenEffect;
  107406. private bloom;
  107407. /**
  107408. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  107409. */
  107410. depthOfField: DepthOfFieldEffect;
  107411. /**
  107412. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107413. */
  107414. fxaa: FxaaPostProcess;
  107415. /**
  107416. * Image post processing pass used to perform operations such as tone mapping or color grading.
  107417. */
  107418. imageProcessing: ImageProcessingPostProcess;
  107419. /**
  107420. * Chromatic aberration post process which will shift rgb colors in the image
  107421. */
  107422. chromaticAberration: ChromaticAberrationPostProcess;
  107423. private _chromaticAberrationEffect;
  107424. /**
  107425. * Grain post process which add noise to the image
  107426. */
  107427. grain: GrainPostProcess;
  107428. private _grainEffect;
  107429. /**
  107430. * Glow post process which adds a glow to emissive areas of the image
  107431. */
  107432. private _glowLayer;
  107433. /**
  107434. * Animations which can be used to tweak settings over a period of time
  107435. */
  107436. animations: Animation[];
  107437. private _imageProcessingConfigurationObserver;
  107438. private _sharpenEnabled;
  107439. private _bloomEnabled;
  107440. private _depthOfFieldEnabled;
  107441. private _depthOfFieldBlurLevel;
  107442. private _fxaaEnabled;
  107443. private _imageProcessingEnabled;
  107444. private _defaultPipelineTextureType;
  107445. private _bloomScale;
  107446. private _chromaticAberrationEnabled;
  107447. private _grainEnabled;
  107448. private _buildAllowed;
  107449. /**
  107450. * Gets active scene
  107451. */
  107452. readonly scene: Scene;
  107453. /**
  107454. * Enable or disable the sharpen process from the pipeline
  107455. */
  107456. sharpenEnabled: boolean;
  107457. private _resizeObserver;
  107458. private _hardwareScaleLevel;
  107459. private _bloomKernel;
  107460. /**
  107461. * Specifies the size of the bloom blur kernel, relative to the final output size
  107462. */
  107463. bloomKernel: number;
  107464. /**
  107465. * Specifies the weight of the bloom in the final rendering
  107466. */
  107467. private _bloomWeight;
  107468. /**
  107469. * Specifies the luma threshold for the area that will be blurred by the bloom
  107470. */
  107471. private _bloomThreshold;
  107472. private _hdr;
  107473. /**
  107474. * The strength of the bloom.
  107475. */
  107476. bloomWeight: number;
  107477. /**
  107478. * The strength of the bloom.
  107479. */
  107480. bloomThreshold: number;
  107481. /**
  107482. * The scale of the bloom, lower value will provide better performance.
  107483. */
  107484. bloomScale: number;
  107485. /**
  107486. * Enable or disable the bloom from the pipeline
  107487. */
  107488. bloomEnabled: boolean;
  107489. private _rebuildBloom;
  107490. /**
  107491. * If the depth of field is enabled.
  107492. */
  107493. depthOfFieldEnabled: boolean;
  107494. /**
  107495. * Blur level of the depth of field effect. (Higher blur will effect performance)
  107496. */
  107497. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  107498. /**
  107499. * If the anti aliasing is enabled.
  107500. */
  107501. fxaaEnabled: boolean;
  107502. private _samples;
  107503. /**
  107504. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107505. */
  107506. samples: number;
  107507. /**
  107508. * If image processing is enabled.
  107509. */
  107510. imageProcessingEnabled: boolean;
  107511. /**
  107512. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  107513. */
  107514. glowLayerEnabled: boolean;
  107515. /**
  107516. * Enable or disable the chromaticAberration process from the pipeline
  107517. */
  107518. chromaticAberrationEnabled: boolean;
  107519. /**
  107520. * Enable or disable the grain process from the pipeline
  107521. */
  107522. grainEnabled: boolean;
  107523. /**
  107524. * @constructor
  107525. * @param name - The rendering pipeline name (default: "")
  107526. * @param hdr - If high dynamic range textures should be used (default: true)
  107527. * @param scene - The scene linked to this pipeline (default: the last created scene)
  107528. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  107529. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  107530. */
  107531. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  107532. /**
  107533. * Get the class name
  107534. * @returns "DefaultRenderingPipeline"
  107535. */
  107536. getClassName(): string;
  107537. /**
  107538. * Force the compilation of the entire pipeline.
  107539. */
  107540. prepare(): void;
  107541. private _hasCleared;
  107542. private _prevPostProcess;
  107543. private _prevPrevPostProcess;
  107544. private _setAutoClearAndTextureSharing;
  107545. private _depthOfFieldSceneObserver;
  107546. private _buildPipeline;
  107547. private _disposePostProcesses;
  107548. /**
  107549. * Adds a camera to the pipeline
  107550. * @param camera the camera to be added
  107551. */
  107552. addCamera(camera: Camera): void;
  107553. /**
  107554. * Removes a camera from the pipeline
  107555. * @param camera the camera to remove
  107556. */
  107557. removeCamera(camera: Camera): void;
  107558. /**
  107559. * Dispose of the pipeline and stop all post processes
  107560. */
  107561. dispose(): void;
  107562. /**
  107563. * Serialize the rendering pipeline (Used when exporting)
  107564. * @returns the serialized object
  107565. */
  107566. serialize(): any;
  107567. /**
  107568. * Parse the serialized pipeline
  107569. * @param source Source pipeline.
  107570. * @param scene The scene to load the pipeline to.
  107571. * @param rootUrl The URL of the serialized pipeline.
  107572. * @returns An instantiated pipeline from the serialized object.
  107573. */
  107574. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  107575. }
  107576. }
  107577. declare module BABYLON {
  107578. /** @hidden */
  107579. export var lensHighlightsPixelShader: {
  107580. name: string;
  107581. shader: string;
  107582. };
  107583. }
  107584. declare module BABYLON {
  107585. /** @hidden */
  107586. export var depthOfFieldPixelShader: {
  107587. name: string;
  107588. shader: string;
  107589. };
  107590. }
  107591. declare module BABYLON {
  107592. /**
  107593. * BABYLON.JS Chromatic Aberration GLSL Shader
  107594. * Author: Olivier Guyot
  107595. * Separates very slightly R, G and B colors on the edges of the screen
  107596. * Inspired by Francois Tarlier & Martins Upitis
  107597. */
  107598. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  107599. /**
  107600. * @ignore
  107601. * The chromatic aberration PostProcess id in the pipeline
  107602. */
  107603. LensChromaticAberrationEffect: string;
  107604. /**
  107605. * @ignore
  107606. * The highlights enhancing PostProcess id in the pipeline
  107607. */
  107608. HighlightsEnhancingEffect: string;
  107609. /**
  107610. * @ignore
  107611. * The depth-of-field PostProcess id in the pipeline
  107612. */
  107613. LensDepthOfFieldEffect: string;
  107614. private _scene;
  107615. private _depthTexture;
  107616. private _grainTexture;
  107617. private _chromaticAberrationPostProcess;
  107618. private _highlightsPostProcess;
  107619. private _depthOfFieldPostProcess;
  107620. private _edgeBlur;
  107621. private _grainAmount;
  107622. private _chromaticAberration;
  107623. private _distortion;
  107624. private _highlightsGain;
  107625. private _highlightsThreshold;
  107626. private _dofDistance;
  107627. private _dofAperture;
  107628. private _dofDarken;
  107629. private _dofPentagon;
  107630. private _blurNoise;
  107631. /**
  107632. * @constructor
  107633. *
  107634. * Effect parameters are as follow:
  107635. * {
  107636. * chromatic_aberration: number; // from 0 to x (1 for realism)
  107637. * edge_blur: number; // from 0 to x (1 for realism)
  107638. * distortion: number; // from 0 to x (1 for realism)
  107639. * grain_amount: number; // from 0 to 1
  107640. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  107641. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  107642. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  107643. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  107644. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  107645. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107646. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107647. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107648. * }
  107649. * Note: if an effect parameter is unset, effect is disabled
  107650. *
  107651. * @param name The rendering pipeline name
  107652. * @param parameters - An object containing all parameters (see above)
  107653. * @param scene The scene linked to this pipeline
  107654. * @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)
  107655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107656. */
  107657. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107658. /**
  107659. * Sets the amount of blur at the edges
  107660. * @param amount blur amount
  107661. */
  107662. setEdgeBlur(amount: number): void;
  107663. /**
  107664. * Sets edge blur to 0
  107665. */
  107666. disableEdgeBlur(): void;
  107667. /**
  107668. * Sets the amout of grain
  107669. * @param amount Amount of grain
  107670. */
  107671. setGrainAmount(amount: number): void;
  107672. /**
  107673. * Set grain amount to 0
  107674. */
  107675. disableGrain(): void;
  107676. /**
  107677. * Sets the chromatic aberration amount
  107678. * @param amount amount of chromatic aberration
  107679. */
  107680. setChromaticAberration(amount: number): void;
  107681. /**
  107682. * Sets chromatic aberration amount to 0
  107683. */
  107684. disableChromaticAberration(): void;
  107685. /**
  107686. * Sets the EdgeDistortion amount
  107687. * @param amount amount of EdgeDistortion
  107688. */
  107689. setEdgeDistortion(amount: number): void;
  107690. /**
  107691. * Sets edge distortion to 0
  107692. */
  107693. disableEdgeDistortion(): void;
  107694. /**
  107695. * Sets the FocusDistance amount
  107696. * @param amount amount of FocusDistance
  107697. */
  107698. setFocusDistance(amount: number): void;
  107699. /**
  107700. * Disables depth of field
  107701. */
  107702. disableDepthOfField(): void;
  107703. /**
  107704. * Sets the Aperture amount
  107705. * @param amount amount of Aperture
  107706. */
  107707. setAperture(amount: number): void;
  107708. /**
  107709. * Sets the DarkenOutOfFocus amount
  107710. * @param amount amount of DarkenOutOfFocus
  107711. */
  107712. setDarkenOutOfFocus(amount: number): void;
  107713. /**
  107714. * Creates a pentagon bokeh effect
  107715. */
  107716. enablePentagonBokeh(): void;
  107717. /**
  107718. * Disables the pentagon bokeh effect
  107719. */
  107720. disablePentagonBokeh(): void;
  107721. /**
  107722. * Enables noise blur
  107723. */
  107724. enableNoiseBlur(): void;
  107725. /**
  107726. * Disables noise blur
  107727. */
  107728. disableNoiseBlur(): void;
  107729. /**
  107730. * Sets the HighlightsGain amount
  107731. * @param amount amount of HighlightsGain
  107732. */
  107733. setHighlightsGain(amount: number): void;
  107734. /**
  107735. * Sets the HighlightsThreshold amount
  107736. * @param amount amount of HighlightsThreshold
  107737. */
  107738. setHighlightsThreshold(amount: number): void;
  107739. /**
  107740. * Disables highlights
  107741. */
  107742. disableHighlights(): void;
  107743. /**
  107744. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107745. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107746. */
  107747. dispose(disableDepthRender?: boolean): void;
  107748. private _createChromaticAberrationPostProcess;
  107749. private _createHighlightsPostProcess;
  107750. private _createDepthOfFieldPostProcess;
  107751. private _createGrainTexture;
  107752. }
  107753. }
  107754. declare module BABYLON {
  107755. /** @hidden */
  107756. export var ssao2PixelShader: {
  107757. name: string;
  107758. shader: string;
  107759. };
  107760. }
  107761. declare module BABYLON {
  107762. /** @hidden */
  107763. export var ssaoCombinePixelShader: {
  107764. name: string;
  107765. shader: string;
  107766. };
  107767. }
  107768. declare module BABYLON {
  107769. /**
  107770. * Render pipeline to produce ssao effect
  107771. */
  107772. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107773. /**
  107774. * @ignore
  107775. * The PassPostProcess id in the pipeline that contains the original scene color
  107776. */
  107777. SSAOOriginalSceneColorEffect: string;
  107778. /**
  107779. * @ignore
  107780. * The SSAO PostProcess id in the pipeline
  107781. */
  107782. SSAORenderEffect: string;
  107783. /**
  107784. * @ignore
  107785. * The horizontal blur PostProcess id in the pipeline
  107786. */
  107787. SSAOBlurHRenderEffect: string;
  107788. /**
  107789. * @ignore
  107790. * The vertical blur PostProcess id in the pipeline
  107791. */
  107792. SSAOBlurVRenderEffect: string;
  107793. /**
  107794. * @ignore
  107795. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107796. */
  107797. SSAOCombineRenderEffect: string;
  107798. /**
  107799. * The output strength of the SSAO post-process. Default value is 1.0.
  107800. */
  107801. totalStrength: number;
  107802. /**
  107803. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107804. */
  107805. maxZ: number;
  107806. /**
  107807. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107808. */
  107809. minZAspect: number;
  107810. private _samples;
  107811. /**
  107812. * Number of samples used for the SSAO calculations. Default value is 8
  107813. */
  107814. samples: number;
  107815. private _textureSamples;
  107816. /**
  107817. * Number of samples to use for antialiasing
  107818. */
  107819. textureSamples: number;
  107820. /**
  107821. * Ratio object used for SSAO ratio and blur ratio
  107822. */
  107823. private _ratio;
  107824. /**
  107825. * Dynamically generated sphere sampler.
  107826. */
  107827. private _sampleSphere;
  107828. /**
  107829. * Blur filter offsets
  107830. */
  107831. private _samplerOffsets;
  107832. private _expensiveBlur;
  107833. /**
  107834. * If bilateral blur should be used
  107835. */
  107836. expensiveBlur: boolean;
  107837. /**
  107838. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107839. */
  107840. radius: number;
  107841. /**
  107842. * The base color of the SSAO post-process
  107843. * The final result is "base + ssao" between [0, 1]
  107844. */
  107845. base: number;
  107846. /**
  107847. * Support test.
  107848. */
  107849. static readonly IsSupported: boolean;
  107850. private _scene;
  107851. private _depthTexture;
  107852. private _normalTexture;
  107853. private _randomTexture;
  107854. private _originalColorPostProcess;
  107855. private _ssaoPostProcess;
  107856. private _blurHPostProcess;
  107857. private _blurVPostProcess;
  107858. private _ssaoCombinePostProcess;
  107859. private _firstUpdate;
  107860. /**
  107861. * Gets active scene
  107862. */
  107863. readonly scene: Scene;
  107864. /**
  107865. * @constructor
  107866. * @param name The rendering pipeline name
  107867. * @param scene The scene linked to this pipeline
  107868. * @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 }
  107869. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107870. */
  107871. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107872. /**
  107873. * Get the class name
  107874. * @returns "SSAO2RenderingPipeline"
  107875. */
  107876. getClassName(): string;
  107877. /**
  107878. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107879. */
  107880. dispose(disableGeometryBufferRenderer?: boolean): void;
  107881. private _createBlurPostProcess;
  107882. /** @hidden */
  107883. _rebuild(): void;
  107884. private _bits;
  107885. private _radicalInverse_VdC;
  107886. private _hammersley;
  107887. private _hemisphereSample_uniform;
  107888. private _generateHemisphere;
  107889. private _createSSAOPostProcess;
  107890. private _createSSAOCombinePostProcess;
  107891. private _createRandomTexture;
  107892. /**
  107893. * Serialize the rendering pipeline (Used when exporting)
  107894. * @returns the serialized object
  107895. */
  107896. serialize(): any;
  107897. /**
  107898. * Parse the serialized pipeline
  107899. * @param source Source pipeline.
  107900. * @param scene The scene to load the pipeline to.
  107901. * @param rootUrl The URL of the serialized pipeline.
  107902. * @returns An instantiated pipeline from the serialized object.
  107903. */
  107904. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107905. }
  107906. }
  107907. declare module BABYLON {
  107908. /** @hidden */
  107909. export var ssaoPixelShader: {
  107910. name: string;
  107911. shader: string;
  107912. };
  107913. }
  107914. declare module BABYLON {
  107915. /**
  107916. * Render pipeline to produce ssao effect
  107917. */
  107918. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107919. /**
  107920. * @ignore
  107921. * The PassPostProcess id in the pipeline that contains the original scene color
  107922. */
  107923. SSAOOriginalSceneColorEffect: string;
  107924. /**
  107925. * @ignore
  107926. * The SSAO PostProcess id in the pipeline
  107927. */
  107928. SSAORenderEffect: string;
  107929. /**
  107930. * @ignore
  107931. * The horizontal blur PostProcess id in the pipeline
  107932. */
  107933. SSAOBlurHRenderEffect: string;
  107934. /**
  107935. * @ignore
  107936. * The vertical blur PostProcess id in the pipeline
  107937. */
  107938. SSAOBlurVRenderEffect: string;
  107939. /**
  107940. * @ignore
  107941. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107942. */
  107943. SSAOCombineRenderEffect: string;
  107944. /**
  107945. * The output strength of the SSAO post-process. Default value is 1.0.
  107946. */
  107947. totalStrength: number;
  107948. /**
  107949. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107950. */
  107951. radius: number;
  107952. /**
  107953. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107954. * Must not be equal to fallOff and superior to fallOff.
  107955. * Default value is 0.0075
  107956. */
  107957. area: number;
  107958. /**
  107959. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107960. * Must not be equal to area and inferior to area.
  107961. * Default value is 0.000001
  107962. */
  107963. fallOff: number;
  107964. /**
  107965. * The base color of the SSAO post-process
  107966. * The final result is "base + ssao" between [0, 1]
  107967. */
  107968. base: number;
  107969. private _scene;
  107970. private _depthTexture;
  107971. private _randomTexture;
  107972. private _originalColorPostProcess;
  107973. private _ssaoPostProcess;
  107974. private _blurHPostProcess;
  107975. private _blurVPostProcess;
  107976. private _ssaoCombinePostProcess;
  107977. private _firstUpdate;
  107978. /**
  107979. * Gets active scene
  107980. */
  107981. readonly scene: Scene;
  107982. /**
  107983. * @constructor
  107984. * @param name - The rendering pipeline name
  107985. * @param scene - The scene linked to this pipeline
  107986. * @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 }
  107987. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107988. */
  107989. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107990. /**
  107991. * Get the class name
  107992. * @returns "SSAORenderingPipeline"
  107993. */
  107994. getClassName(): string;
  107995. /**
  107996. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107997. */
  107998. dispose(disableDepthRender?: boolean): void;
  107999. private _createBlurPostProcess;
  108000. /** @hidden */
  108001. _rebuild(): void;
  108002. private _createSSAOPostProcess;
  108003. private _createSSAOCombinePostProcess;
  108004. private _createRandomTexture;
  108005. }
  108006. }
  108007. declare module BABYLON {
  108008. /** @hidden */
  108009. export var standardPixelShader: {
  108010. name: string;
  108011. shader: string;
  108012. };
  108013. }
  108014. declare module BABYLON {
  108015. /**
  108016. * Standard rendering pipeline
  108017. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108018. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  108019. */
  108020. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108021. /**
  108022. * Public members
  108023. */
  108024. /**
  108025. * Post-process which contains the original scene color before the pipeline applies all the effects
  108026. */
  108027. originalPostProcess: Nullable<PostProcess>;
  108028. /**
  108029. * Post-process used to down scale an image x4
  108030. */
  108031. downSampleX4PostProcess: Nullable<PostProcess>;
  108032. /**
  108033. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  108034. */
  108035. brightPassPostProcess: Nullable<PostProcess>;
  108036. /**
  108037. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  108038. */
  108039. blurHPostProcesses: PostProcess[];
  108040. /**
  108041. * Post-process array storing all the vertical blur post-processes used by the pipeline
  108042. */
  108043. blurVPostProcesses: PostProcess[];
  108044. /**
  108045. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  108046. */
  108047. textureAdderPostProcess: Nullable<PostProcess>;
  108048. /**
  108049. * Post-process used to create volumetric lighting effect
  108050. */
  108051. volumetricLightPostProcess: Nullable<PostProcess>;
  108052. /**
  108053. * Post-process used to smooth the previous volumetric light post-process on the X axis
  108054. */
  108055. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  108056. /**
  108057. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  108058. */
  108059. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  108060. /**
  108061. * Post-process used to merge the volumetric light effect and the real scene color
  108062. */
  108063. volumetricLightMergePostProces: Nullable<PostProcess>;
  108064. /**
  108065. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  108066. */
  108067. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  108068. /**
  108069. * Base post-process used to calculate the average luminance of the final image for HDR
  108070. */
  108071. luminancePostProcess: Nullable<PostProcess>;
  108072. /**
  108073. * Post-processes used to create down sample post-processes in order to get
  108074. * the average luminance of the final image for HDR
  108075. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  108076. */
  108077. luminanceDownSamplePostProcesses: PostProcess[];
  108078. /**
  108079. * Post-process used to create a HDR effect (light adaptation)
  108080. */
  108081. hdrPostProcess: Nullable<PostProcess>;
  108082. /**
  108083. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  108084. */
  108085. textureAdderFinalPostProcess: Nullable<PostProcess>;
  108086. /**
  108087. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  108088. */
  108089. lensFlareFinalPostProcess: Nullable<PostProcess>;
  108090. /**
  108091. * Post-process used to merge the final HDR post-process and the real scene color
  108092. */
  108093. hdrFinalPostProcess: Nullable<PostProcess>;
  108094. /**
  108095. * Post-process used to create a lens flare effect
  108096. */
  108097. lensFlarePostProcess: Nullable<PostProcess>;
  108098. /**
  108099. * Post-process that merges the result of the lens flare post-process and the real scene color
  108100. */
  108101. lensFlareComposePostProcess: Nullable<PostProcess>;
  108102. /**
  108103. * Post-process used to create a motion blur effect
  108104. */
  108105. motionBlurPostProcess: Nullable<PostProcess>;
  108106. /**
  108107. * Post-process used to create a depth of field effect
  108108. */
  108109. depthOfFieldPostProcess: Nullable<PostProcess>;
  108110. /**
  108111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108112. */
  108113. fxaaPostProcess: Nullable<FxaaPostProcess>;
  108114. /**
  108115. * Represents the brightness threshold in order to configure the illuminated surfaces
  108116. */
  108117. brightThreshold: number;
  108118. /**
  108119. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  108120. */
  108121. blurWidth: number;
  108122. /**
  108123. * Sets if the blur for highlighted surfaces must be only horizontal
  108124. */
  108125. horizontalBlur: boolean;
  108126. /**
  108127. * Sets the overall exposure used by the pipeline
  108128. */
  108129. exposure: number;
  108130. /**
  108131. * Texture used typically to simulate "dirty" on camera lens
  108132. */
  108133. lensTexture: Nullable<Texture>;
  108134. /**
  108135. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  108136. */
  108137. volumetricLightCoefficient: number;
  108138. /**
  108139. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  108140. */
  108141. volumetricLightPower: number;
  108142. /**
  108143. * Used the set the blur intensity to smooth the volumetric lights
  108144. */
  108145. volumetricLightBlurScale: number;
  108146. /**
  108147. * Light (spot or directional) used to generate the volumetric lights rays
  108148. * The source light must have a shadow generate so the pipeline can get its
  108149. * depth map
  108150. */
  108151. sourceLight: Nullable<SpotLight | DirectionalLight>;
  108152. /**
  108153. * For eye adaptation, represents the minimum luminance the eye can see
  108154. */
  108155. hdrMinimumLuminance: number;
  108156. /**
  108157. * For eye adaptation, represents the decrease luminance speed
  108158. */
  108159. hdrDecreaseRate: number;
  108160. /**
  108161. * For eye adaptation, represents the increase luminance speed
  108162. */
  108163. hdrIncreaseRate: number;
  108164. /**
  108165. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  108166. */
  108167. lensColorTexture: Nullable<Texture>;
  108168. /**
  108169. * The overall strengh for the lens flare effect
  108170. */
  108171. lensFlareStrength: number;
  108172. /**
  108173. * Dispersion coefficient for lens flare ghosts
  108174. */
  108175. lensFlareGhostDispersal: number;
  108176. /**
  108177. * Main lens flare halo width
  108178. */
  108179. lensFlareHaloWidth: number;
  108180. /**
  108181. * Based on the lens distortion effect, defines how much the lens flare result
  108182. * is distorted
  108183. */
  108184. lensFlareDistortionStrength: number;
  108185. /**
  108186. * Lens star texture must be used to simulate rays on the flares and is available
  108187. * in the documentation
  108188. */
  108189. lensStarTexture: Nullable<Texture>;
  108190. /**
  108191. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  108192. * flare effect by taking account of the dirt texture
  108193. */
  108194. lensFlareDirtTexture: Nullable<Texture>;
  108195. /**
  108196. * Represents the focal length for the depth of field effect
  108197. */
  108198. depthOfFieldDistance: number;
  108199. /**
  108200. * Represents the blur intensity for the blurred part of the depth of field effect
  108201. */
  108202. depthOfFieldBlurWidth: number;
  108203. /**
  108204. * For motion blur, defines how much the image is blurred by the movement
  108205. */
  108206. motionStrength: number;
  108207. /**
  108208. * List of animations for the pipeline (IAnimatable implementation)
  108209. */
  108210. animations: Animation[];
  108211. /**
  108212. * Private members
  108213. */
  108214. private _scene;
  108215. private _currentDepthOfFieldSource;
  108216. private _basePostProcess;
  108217. private _hdrCurrentLuminance;
  108218. private _floatTextureType;
  108219. private _ratio;
  108220. private _bloomEnabled;
  108221. private _depthOfFieldEnabled;
  108222. private _vlsEnabled;
  108223. private _lensFlareEnabled;
  108224. private _hdrEnabled;
  108225. private _motionBlurEnabled;
  108226. private _fxaaEnabled;
  108227. private _motionBlurSamples;
  108228. private _volumetricLightStepsCount;
  108229. private _samples;
  108230. /**
  108231. * @ignore
  108232. * Specifies if the bloom pipeline is enabled
  108233. */
  108234. BloomEnabled: boolean;
  108235. /**
  108236. * @ignore
  108237. * Specifies if the depth of field pipeline is enabed
  108238. */
  108239. DepthOfFieldEnabled: boolean;
  108240. /**
  108241. * @ignore
  108242. * Specifies if the lens flare pipeline is enabed
  108243. */
  108244. LensFlareEnabled: boolean;
  108245. /**
  108246. * @ignore
  108247. * Specifies if the HDR pipeline is enabled
  108248. */
  108249. HDREnabled: boolean;
  108250. /**
  108251. * @ignore
  108252. * Specifies if the volumetric lights scattering effect is enabled
  108253. */
  108254. VLSEnabled: boolean;
  108255. /**
  108256. * @ignore
  108257. * Specifies if the motion blur effect is enabled
  108258. */
  108259. MotionBlurEnabled: boolean;
  108260. /**
  108261. * Specifies if anti-aliasing is enabled
  108262. */
  108263. fxaaEnabled: boolean;
  108264. /**
  108265. * Specifies the number of steps used to calculate the volumetric lights
  108266. * Typically in interval [50, 200]
  108267. */
  108268. volumetricLightStepsCount: number;
  108269. /**
  108270. * Specifies the number of samples used for the motion blur effect
  108271. * Typically in interval [16, 64]
  108272. */
  108273. motionBlurSamples: number;
  108274. /**
  108275. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108276. */
  108277. samples: number;
  108278. /**
  108279. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108280. * @constructor
  108281. * @param name The rendering pipeline name
  108282. * @param scene The scene linked to this pipeline
  108283. * @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)
  108284. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  108285. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108286. */
  108287. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  108288. private _buildPipeline;
  108289. private _createDownSampleX4PostProcess;
  108290. private _createBrightPassPostProcess;
  108291. private _createBlurPostProcesses;
  108292. private _createTextureAdderPostProcess;
  108293. private _createVolumetricLightPostProcess;
  108294. private _createLuminancePostProcesses;
  108295. private _createHdrPostProcess;
  108296. private _createLensFlarePostProcess;
  108297. private _createDepthOfFieldPostProcess;
  108298. private _createMotionBlurPostProcess;
  108299. private _getDepthTexture;
  108300. private _disposePostProcesses;
  108301. /**
  108302. * Dispose of the pipeline and stop all post processes
  108303. */
  108304. dispose(): void;
  108305. /**
  108306. * Serialize the rendering pipeline (Used when exporting)
  108307. * @returns the serialized object
  108308. */
  108309. serialize(): any;
  108310. /**
  108311. * Parse the serialized pipeline
  108312. * @param source Source pipeline.
  108313. * @param scene The scene to load the pipeline to.
  108314. * @param rootUrl The URL of the serialized pipeline.
  108315. * @returns An instantiated pipeline from the serialized object.
  108316. */
  108317. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  108318. /**
  108319. * Luminance steps
  108320. */
  108321. static LuminanceSteps: number;
  108322. }
  108323. }
  108324. declare module BABYLON {
  108325. /**
  108326. * PostProcessRenderPipelineManager class
  108327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108328. */
  108329. export class PostProcessRenderPipelineManager {
  108330. private _renderPipelines;
  108331. /**
  108332. * Initializes a PostProcessRenderPipelineManager
  108333. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108334. */
  108335. constructor();
  108336. /**
  108337. * Gets the list of supported render pipelines
  108338. */
  108339. readonly supportedPipelines: PostProcessRenderPipeline[];
  108340. /**
  108341. * Adds a pipeline to the manager
  108342. * @param renderPipeline The pipeline to add
  108343. */
  108344. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  108345. /**
  108346. * Attaches a camera to the pipeline
  108347. * @param renderPipelineName The name of the pipeline to attach to
  108348. * @param cameras the camera to attach
  108349. * @param unique if the camera can be attached multiple times to the pipeline
  108350. */
  108351. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  108352. /**
  108353. * Detaches a camera from the pipeline
  108354. * @param renderPipelineName The name of the pipeline to detach from
  108355. * @param cameras the camera to detach
  108356. */
  108357. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  108358. /**
  108359. * Enables an effect by name on a pipeline
  108360. * @param renderPipelineName the name of the pipeline to enable the effect in
  108361. * @param renderEffectName the name of the effect to enable
  108362. * @param cameras the cameras that the effect should be enabled on
  108363. */
  108364. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108365. /**
  108366. * Disables an effect by name on a pipeline
  108367. * @param renderPipelineName the name of the pipeline to disable the effect in
  108368. * @param renderEffectName the name of the effect to disable
  108369. * @param cameras the cameras that the effect should be disabled on
  108370. */
  108371. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108372. /**
  108373. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  108374. */
  108375. update(): void;
  108376. /** @hidden */
  108377. _rebuild(): void;
  108378. /**
  108379. * Disposes of the manager and pipelines
  108380. */
  108381. dispose(): void;
  108382. }
  108383. }
  108384. declare module BABYLON {
  108385. interface Scene {
  108386. /** @hidden (Backing field) */
  108387. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108388. /**
  108389. * Gets the postprocess render pipeline manager
  108390. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108391. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108392. */
  108393. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108394. }
  108395. /**
  108396. * Defines the Render Pipeline scene component responsible to rendering pipelines
  108397. */
  108398. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  108399. /**
  108400. * The component name helpfull to identify the component in the list of scene components.
  108401. */
  108402. readonly name: string;
  108403. /**
  108404. * The scene the component belongs to.
  108405. */
  108406. scene: Scene;
  108407. /**
  108408. * Creates a new instance of the component for the given scene
  108409. * @param scene Defines the scene to register the component in
  108410. */
  108411. constructor(scene: Scene);
  108412. /**
  108413. * Registers the component in a given scene
  108414. */
  108415. register(): void;
  108416. /**
  108417. * Rebuilds the elements related to this component in case of
  108418. * context lost for instance.
  108419. */
  108420. rebuild(): void;
  108421. /**
  108422. * Disposes the component and the associated ressources
  108423. */
  108424. dispose(): void;
  108425. private _gatherRenderTargets;
  108426. }
  108427. }
  108428. declare module BABYLON {
  108429. /** @hidden */
  108430. export var tonemapPixelShader: {
  108431. name: string;
  108432. shader: string;
  108433. };
  108434. }
  108435. declare module BABYLON {
  108436. /** Defines operator used for tonemapping */
  108437. export enum TonemappingOperator {
  108438. /** Hable */
  108439. Hable = 0,
  108440. /** Reinhard */
  108441. Reinhard = 1,
  108442. /** HejiDawson */
  108443. HejiDawson = 2,
  108444. /** Photographic */
  108445. Photographic = 3
  108446. }
  108447. /**
  108448. * Defines a post process to apply tone mapping
  108449. */
  108450. export class TonemapPostProcess extends PostProcess {
  108451. private _operator;
  108452. /** Defines the required exposure adjustement */
  108453. exposureAdjustment: number;
  108454. /**
  108455. * Creates a new TonemapPostProcess
  108456. * @param name defines the name of the postprocess
  108457. * @param _operator defines the operator to use
  108458. * @param exposureAdjustment defines the required exposure adjustement
  108459. * @param camera defines the camera to use (can be null)
  108460. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  108461. * @param engine defines the hosting engine (can be ignore if camera is set)
  108462. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108463. */
  108464. constructor(name: string, _operator: TonemappingOperator,
  108465. /** Defines the required exposure adjustement */
  108466. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  108467. }
  108468. }
  108469. declare module BABYLON {
  108470. /** @hidden */
  108471. export var depthVertexShader: {
  108472. name: string;
  108473. shader: string;
  108474. };
  108475. }
  108476. declare module BABYLON {
  108477. /** @hidden */
  108478. export var volumetricLightScatteringPixelShader: {
  108479. name: string;
  108480. shader: string;
  108481. };
  108482. }
  108483. declare module BABYLON {
  108484. /** @hidden */
  108485. export var volumetricLightScatteringPassPixelShader: {
  108486. name: string;
  108487. shader: string;
  108488. };
  108489. }
  108490. declare module BABYLON {
  108491. /**
  108492. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  108493. */
  108494. export class VolumetricLightScatteringPostProcess extends PostProcess {
  108495. private _volumetricLightScatteringPass;
  108496. private _volumetricLightScatteringRTT;
  108497. private _viewPort;
  108498. private _screenCoordinates;
  108499. private _cachedDefines;
  108500. /**
  108501. * If not undefined, the mesh position is computed from the attached node position
  108502. */
  108503. attachedNode: {
  108504. position: Vector3;
  108505. };
  108506. /**
  108507. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  108508. */
  108509. customMeshPosition: Vector3;
  108510. /**
  108511. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  108512. */
  108513. useCustomMeshPosition: boolean;
  108514. /**
  108515. * If the post-process should inverse the light scattering direction
  108516. */
  108517. invert: boolean;
  108518. /**
  108519. * The internal mesh used by the post-process
  108520. */
  108521. mesh: Mesh;
  108522. /**
  108523. * @hidden
  108524. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  108525. */
  108526. useDiffuseColor: boolean;
  108527. /**
  108528. * Array containing the excluded meshes not rendered in the internal pass
  108529. */
  108530. excludedMeshes: AbstractMesh[];
  108531. /**
  108532. * Controls the overall intensity of the post-process
  108533. */
  108534. exposure: number;
  108535. /**
  108536. * Dissipates each sample's contribution in range [0, 1]
  108537. */
  108538. decay: number;
  108539. /**
  108540. * Controls the overall intensity of each sample
  108541. */
  108542. weight: number;
  108543. /**
  108544. * Controls the density of each sample
  108545. */
  108546. density: number;
  108547. /**
  108548. * @constructor
  108549. * @param name The post-process name
  108550. * @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)
  108551. * @param camera The camera that the post-process will be attached to
  108552. * @param mesh The mesh used to create the light scattering
  108553. * @param samples The post-process quality, default 100
  108554. * @param samplingModeThe post-process filtering mode
  108555. * @param engine The babylon engine
  108556. * @param reusable If the post-process is reusable
  108557. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  108558. */
  108559. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  108560. /**
  108561. * Returns the string "VolumetricLightScatteringPostProcess"
  108562. * @returns "VolumetricLightScatteringPostProcess"
  108563. */
  108564. getClassName(): string;
  108565. private _isReady;
  108566. /**
  108567. * Sets the new light position for light scattering effect
  108568. * @param position The new custom light position
  108569. */
  108570. setCustomMeshPosition(position: Vector3): void;
  108571. /**
  108572. * Returns the light position for light scattering effect
  108573. * @return Vector3 The custom light position
  108574. */
  108575. getCustomMeshPosition(): Vector3;
  108576. /**
  108577. * Disposes the internal assets and detaches the post-process from the camera
  108578. */
  108579. dispose(camera: Camera): void;
  108580. /**
  108581. * Returns the render target texture used by the post-process
  108582. * @return the render target texture used by the post-process
  108583. */
  108584. getPass(): RenderTargetTexture;
  108585. private _meshExcluded;
  108586. private _createPass;
  108587. private _updateMeshScreenCoordinates;
  108588. /**
  108589. * Creates a default mesh for the Volumeric Light Scattering post-process
  108590. * @param name The mesh name
  108591. * @param scene The scene where to create the mesh
  108592. * @return the default mesh
  108593. */
  108594. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  108595. }
  108596. }
  108597. declare module BABYLON {
  108598. interface Scene {
  108599. /** @hidden (Backing field) */
  108600. _boundingBoxRenderer: BoundingBoxRenderer;
  108601. /** @hidden (Backing field) */
  108602. _forceShowBoundingBoxes: boolean;
  108603. /**
  108604. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  108605. */
  108606. forceShowBoundingBoxes: boolean;
  108607. /**
  108608. * Gets the bounding box renderer associated with the scene
  108609. * @returns a BoundingBoxRenderer
  108610. */
  108611. getBoundingBoxRenderer(): BoundingBoxRenderer;
  108612. }
  108613. interface AbstractMesh {
  108614. /** @hidden (Backing field) */
  108615. _showBoundingBox: boolean;
  108616. /**
  108617. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  108618. */
  108619. showBoundingBox: boolean;
  108620. }
  108621. /**
  108622. * Component responsible of rendering the bounding box of the meshes in a scene.
  108623. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  108624. */
  108625. export class BoundingBoxRenderer implements ISceneComponent {
  108626. /**
  108627. * The component name helpfull to identify the component in the list of scene components.
  108628. */
  108629. readonly name: string;
  108630. /**
  108631. * The scene the component belongs to.
  108632. */
  108633. scene: Scene;
  108634. /**
  108635. * Color of the bounding box lines placed in front of an object
  108636. */
  108637. frontColor: Color3;
  108638. /**
  108639. * Color of the bounding box lines placed behind an object
  108640. */
  108641. backColor: Color3;
  108642. /**
  108643. * Defines if the renderer should show the back lines or not
  108644. */
  108645. showBackLines: boolean;
  108646. /**
  108647. * @hidden
  108648. */
  108649. renderList: SmartArray<BoundingBox>;
  108650. private _colorShader;
  108651. private _vertexBuffers;
  108652. private _indexBuffer;
  108653. /**
  108654. * Instantiates a new bounding box renderer in a scene.
  108655. * @param scene the scene the renderer renders in
  108656. */
  108657. constructor(scene: Scene);
  108658. /**
  108659. * Registers the component in a given scene
  108660. */
  108661. register(): void;
  108662. private _evaluateSubMesh;
  108663. private _activeMesh;
  108664. private _prepareRessources;
  108665. private _createIndexBuffer;
  108666. /**
  108667. * Rebuilds the elements related to this component in case of
  108668. * context lost for instance.
  108669. */
  108670. rebuild(): void;
  108671. /**
  108672. * @hidden
  108673. */
  108674. reset(): void;
  108675. /**
  108676. * Render the bounding boxes of a specific rendering group
  108677. * @param renderingGroupId defines the rendering group to render
  108678. */
  108679. render(renderingGroupId: number): void;
  108680. /**
  108681. * In case of occlusion queries, we can render the occlusion bounding box through this method
  108682. * @param mesh Define the mesh to render the occlusion bounding box for
  108683. */
  108684. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  108685. /**
  108686. * Dispose and release the resources attached to this renderer.
  108687. */
  108688. dispose(): void;
  108689. }
  108690. }
  108691. declare module BABYLON {
  108692. /** @hidden */
  108693. export var depthPixelShader: {
  108694. name: string;
  108695. shader: string;
  108696. };
  108697. }
  108698. declare module BABYLON {
  108699. /**
  108700. * This represents a depth renderer in Babylon.
  108701. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108702. */
  108703. export class DepthRenderer {
  108704. private _scene;
  108705. private _depthMap;
  108706. private _effect;
  108707. private _cachedDefines;
  108708. private _camera;
  108709. /**
  108710. * Specifiess that the depth renderer will only be used within
  108711. * the camera it is created for.
  108712. * This can help forcing its rendering during the camera processing.
  108713. */
  108714. useOnlyInActiveCamera: boolean;
  108715. /** @hidden */
  108716. static _SceneComponentInitialization: (scene: Scene) => void;
  108717. /**
  108718. * Instantiates a depth renderer
  108719. * @param scene The scene the renderer belongs to
  108720. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108721. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108722. */
  108723. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108724. /**
  108725. * Creates the depth rendering effect and checks if the effect is ready.
  108726. * @param subMesh The submesh to be used to render the depth map of
  108727. * @param useInstances If multiple world instances should be used
  108728. * @returns if the depth renderer is ready to render the depth map
  108729. */
  108730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108731. /**
  108732. * Gets the texture which the depth map will be written to.
  108733. * @returns The depth map texture
  108734. */
  108735. getDepthMap(): RenderTargetTexture;
  108736. /**
  108737. * Disposes of the depth renderer.
  108738. */
  108739. dispose(): void;
  108740. }
  108741. }
  108742. declare module BABYLON {
  108743. interface Scene {
  108744. /** @hidden (Backing field) */
  108745. _depthRenderer: {
  108746. [id: string]: DepthRenderer;
  108747. };
  108748. /**
  108749. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108750. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108751. * @returns the created depth renderer
  108752. */
  108753. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108754. /**
  108755. * Disables a depth renderer for a given camera
  108756. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108757. */
  108758. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108759. }
  108760. /**
  108761. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108762. * in several rendering techniques.
  108763. */
  108764. export class DepthRendererSceneComponent implements ISceneComponent {
  108765. /**
  108766. * The component name helpfull to identify the component in the list of scene components.
  108767. */
  108768. readonly name: string;
  108769. /**
  108770. * The scene the component belongs to.
  108771. */
  108772. scene: Scene;
  108773. /**
  108774. * Creates a new instance of the component for the given scene
  108775. * @param scene Defines the scene to register the component in
  108776. */
  108777. constructor(scene: Scene);
  108778. /**
  108779. * Registers the component in a given scene
  108780. */
  108781. register(): void;
  108782. /**
  108783. * Rebuilds the elements related to this component in case of
  108784. * context lost for instance.
  108785. */
  108786. rebuild(): void;
  108787. /**
  108788. * Disposes the component and the associated ressources
  108789. */
  108790. dispose(): void;
  108791. private _gatherRenderTargets;
  108792. private _gatherActiveCameraRenderTargets;
  108793. }
  108794. }
  108795. declare module BABYLON {
  108796. interface Scene {
  108797. /** @hidden (Backing field) */
  108798. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108799. /**
  108800. * Gets or Sets the current geometry buffer associated to the scene.
  108801. */
  108802. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108803. /**
  108804. * Enables a GeometryBufferRender and associates it with the scene
  108805. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108806. * @returns the GeometryBufferRenderer
  108807. */
  108808. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108809. /**
  108810. * Disables the GeometryBufferRender associated with the scene
  108811. */
  108812. disableGeometryBufferRenderer(): void;
  108813. }
  108814. /**
  108815. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108816. * in several rendering techniques.
  108817. */
  108818. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108819. /**
  108820. * The component name helpful to identify the component in the list of scene components.
  108821. */
  108822. readonly name: string;
  108823. /**
  108824. * The scene the component belongs to.
  108825. */
  108826. scene: Scene;
  108827. /**
  108828. * Creates a new instance of the component for the given scene
  108829. * @param scene Defines the scene to register the component in
  108830. */
  108831. constructor(scene: Scene);
  108832. /**
  108833. * Registers the component in a given scene
  108834. */
  108835. register(): void;
  108836. /**
  108837. * Rebuilds the elements related to this component in case of
  108838. * context lost for instance.
  108839. */
  108840. rebuild(): void;
  108841. /**
  108842. * Disposes the component and the associated ressources
  108843. */
  108844. dispose(): void;
  108845. private _gatherRenderTargets;
  108846. }
  108847. }
  108848. declare module BABYLON {
  108849. /** @hidden */
  108850. export var outlinePixelShader: {
  108851. name: string;
  108852. shader: string;
  108853. };
  108854. }
  108855. declare module BABYLON {
  108856. /** @hidden */
  108857. export var outlineVertexShader: {
  108858. name: string;
  108859. shader: string;
  108860. };
  108861. }
  108862. declare module BABYLON {
  108863. interface Scene {
  108864. /** @hidden */
  108865. _outlineRenderer: OutlineRenderer;
  108866. /**
  108867. * Gets the outline renderer associated with the scene
  108868. * @returns a OutlineRenderer
  108869. */
  108870. getOutlineRenderer(): OutlineRenderer;
  108871. }
  108872. interface AbstractMesh {
  108873. /** @hidden (Backing field) */
  108874. _renderOutline: boolean;
  108875. /**
  108876. * Gets or sets a boolean indicating if the outline must be rendered as well
  108877. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108878. */
  108879. renderOutline: boolean;
  108880. /** @hidden (Backing field) */
  108881. _renderOverlay: boolean;
  108882. /**
  108883. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108884. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108885. */
  108886. renderOverlay: boolean;
  108887. }
  108888. /**
  108889. * This class is responsible to draw bothe outline/overlay of meshes.
  108890. * It should not be used directly but through the available method on mesh.
  108891. */
  108892. export class OutlineRenderer implements ISceneComponent {
  108893. /**
  108894. * The name of the component. Each component must have a unique name.
  108895. */
  108896. name: string;
  108897. /**
  108898. * The scene the component belongs to.
  108899. */
  108900. scene: Scene;
  108901. /**
  108902. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108903. */
  108904. zOffset: number;
  108905. private _engine;
  108906. private _effect;
  108907. private _cachedDefines;
  108908. private _savedDepthWrite;
  108909. /**
  108910. * Instantiates a new outline renderer. (There could be only one per scene).
  108911. * @param scene Defines the scene it belongs to
  108912. */
  108913. constructor(scene: Scene);
  108914. /**
  108915. * Register the component to one instance of a scene.
  108916. */
  108917. register(): void;
  108918. /**
  108919. * Rebuilds the elements related to this component in case of
  108920. * context lost for instance.
  108921. */
  108922. rebuild(): void;
  108923. /**
  108924. * Disposes the component and the associated ressources.
  108925. */
  108926. dispose(): void;
  108927. /**
  108928. * Renders the outline in the canvas.
  108929. * @param subMesh Defines the sumesh to render
  108930. * @param batch Defines the batch of meshes in case of instances
  108931. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108932. */
  108933. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108934. /**
  108935. * Returns whether or not the outline renderer is ready for a given submesh.
  108936. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108937. * @param subMesh Defines the submesh to check readyness for
  108938. * @param useInstances Defines wheter wee are trying to render instances or not
  108939. * @returns true if ready otherwise false
  108940. */
  108941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108942. private _beforeRenderingMesh;
  108943. private _afterRenderingMesh;
  108944. }
  108945. }
  108946. declare module BABYLON {
  108947. /**
  108948. * Defines the list of states available for a task inside a AssetsManager
  108949. */
  108950. export enum AssetTaskState {
  108951. /**
  108952. * Initialization
  108953. */
  108954. INIT = 0,
  108955. /**
  108956. * Running
  108957. */
  108958. RUNNING = 1,
  108959. /**
  108960. * Done
  108961. */
  108962. DONE = 2,
  108963. /**
  108964. * Error
  108965. */
  108966. ERROR = 3
  108967. }
  108968. /**
  108969. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108970. */
  108971. export abstract class AbstractAssetTask {
  108972. /**
  108973. * Task name
  108974. */ name: string;
  108975. /**
  108976. * Callback called when the task is successful
  108977. */
  108978. onSuccess: (task: any) => void;
  108979. /**
  108980. * Callback called when the task is not successful
  108981. */
  108982. onError: (task: any, message?: string, exception?: any) => void;
  108983. /**
  108984. * Creates a new AssetsManager
  108985. * @param name defines the name of the task
  108986. */
  108987. constructor(
  108988. /**
  108989. * Task name
  108990. */ name: string);
  108991. private _isCompleted;
  108992. private _taskState;
  108993. private _errorObject;
  108994. /**
  108995. * Get if the task is completed
  108996. */
  108997. readonly isCompleted: boolean;
  108998. /**
  108999. * Gets the current state of the task
  109000. */
  109001. readonly taskState: AssetTaskState;
  109002. /**
  109003. * Gets the current error object (if task is in error)
  109004. */
  109005. readonly errorObject: {
  109006. message?: string;
  109007. exception?: any;
  109008. };
  109009. /**
  109010. * Internal only
  109011. * @hidden
  109012. */
  109013. _setErrorObject(message?: string, exception?: any): void;
  109014. /**
  109015. * Execute the current task
  109016. * @param scene defines the scene where you want your assets to be loaded
  109017. * @param onSuccess is a callback called when the task is successfully executed
  109018. * @param onError is a callback called if an error occurs
  109019. */
  109020. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109021. /**
  109022. * Execute the current task
  109023. * @param scene defines the scene where you want your assets to be loaded
  109024. * @param onSuccess is a callback called when the task is successfully executed
  109025. * @param onError is a callback called if an error occurs
  109026. */
  109027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109028. /**
  109029. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  109030. * This can be used with failed tasks that have the reason for failure fixed.
  109031. */
  109032. reset(): void;
  109033. private onErrorCallback;
  109034. private onDoneCallback;
  109035. }
  109036. /**
  109037. * Define the interface used by progress events raised during assets loading
  109038. */
  109039. export interface IAssetsProgressEvent {
  109040. /**
  109041. * Defines the number of remaining tasks to process
  109042. */
  109043. remainingCount: number;
  109044. /**
  109045. * Defines the total number of tasks
  109046. */
  109047. totalCount: number;
  109048. /**
  109049. * Defines the task that was just processed
  109050. */
  109051. task: AbstractAssetTask;
  109052. }
  109053. /**
  109054. * Class used to share progress information about assets loading
  109055. */
  109056. export class AssetsProgressEvent implements IAssetsProgressEvent {
  109057. /**
  109058. * Defines the number of remaining tasks to process
  109059. */
  109060. remainingCount: number;
  109061. /**
  109062. * Defines the total number of tasks
  109063. */
  109064. totalCount: number;
  109065. /**
  109066. * Defines the task that was just processed
  109067. */
  109068. task: AbstractAssetTask;
  109069. /**
  109070. * Creates a AssetsProgressEvent
  109071. * @param remainingCount defines the number of remaining tasks to process
  109072. * @param totalCount defines the total number of tasks
  109073. * @param task defines the task that was just processed
  109074. */
  109075. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  109076. }
  109077. /**
  109078. * Define a task used by AssetsManager to load meshes
  109079. */
  109080. export class MeshAssetTask extends AbstractAssetTask {
  109081. /**
  109082. * Defines the name of the task
  109083. */
  109084. name: string;
  109085. /**
  109086. * Defines the list of mesh's names you want to load
  109087. */
  109088. meshesNames: any;
  109089. /**
  109090. * Defines the root url to use as a base to load your meshes and associated resources
  109091. */
  109092. rootUrl: string;
  109093. /**
  109094. * Defines the filename of the scene to load from
  109095. */
  109096. sceneFilename: string;
  109097. /**
  109098. * Gets the list of loaded meshes
  109099. */
  109100. loadedMeshes: Array<AbstractMesh>;
  109101. /**
  109102. * Gets the list of loaded particle systems
  109103. */
  109104. loadedParticleSystems: Array<IParticleSystem>;
  109105. /**
  109106. * Gets the list of loaded skeletons
  109107. */
  109108. loadedSkeletons: Array<Skeleton>;
  109109. /**
  109110. * Gets the list of loaded animation groups
  109111. */
  109112. loadedAnimationGroups: Array<AnimationGroup>;
  109113. /**
  109114. * Callback called when the task is successful
  109115. */
  109116. onSuccess: (task: MeshAssetTask) => void;
  109117. /**
  109118. * Callback called when the task is successful
  109119. */
  109120. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  109121. /**
  109122. * Creates a new MeshAssetTask
  109123. * @param name defines the name of the task
  109124. * @param meshesNames defines the list of mesh's names you want to load
  109125. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  109126. * @param sceneFilename defines the filename of the scene to load from
  109127. */
  109128. constructor(
  109129. /**
  109130. * Defines the name of the task
  109131. */
  109132. name: string,
  109133. /**
  109134. * Defines the list of mesh's names you want to load
  109135. */
  109136. meshesNames: any,
  109137. /**
  109138. * Defines the root url to use as a base to load your meshes and associated resources
  109139. */
  109140. rootUrl: string,
  109141. /**
  109142. * Defines the filename of the scene to load from
  109143. */
  109144. sceneFilename: string);
  109145. /**
  109146. * Execute the current task
  109147. * @param scene defines the scene where you want your assets to be loaded
  109148. * @param onSuccess is a callback called when the task is successfully executed
  109149. * @param onError is a callback called if an error occurs
  109150. */
  109151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109152. }
  109153. /**
  109154. * Define a task used by AssetsManager to load text content
  109155. */
  109156. export class TextFileAssetTask extends AbstractAssetTask {
  109157. /**
  109158. * Defines the name of the task
  109159. */
  109160. name: string;
  109161. /**
  109162. * Defines the location of the file to load
  109163. */
  109164. url: string;
  109165. /**
  109166. * Gets the loaded text string
  109167. */
  109168. text: string;
  109169. /**
  109170. * Callback called when the task is successful
  109171. */
  109172. onSuccess: (task: TextFileAssetTask) => void;
  109173. /**
  109174. * Callback called when the task is successful
  109175. */
  109176. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  109177. /**
  109178. * Creates a new TextFileAssetTask object
  109179. * @param name defines the name of the task
  109180. * @param url defines the location of the file to load
  109181. */
  109182. constructor(
  109183. /**
  109184. * Defines the name of the task
  109185. */
  109186. name: string,
  109187. /**
  109188. * Defines the location of the file to load
  109189. */
  109190. url: string);
  109191. /**
  109192. * Execute the current task
  109193. * @param scene defines the scene where you want your assets to be loaded
  109194. * @param onSuccess is a callback called when the task is successfully executed
  109195. * @param onError is a callback called if an error occurs
  109196. */
  109197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109198. }
  109199. /**
  109200. * Define a task used by AssetsManager to load binary data
  109201. */
  109202. export class BinaryFileAssetTask extends AbstractAssetTask {
  109203. /**
  109204. * Defines the name of the task
  109205. */
  109206. name: string;
  109207. /**
  109208. * Defines the location of the file to load
  109209. */
  109210. url: string;
  109211. /**
  109212. * Gets the lodaded data (as an array buffer)
  109213. */
  109214. data: ArrayBuffer;
  109215. /**
  109216. * Callback called when the task is successful
  109217. */
  109218. onSuccess: (task: BinaryFileAssetTask) => void;
  109219. /**
  109220. * Callback called when the task is successful
  109221. */
  109222. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  109223. /**
  109224. * Creates a new BinaryFileAssetTask object
  109225. * @param name defines the name of the new task
  109226. * @param url defines the location of the file to load
  109227. */
  109228. constructor(
  109229. /**
  109230. * Defines the name of the task
  109231. */
  109232. name: string,
  109233. /**
  109234. * Defines the location of the file to load
  109235. */
  109236. url: string);
  109237. /**
  109238. * Execute the current task
  109239. * @param scene defines the scene where you want your assets to be loaded
  109240. * @param onSuccess is a callback called when the task is successfully executed
  109241. * @param onError is a callback called if an error occurs
  109242. */
  109243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109244. }
  109245. /**
  109246. * Define a task used by AssetsManager to load images
  109247. */
  109248. export class ImageAssetTask extends AbstractAssetTask {
  109249. /**
  109250. * Defines the name of the task
  109251. */
  109252. name: string;
  109253. /**
  109254. * Defines the location of the image to load
  109255. */
  109256. url: string;
  109257. /**
  109258. * Gets the loaded images
  109259. */
  109260. image: HTMLImageElement;
  109261. /**
  109262. * Callback called when the task is successful
  109263. */
  109264. onSuccess: (task: ImageAssetTask) => void;
  109265. /**
  109266. * Callback called when the task is successful
  109267. */
  109268. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  109269. /**
  109270. * Creates a new ImageAssetTask
  109271. * @param name defines the name of the task
  109272. * @param url defines the location of the image to load
  109273. */
  109274. constructor(
  109275. /**
  109276. * Defines the name of the task
  109277. */
  109278. name: string,
  109279. /**
  109280. * Defines the location of the image to load
  109281. */
  109282. url: string);
  109283. /**
  109284. * Execute the current task
  109285. * @param scene defines the scene where you want your assets to be loaded
  109286. * @param onSuccess is a callback called when the task is successfully executed
  109287. * @param onError is a callback called if an error occurs
  109288. */
  109289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109290. }
  109291. /**
  109292. * Defines the interface used by texture loading tasks
  109293. */
  109294. export interface ITextureAssetTask<TEX extends BaseTexture> {
  109295. /**
  109296. * Gets the loaded texture
  109297. */
  109298. texture: TEX;
  109299. }
  109300. /**
  109301. * Define a task used by AssetsManager to load 2D textures
  109302. */
  109303. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  109304. /**
  109305. * Defines the name of the task
  109306. */
  109307. name: string;
  109308. /**
  109309. * Defines the location of the file to load
  109310. */
  109311. url: string;
  109312. /**
  109313. * Defines if mipmap should not be generated (default is false)
  109314. */
  109315. noMipmap?: boolean | undefined;
  109316. /**
  109317. * Defines if texture must be inverted on Y axis (default is false)
  109318. */
  109319. invertY?: boolean | undefined;
  109320. /**
  109321. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109322. */
  109323. samplingMode: number;
  109324. /**
  109325. * Gets the loaded texture
  109326. */
  109327. texture: Texture;
  109328. /**
  109329. * Callback called when the task is successful
  109330. */
  109331. onSuccess: (task: TextureAssetTask) => void;
  109332. /**
  109333. * Callback called when the task is successful
  109334. */
  109335. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  109336. /**
  109337. * Creates a new TextureAssetTask object
  109338. * @param name defines the name of the task
  109339. * @param url defines the location of the file to load
  109340. * @param noMipmap defines if mipmap should not be generated (default is false)
  109341. * @param invertY defines if texture must be inverted on Y axis (default is false)
  109342. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109343. */
  109344. constructor(
  109345. /**
  109346. * Defines the name of the task
  109347. */
  109348. name: string,
  109349. /**
  109350. * Defines the location of the file to load
  109351. */
  109352. url: string,
  109353. /**
  109354. * Defines if mipmap should not be generated (default is false)
  109355. */
  109356. noMipmap?: boolean | undefined,
  109357. /**
  109358. * Defines if texture must be inverted on Y axis (default is false)
  109359. */
  109360. invertY?: boolean | undefined,
  109361. /**
  109362. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109363. */
  109364. samplingMode?: number);
  109365. /**
  109366. * Execute the current task
  109367. * @param scene defines the scene where you want your assets to be loaded
  109368. * @param onSuccess is a callback called when the task is successfully executed
  109369. * @param onError is a callback called if an error occurs
  109370. */
  109371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109372. }
  109373. /**
  109374. * Define a task used by AssetsManager to load cube textures
  109375. */
  109376. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  109377. /**
  109378. * Defines the name of the task
  109379. */
  109380. name: string;
  109381. /**
  109382. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109383. */
  109384. url: string;
  109385. /**
  109386. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109387. */
  109388. extensions?: string[] | undefined;
  109389. /**
  109390. * Defines if mipmaps should not be generated (default is false)
  109391. */
  109392. noMipmap?: boolean | undefined;
  109393. /**
  109394. * Defines the explicit list of files (undefined by default)
  109395. */
  109396. files?: string[] | undefined;
  109397. /**
  109398. * Gets the loaded texture
  109399. */
  109400. texture: CubeTexture;
  109401. /**
  109402. * Callback called when the task is successful
  109403. */
  109404. onSuccess: (task: CubeTextureAssetTask) => void;
  109405. /**
  109406. * Callback called when the task is successful
  109407. */
  109408. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  109409. /**
  109410. * Creates a new CubeTextureAssetTask
  109411. * @param name defines the name of the task
  109412. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109413. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109414. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109415. * @param files defines the explicit list of files (undefined by default)
  109416. */
  109417. constructor(
  109418. /**
  109419. * Defines the name of the task
  109420. */
  109421. name: string,
  109422. /**
  109423. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109424. */
  109425. url: string,
  109426. /**
  109427. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109428. */
  109429. extensions?: string[] | undefined,
  109430. /**
  109431. * Defines if mipmaps should not be generated (default is false)
  109432. */
  109433. noMipmap?: boolean | undefined,
  109434. /**
  109435. * Defines the explicit list of files (undefined by default)
  109436. */
  109437. files?: string[] | undefined);
  109438. /**
  109439. * Execute the current task
  109440. * @param scene defines the scene where you want your assets to be loaded
  109441. * @param onSuccess is a callback called when the task is successfully executed
  109442. * @param onError is a callback called if an error occurs
  109443. */
  109444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109445. }
  109446. /**
  109447. * Define a task used by AssetsManager to load HDR cube textures
  109448. */
  109449. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  109450. /**
  109451. * Defines the name of the task
  109452. */
  109453. name: string;
  109454. /**
  109455. * Defines the location of the file to load
  109456. */
  109457. url: string;
  109458. /**
  109459. * Defines the desired size (the more it increases the longer the generation will be)
  109460. */
  109461. size: number;
  109462. /**
  109463. * Defines if mipmaps should not be generated (default is false)
  109464. */
  109465. noMipmap: boolean;
  109466. /**
  109467. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109468. */
  109469. generateHarmonics: boolean;
  109470. /**
  109471. * 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)
  109472. */
  109473. gammaSpace: boolean;
  109474. /**
  109475. * Internal Use Only
  109476. */
  109477. reserved: boolean;
  109478. /**
  109479. * Gets the loaded texture
  109480. */
  109481. texture: HDRCubeTexture;
  109482. /**
  109483. * Callback called when the task is successful
  109484. */
  109485. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  109486. /**
  109487. * Callback called when the task is successful
  109488. */
  109489. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  109490. /**
  109491. * Creates a new HDRCubeTextureAssetTask object
  109492. * @param name defines the name of the task
  109493. * @param url defines the location of the file to load
  109494. * @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.
  109495. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109496. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109497. * @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)
  109498. * @param reserved Internal use only
  109499. */
  109500. constructor(
  109501. /**
  109502. * Defines the name of the task
  109503. */
  109504. name: string,
  109505. /**
  109506. * Defines the location of the file to load
  109507. */
  109508. url: string,
  109509. /**
  109510. * Defines the desired size (the more it increases the longer the generation will be)
  109511. */
  109512. size: number,
  109513. /**
  109514. * Defines if mipmaps should not be generated (default is false)
  109515. */
  109516. noMipmap?: boolean,
  109517. /**
  109518. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109519. */
  109520. generateHarmonics?: boolean,
  109521. /**
  109522. * 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)
  109523. */
  109524. gammaSpace?: boolean,
  109525. /**
  109526. * Internal Use Only
  109527. */
  109528. reserved?: boolean);
  109529. /**
  109530. * Execute the current task
  109531. * @param scene defines the scene where you want your assets to be loaded
  109532. * @param onSuccess is a callback called when the task is successfully executed
  109533. * @param onError is a callback called if an error occurs
  109534. */
  109535. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109536. }
  109537. /**
  109538. * This class can be used to easily import assets into a scene
  109539. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  109540. */
  109541. export class AssetsManager {
  109542. private _scene;
  109543. private _isLoading;
  109544. protected _tasks: AbstractAssetTask[];
  109545. protected _waitingTasksCount: number;
  109546. protected _totalTasksCount: number;
  109547. /**
  109548. * Callback called when all tasks are processed
  109549. */
  109550. onFinish: (tasks: AbstractAssetTask[]) => void;
  109551. /**
  109552. * Callback called when a task is successful
  109553. */
  109554. onTaskSuccess: (task: AbstractAssetTask) => void;
  109555. /**
  109556. * Callback called when a task had an error
  109557. */
  109558. onTaskError: (task: AbstractAssetTask) => void;
  109559. /**
  109560. * Callback called when a task is done (whatever the result is)
  109561. */
  109562. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  109563. /**
  109564. * Observable called when all tasks are processed
  109565. */
  109566. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  109567. /**
  109568. * Observable called when a task had an error
  109569. */
  109570. onTaskErrorObservable: Observable<AbstractAssetTask>;
  109571. /**
  109572. * Observable called when a task is successful
  109573. */
  109574. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  109575. /**
  109576. * Observable called when a task is done (whatever the result is)
  109577. */
  109578. onProgressObservable: Observable<IAssetsProgressEvent>;
  109579. /**
  109580. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  109581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109582. */
  109583. useDefaultLoadingScreen: boolean;
  109584. /**
  109585. * Creates a new AssetsManager
  109586. * @param scene defines the scene to work on
  109587. */
  109588. constructor(scene: Scene);
  109589. /**
  109590. * Add a MeshAssetTask to the list of active tasks
  109591. * @param taskName defines the name of the new task
  109592. * @param meshesNames defines the name of meshes to load
  109593. * @param rootUrl defines the root url to use to locate files
  109594. * @param sceneFilename defines the filename of the scene file
  109595. * @returns a new MeshAssetTask object
  109596. */
  109597. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  109598. /**
  109599. * Add a TextFileAssetTask to the list of active tasks
  109600. * @param taskName defines the name of the new task
  109601. * @param url defines the url of the file to load
  109602. * @returns a new TextFileAssetTask object
  109603. */
  109604. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  109605. /**
  109606. * Add a BinaryFileAssetTask to the list of active tasks
  109607. * @param taskName defines the name of the new task
  109608. * @param url defines the url of the file to load
  109609. * @returns a new BinaryFileAssetTask object
  109610. */
  109611. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  109612. /**
  109613. * Add a ImageAssetTask to the list of active tasks
  109614. * @param taskName defines the name of the new task
  109615. * @param url defines the url of the file to load
  109616. * @returns a new ImageAssetTask object
  109617. */
  109618. addImageTask(taskName: string, url: string): ImageAssetTask;
  109619. /**
  109620. * Add a TextureAssetTask to the list of active tasks
  109621. * @param taskName defines the name of the new task
  109622. * @param url defines the url of the file to load
  109623. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109624. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  109625. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109626. * @returns a new TextureAssetTask object
  109627. */
  109628. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  109629. /**
  109630. * Add a CubeTextureAssetTask to the list of active tasks
  109631. * @param taskName defines the name of the new task
  109632. * @param url defines the url of the file to load
  109633. * @param extensions defines the extension to use to load the cube map (can be null)
  109634. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109635. * @param files defines the list of files to load (can be null)
  109636. * @returns a new CubeTextureAssetTask object
  109637. */
  109638. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  109639. /**
  109640. *
  109641. * Add a HDRCubeTextureAssetTask to the list of active tasks
  109642. * @param taskName defines the name of the new task
  109643. * @param url defines the url of the file to load
  109644. * @param size defines the size you want for the cubemap (can be null)
  109645. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109646. * @param generateHarmonics defines if you want to automatically generate (true by default)
  109647. * @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)
  109648. * @param reserved Internal use only
  109649. * @returns a new HDRCubeTextureAssetTask object
  109650. */
  109651. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  109652. /**
  109653. * Remove a task from the assets manager.
  109654. * @param task the task to remove
  109655. */
  109656. removeTask(task: AbstractAssetTask): void;
  109657. private _decreaseWaitingTasksCount;
  109658. private _runTask;
  109659. /**
  109660. * Reset the AssetsManager and remove all tasks
  109661. * @return the current instance of the AssetsManager
  109662. */
  109663. reset(): AssetsManager;
  109664. /**
  109665. * Start the loading process
  109666. * @return the current instance of the AssetsManager
  109667. */
  109668. load(): AssetsManager;
  109669. }
  109670. }
  109671. declare module BABYLON {
  109672. /**
  109673. * Wrapper class for promise with external resolve and reject.
  109674. */
  109675. export class Deferred<T> {
  109676. /**
  109677. * The promise associated with this deferred object.
  109678. */
  109679. readonly promise: Promise<T>;
  109680. private _resolve;
  109681. private _reject;
  109682. /**
  109683. * The resolve method of the promise associated with this deferred object.
  109684. */
  109685. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  109686. /**
  109687. * The reject method of the promise associated with this deferred object.
  109688. */
  109689. readonly reject: (reason?: any) => void;
  109690. /**
  109691. * Constructor for this deferred object.
  109692. */
  109693. constructor();
  109694. }
  109695. }
  109696. declare module BABYLON {
  109697. /**
  109698. * Class used to help managing file picking and drag'n'drop
  109699. */
  109700. export class FilesInput {
  109701. /**
  109702. * List of files ready to be loaded
  109703. */
  109704. static readonly FilesToLoad: {
  109705. [key: string]: File;
  109706. };
  109707. /**
  109708. * Callback called when a file is processed
  109709. */
  109710. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109711. private _engine;
  109712. private _currentScene;
  109713. private _sceneLoadedCallback;
  109714. private _progressCallback;
  109715. private _additionalRenderLoopLogicCallback;
  109716. private _textureLoadingCallback;
  109717. private _startingProcessingFilesCallback;
  109718. private _onReloadCallback;
  109719. private _errorCallback;
  109720. private _elementToMonitor;
  109721. private _sceneFileToLoad;
  109722. private _filesToLoad;
  109723. /**
  109724. * Creates a new FilesInput
  109725. * @param engine defines the rendering engine
  109726. * @param scene defines the hosting scene
  109727. * @param sceneLoadedCallback callback called when scene is loaded
  109728. * @param progressCallback callback called to track progress
  109729. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  109730. * @param textureLoadingCallback callback called when a texture is loading
  109731. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  109732. * @param onReloadCallback callback called when a reload is requested
  109733. * @param errorCallback callback call if an error occurs
  109734. */
  109735. 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);
  109736. private _dragEnterHandler;
  109737. private _dragOverHandler;
  109738. private _dropHandler;
  109739. /**
  109740. * Calls this function to listen to drag'n'drop events on a specific DOM element
  109741. * @param elementToMonitor defines the DOM element to track
  109742. */
  109743. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  109744. /**
  109745. * Release all associated resources
  109746. */
  109747. dispose(): void;
  109748. private renderFunction;
  109749. private drag;
  109750. private drop;
  109751. private _traverseFolder;
  109752. private _processFiles;
  109753. /**
  109754. * Load files from a drop event
  109755. * @param event defines the drop event to use as source
  109756. */
  109757. loadFiles(event: any): void;
  109758. private _processReload;
  109759. /**
  109760. * Reload the current scene from the loaded files
  109761. */
  109762. reload(): void;
  109763. }
  109764. }
  109765. declare module BABYLON {
  109766. /**
  109767. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109768. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109769. */
  109770. export class SceneOptimization {
  109771. /**
  109772. * Defines the priority of this optimization (0 by default which means first in the list)
  109773. */
  109774. priority: number;
  109775. /**
  109776. * Gets a string describing the action executed by the current optimization
  109777. * @returns description string
  109778. */
  109779. getDescription(): string;
  109780. /**
  109781. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109782. * @param scene defines the current scene where to apply this optimization
  109783. * @param optimizer defines the current optimizer
  109784. * @returns true if everything that can be done was applied
  109785. */
  109786. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109787. /**
  109788. * Creates the SceneOptimization object
  109789. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109790. * @param desc defines the description associated with the optimization
  109791. */
  109792. constructor(
  109793. /**
  109794. * Defines the priority of this optimization (0 by default which means first in the list)
  109795. */
  109796. priority?: number);
  109797. }
  109798. /**
  109799. * Defines an optimization used to reduce the size of render target textures
  109800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109801. */
  109802. export class TextureOptimization extends SceneOptimization {
  109803. /**
  109804. * Defines the priority of this optimization (0 by default which means first in the list)
  109805. */
  109806. priority: number;
  109807. /**
  109808. * 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
  109809. */
  109810. maximumSize: number;
  109811. /**
  109812. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109813. */
  109814. step: number;
  109815. /**
  109816. * Gets a string describing the action executed by the current optimization
  109817. * @returns description string
  109818. */
  109819. getDescription(): string;
  109820. /**
  109821. * Creates the TextureOptimization object
  109822. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109823. * @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
  109824. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109825. */
  109826. constructor(
  109827. /**
  109828. * Defines the priority of this optimization (0 by default which means first in the list)
  109829. */
  109830. priority?: number,
  109831. /**
  109832. * 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
  109833. */
  109834. maximumSize?: number,
  109835. /**
  109836. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109837. */
  109838. step?: number);
  109839. /**
  109840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109841. * @param scene defines the current scene where to apply this optimization
  109842. * @param optimizer defines the current optimizer
  109843. * @returns true if everything that can be done was applied
  109844. */
  109845. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109846. }
  109847. /**
  109848. * Defines an optimization used to increase or decrease the rendering resolution
  109849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109850. */
  109851. export class HardwareScalingOptimization extends SceneOptimization {
  109852. /**
  109853. * Defines the priority of this optimization (0 by default which means first in the list)
  109854. */
  109855. priority: number;
  109856. /**
  109857. * Defines the maximum scale to use (2 by default)
  109858. */
  109859. maximumScale: number;
  109860. /**
  109861. * Defines the step to use between two passes (0.5 by default)
  109862. */
  109863. step: number;
  109864. private _currentScale;
  109865. private _directionOffset;
  109866. /**
  109867. * Gets a string describing the action executed by the current optimization
  109868. * @return description string
  109869. */
  109870. getDescription(): string;
  109871. /**
  109872. * Creates the HardwareScalingOptimization object
  109873. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109874. * @param maximumScale defines the maximum scale to use (2 by default)
  109875. * @param step defines the step to use between two passes (0.5 by default)
  109876. */
  109877. constructor(
  109878. /**
  109879. * Defines the priority of this optimization (0 by default which means first in the list)
  109880. */
  109881. priority?: number,
  109882. /**
  109883. * Defines the maximum scale to use (2 by default)
  109884. */
  109885. maximumScale?: number,
  109886. /**
  109887. * Defines the step to use between two passes (0.5 by default)
  109888. */
  109889. step?: number);
  109890. /**
  109891. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109892. * @param scene defines the current scene where to apply this optimization
  109893. * @param optimizer defines the current optimizer
  109894. * @returns true if everything that can be done was applied
  109895. */
  109896. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109897. }
  109898. /**
  109899. * Defines an optimization used to remove shadows
  109900. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109901. */
  109902. export class ShadowsOptimization extends SceneOptimization {
  109903. /**
  109904. * Gets a string describing the action executed by the current optimization
  109905. * @return description string
  109906. */
  109907. getDescription(): string;
  109908. /**
  109909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109910. * @param scene defines the current scene where to apply this optimization
  109911. * @param optimizer defines the current optimizer
  109912. * @returns true if everything that can be done was applied
  109913. */
  109914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109915. }
  109916. /**
  109917. * Defines an optimization used to turn post-processes off
  109918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109919. */
  109920. export class PostProcessesOptimization extends SceneOptimization {
  109921. /**
  109922. * Gets a string describing the action executed by the current optimization
  109923. * @return description string
  109924. */
  109925. getDescription(): string;
  109926. /**
  109927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109928. * @param scene defines the current scene where to apply this optimization
  109929. * @param optimizer defines the current optimizer
  109930. * @returns true if everything that can be done was applied
  109931. */
  109932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109933. }
  109934. /**
  109935. * Defines an optimization used to turn lens flares off
  109936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109937. */
  109938. export class LensFlaresOptimization extends SceneOptimization {
  109939. /**
  109940. * Gets a string describing the action executed by the current optimization
  109941. * @return description string
  109942. */
  109943. getDescription(): string;
  109944. /**
  109945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109946. * @param scene defines the current scene where to apply this optimization
  109947. * @param optimizer defines the current optimizer
  109948. * @returns true if everything that can be done was applied
  109949. */
  109950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109951. }
  109952. /**
  109953. * Defines an optimization based on user defined callback.
  109954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109955. */
  109956. export class CustomOptimization extends SceneOptimization {
  109957. /**
  109958. * Callback called to apply the custom optimization.
  109959. */
  109960. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109961. /**
  109962. * Callback called to get custom description
  109963. */
  109964. onGetDescription: () => string;
  109965. /**
  109966. * Gets a string describing the action executed by the current optimization
  109967. * @returns description string
  109968. */
  109969. getDescription(): string;
  109970. /**
  109971. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109972. * @param scene defines the current scene where to apply this optimization
  109973. * @param optimizer defines the current optimizer
  109974. * @returns true if everything that can be done was applied
  109975. */
  109976. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109977. }
  109978. /**
  109979. * Defines an optimization used to turn particles off
  109980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109981. */
  109982. export class ParticlesOptimization extends SceneOptimization {
  109983. /**
  109984. * Gets a string describing the action executed by the current optimization
  109985. * @return description string
  109986. */
  109987. getDescription(): string;
  109988. /**
  109989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109990. * @param scene defines the current scene where to apply this optimization
  109991. * @param optimizer defines the current optimizer
  109992. * @returns true if everything that can be done was applied
  109993. */
  109994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109995. }
  109996. /**
  109997. * Defines an optimization used to turn render targets off
  109998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109999. */
  110000. export class RenderTargetsOptimization extends SceneOptimization {
  110001. /**
  110002. * Gets a string describing the action executed by the current optimization
  110003. * @return description string
  110004. */
  110005. getDescription(): string;
  110006. /**
  110007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110008. * @param scene defines the current scene where to apply this optimization
  110009. * @param optimizer defines the current optimizer
  110010. * @returns true if everything that can be done was applied
  110011. */
  110012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110013. }
  110014. /**
  110015. * Defines an optimization used to merge meshes with compatible materials
  110016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110017. */
  110018. export class MergeMeshesOptimization extends SceneOptimization {
  110019. private static _UpdateSelectionTree;
  110020. /**
  110021. * Gets or sets a boolean which defines if optimization octree has to be updated
  110022. */
  110023. /**
  110024. * Gets or sets a boolean which defines if optimization octree has to be updated
  110025. */
  110026. static UpdateSelectionTree: boolean;
  110027. /**
  110028. * Gets a string describing the action executed by the current optimization
  110029. * @return description string
  110030. */
  110031. getDescription(): string;
  110032. private _canBeMerged;
  110033. /**
  110034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110035. * @param scene defines the current scene where to apply this optimization
  110036. * @param optimizer defines the current optimizer
  110037. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  110038. * @returns true if everything that can be done was applied
  110039. */
  110040. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  110041. }
  110042. /**
  110043. * Defines a list of options used by SceneOptimizer
  110044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110045. */
  110046. export class SceneOptimizerOptions {
  110047. /**
  110048. * Defines the target frame rate to reach (60 by default)
  110049. */
  110050. targetFrameRate: number;
  110051. /**
  110052. * Defines the interval between two checkes (2000ms by default)
  110053. */
  110054. trackerDuration: number;
  110055. /**
  110056. * Gets the list of optimizations to apply
  110057. */
  110058. optimizations: SceneOptimization[];
  110059. /**
  110060. * Creates a new list of options used by SceneOptimizer
  110061. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  110062. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  110063. */
  110064. constructor(
  110065. /**
  110066. * Defines the target frame rate to reach (60 by default)
  110067. */
  110068. targetFrameRate?: number,
  110069. /**
  110070. * Defines the interval between two checkes (2000ms by default)
  110071. */
  110072. trackerDuration?: number);
  110073. /**
  110074. * Add a new optimization
  110075. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  110076. * @returns the current SceneOptimizerOptions
  110077. */
  110078. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  110079. /**
  110080. * Add a new custom optimization
  110081. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  110082. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  110083. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110084. * @returns the current SceneOptimizerOptions
  110085. */
  110086. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  110087. /**
  110088. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  110089. * @param targetFrameRate defines the target frame rate (60 by default)
  110090. * @returns a SceneOptimizerOptions object
  110091. */
  110092. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110093. /**
  110094. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  110095. * @param targetFrameRate defines the target frame rate (60 by default)
  110096. * @returns a SceneOptimizerOptions object
  110097. */
  110098. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110099. /**
  110100. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  110101. * @param targetFrameRate defines the target frame rate (60 by default)
  110102. * @returns a SceneOptimizerOptions object
  110103. */
  110104. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110105. }
  110106. /**
  110107. * Class used to run optimizations in order to reach a target frame rate
  110108. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110109. */
  110110. export class SceneOptimizer implements IDisposable {
  110111. private _isRunning;
  110112. private _options;
  110113. private _scene;
  110114. private _currentPriorityLevel;
  110115. private _targetFrameRate;
  110116. private _trackerDuration;
  110117. private _currentFrameRate;
  110118. private _sceneDisposeObserver;
  110119. private _improvementMode;
  110120. /**
  110121. * Defines an observable called when the optimizer reaches the target frame rate
  110122. */
  110123. onSuccessObservable: Observable<SceneOptimizer>;
  110124. /**
  110125. * Defines an observable called when the optimizer enables an optimization
  110126. */
  110127. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  110128. /**
  110129. * Defines an observable called when the optimizer is not able to reach the target frame rate
  110130. */
  110131. onFailureObservable: Observable<SceneOptimizer>;
  110132. /**
  110133. * Gets a boolean indicating if the optimizer is in improvement mode
  110134. */
  110135. readonly isInImprovementMode: boolean;
  110136. /**
  110137. * Gets the current priority level (0 at start)
  110138. */
  110139. readonly currentPriorityLevel: number;
  110140. /**
  110141. * Gets the current frame rate checked by the SceneOptimizer
  110142. */
  110143. readonly currentFrameRate: number;
  110144. /**
  110145. * Gets or sets the current target frame rate (60 by default)
  110146. */
  110147. /**
  110148. * Gets or sets the current target frame rate (60 by default)
  110149. */
  110150. targetFrameRate: number;
  110151. /**
  110152. * Gets or sets the current interval between two checks (every 2000ms by default)
  110153. */
  110154. /**
  110155. * Gets or sets the current interval between two checks (every 2000ms by default)
  110156. */
  110157. trackerDuration: number;
  110158. /**
  110159. * Gets the list of active optimizations
  110160. */
  110161. readonly optimizations: SceneOptimization[];
  110162. /**
  110163. * Creates a new SceneOptimizer
  110164. * @param scene defines the scene to work on
  110165. * @param options defines the options to use with the SceneOptimizer
  110166. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  110167. * @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)
  110168. */
  110169. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  110170. /**
  110171. * Stops the current optimizer
  110172. */
  110173. stop(): void;
  110174. /**
  110175. * Reset the optimizer to initial step (current priority level = 0)
  110176. */
  110177. reset(): void;
  110178. /**
  110179. * Start the optimizer. By default it will try to reach a specific framerate
  110180. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  110181. */
  110182. start(): void;
  110183. private _checkCurrentState;
  110184. /**
  110185. * Release all resources
  110186. */
  110187. dispose(): void;
  110188. /**
  110189. * Helper function to create a SceneOptimizer with one single line of code
  110190. * @param scene defines the scene to work on
  110191. * @param options defines the options to use with the SceneOptimizer
  110192. * @param onSuccess defines a callback to call on success
  110193. * @param onFailure defines a callback to call on failure
  110194. * @returns the new SceneOptimizer object
  110195. */
  110196. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  110197. }
  110198. }
  110199. declare module BABYLON {
  110200. /**
  110201. * Class used to serialize a scene into a string
  110202. */
  110203. export class SceneSerializer {
  110204. /**
  110205. * Clear cache used by a previous serialization
  110206. */
  110207. static ClearCache(): void;
  110208. /**
  110209. * Serialize a scene into a JSON compatible object
  110210. * @param scene defines the scene to serialize
  110211. * @returns a JSON compatible object
  110212. */
  110213. static Serialize(scene: Scene): any;
  110214. /**
  110215. * Serialize a mesh into a JSON compatible object
  110216. * @param toSerialize defines the mesh to serialize
  110217. * @param withParents defines if parents must be serialized as well
  110218. * @param withChildren defines if children must be serialized as well
  110219. * @returns a JSON compatible object
  110220. */
  110221. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  110222. }
  110223. }
  110224. declare module BABYLON {
  110225. /**
  110226. * This represents the different options avilable for the video capture.
  110227. */
  110228. export interface VideoRecorderOptions {
  110229. /** Defines the mime type of the video */
  110230. mimeType: string;
  110231. /** Defines the video the video should be recorded at */
  110232. fps: number;
  110233. /** Defines the chunk size for the recording data */
  110234. recordChunckSize: number;
  110235. }
  110236. /**
  110237. * This can helps recording videos from BabylonJS.
  110238. * This is based on the available WebRTC functionalities of the browser.
  110239. *
  110240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  110241. */
  110242. export class VideoRecorder {
  110243. private static readonly _defaultOptions;
  110244. /**
  110245. * Returns wehther or not the VideoRecorder is available in your browser.
  110246. * @param engine Defines the Babylon Engine to check the support for
  110247. * @returns true if supported otherwise false
  110248. */
  110249. static IsSupported(engine: Engine): boolean;
  110250. private readonly _options;
  110251. private _canvas;
  110252. private _mediaRecorder;
  110253. private _recordedChunks;
  110254. private _fileName;
  110255. private _resolve;
  110256. private _reject;
  110257. /**
  110258. * True wether a recording is already in progress.
  110259. */
  110260. readonly isRecording: boolean;
  110261. /**
  110262. * Create a new VideoCapture object which can help converting what you see in Babylon to
  110263. * a video file.
  110264. * @param engine Defines the BabylonJS Engine you wish to record
  110265. * @param options Defines options that can be used to customized the capture
  110266. */
  110267. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  110268. /**
  110269. * Stops the current recording before the default capture timeout passed in the startRecording
  110270. * functions.
  110271. */
  110272. stopRecording(): void;
  110273. /**
  110274. * Starts recording the canvas for a max duration specified in parameters.
  110275. * @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.
  110276. * @param maxDuration Defines the maximum recording time in seconds.
  110277. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  110278. * @return a promise callback at the end of the recording with the video data in Blob.
  110279. */
  110280. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  110281. /**
  110282. * Releases internal resources used during the recording.
  110283. */
  110284. dispose(): void;
  110285. private _handleDataAvailable;
  110286. private _handleError;
  110287. private _handleStop;
  110288. }
  110289. }
  110290. declare module BABYLON {
  110291. /**
  110292. * Helper class to push actions to a pool of workers.
  110293. */
  110294. export class WorkerPool implements IDisposable {
  110295. private _workerInfos;
  110296. private _pendingActions;
  110297. /**
  110298. * Constructor
  110299. * @param workers Array of workers to use for actions
  110300. */
  110301. constructor(workers: Array<Worker>);
  110302. /**
  110303. * Terminates all workers and clears any pending actions.
  110304. */
  110305. dispose(): void;
  110306. /**
  110307. * Pushes an action to the worker pool. If all the workers are active, the action will be
  110308. * pended until a worker has completed its action.
  110309. * @param action The action to perform. Call onComplete when the action is complete.
  110310. */
  110311. push(action: (worker: Worker, onComplete: () => void) => void): void;
  110312. private _execute;
  110313. }
  110314. }
  110315. declare module BABYLON {
  110316. /**
  110317. * Class containing a set of static utilities functions for screenshots
  110318. */
  110319. export class ScreenshotTools {
  110320. /**
  110321. * Captures a screenshot of the current rendering
  110322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110323. * @param engine defines the rendering engine
  110324. * @param camera defines the source camera
  110325. * @param size This parameter can be set to a single number or to an object with the
  110326. * following (optional) properties: precision, width, height. If a single number is passed,
  110327. * it will be used for both width and height. If an object is passed, the screenshot size
  110328. * will be derived from the parameters. The precision property is a multiplier allowing
  110329. * rendering at a higher or lower resolution
  110330. * @param successCallback defines the callback receives a single parameter which contains the
  110331. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110332. * src parameter of an <img> to display it
  110333. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110334. * Check your browser for supported MIME types
  110335. */
  110336. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  110337. /**
  110338. * Generates an image screenshot from the specified camera.
  110339. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110340. * @param engine The engine to use for rendering
  110341. * @param camera The camera to use for rendering
  110342. * @param size This parameter can be set to a single number or to an object with the
  110343. * following (optional) properties: precision, width, height. If a single number is passed,
  110344. * it will be used for both width and height. If an object is passed, the screenshot size
  110345. * will be derived from the parameters. The precision property is a multiplier allowing
  110346. * rendering at a higher or lower resolution
  110347. * @param successCallback The callback receives a single parameter which contains the
  110348. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110349. * src parameter of an <img> to display it
  110350. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110351. * Check your browser for supported MIME types
  110352. * @param samples Texture samples (default: 1)
  110353. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110354. * @param fileName A name for for the downloaded file.
  110355. */
  110356. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110357. }
  110358. }
  110359. declare module BABYLON {
  110360. /**
  110361. * A cursor which tracks a point on a path
  110362. */
  110363. export class PathCursor {
  110364. private path;
  110365. /**
  110366. * Stores path cursor callbacks for when an onchange event is triggered
  110367. */
  110368. private _onchange;
  110369. /**
  110370. * The value of the path cursor
  110371. */
  110372. value: number;
  110373. /**
  110374. * The animation array of the path cursor
  110375. */
  110376. animations: Animation[];
  110377. /**
  110378. * Initializes the path cursor
  110379. * @param path The path to track
  110380. */
  110381. constructor(path: Path2);
  110382. /**
  110383. * Gets the cursor point on the path
  110384. * @returns A point on the path cursor at the cursor location
  110385. */
  110386. getPoint(): Vector3;
  110387. /**
  110388. * Moves the cursor ahead by the step amount
  110389. * @param step The amount to move the cursor forward
  110390. * @returns This path cursor
  110391. */
  110392. moveAhead(step?: number): PathCursor;
  110393. /**
  110394. * Moves the cursor behind by the step amount
  110395. * @param step The amount to move the cursor back
  110396. * @returns This path cursor
  110397. */
  110398. moveBack(step?: number): PathCursor;
  110399. /**
  110400. * Moves the cursor by the step amount
  110401. * If the step amount is greater than one, an exception is thrown
  110402. * @param step The amount to move the cursor
  110403. * @returns This path cursor
  110404. */
  110405. move(step: number): PathCursor;
  110406. /**
  110407. * Ensures that the value is limited between zero and one
  110408. * @returns This path cursor
  110409. */
  110410. private ensureLimits;
  110411. /**
  110412. * Runs onchange callbacks on change (used by the animation engine)
  110413. * @returns This path cursor
  110414. */
  110415. private raiseOnChange;
  110416. /**
  110417. * Executes a function on change
  110418. * @param f A path cursor onchange callback
  110419. * @returns This path cursor
  110420. */
  110421. onchange(f: (cursor: PathCursor) => void): PathCursor;
  110422. }
  110423. }
  110424. declare module BABYLON {
  110425. /** @hidden */
  110426. export var blurPixelShader: {
  110427. name: string;
  110428. shader: string;
  110429. };
  110430. }
  110431. declare module BABYLON {
  110432. /** @hidden */
  110433. export var bones300Declaration: {
  110434. name: string;
  110435. shader: string;
  110436. };
  110437. }
  110438. declare module BABYLON {
  110439. /** @hidden */
  110440. export var instances300Declaration: {
  110441. name: string;
  110442. shader: string;
  110443. };
  110444. }
  110445. declare module BABYLON {
  110446. /** @hidden */
  110447. export var pointCloudVertexDeclaration: {
  110448. name: string;
  110449. shader: string;
  110450. };
  110451. }
  110452. // Mixins
  110453. interface Window {
  110454. mozIndexedDB: IDBFactory;
  110455. webkitIndexedDB: IDBFactory;
  110456. msIndexedDB: IDBFactory;
  110457. webkitURL: typeof URL;
  110458. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  110459. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  110460. WebGLRenderingContext: WebGLRenderingContext;
  110461. MSGesture: MSGesture;
  110462. CANNON: any;
  110463. AudioContext: AudioContext;
  110464. webkitAudioContext: AudioContext;
  110465. PointerEvent: any;
  110466. Math: Math;
  110467. Uint8Array: Uint8ArrayConstructor;
  110468. Float32Array: Float32ArrayConstructor;
  110469. mozURL: typeof URL;
  110470. msURL: typeof URL;
  110471. VRFrameData: any; // WebVR, from specs 1.1
  110472. DracoDecoderModule: any;
  110473. setImmediate(handler: (...args: any[]) => void): number;
  110474. }
  110475. interface Document {
  110476. mozCancelFullScreen(): void;
  110477. msCancelFullScreen(): void;
  110478. webkitCancelFullScreen(): void;
  110479. requestPointerLock(): void;
  110480. exitPointerLock(): void;
  110481. mozFullScreen: boolean;
  110482. msIsFullScreen: boolean;
  110483. readonly webkitIsFullScreen: boolean;
  110484. readonly pointerLockElement: Element;
  110485. mozPointerLockElement: HTMLElement;
  110486. msPointerLockElement: HTMLElement;
  110487. webkitPointerLockElement: HTMLElement;
  110488. }
  110489. interface HTMLCanvasElement {
  110490. requestPointerLock(): void;
  110491. msRequestPointerLock?(): void;
  110492. mozRequestPointerLock?(): void;
  110493. webkitRequestPointerLock?(): void;
  110494. /** Track wether a record is in progress */
  110495. isRecording: boolean;
  110496. /** Capture Stream method defined by some browsers */
  110497. captureStream(fps?: number): MediaStream;
  110498. }
  110499. interface CanvasRenderingContext2D {
  110500. msImageSmoothingEnabled: boolean;
  110501. }
  110502. interface MouseEvent {
  110503. mozMovementX: number;
  110504. mozMovementY: number;
  110505. webkitMovementX: number;
  110506. webkitMovementY: number;
  110507. msMovementX: number;
  110508. msMovementY: number;
  110509. }
  110510. interface Navigator {
  110511. mozGetVRDevices: (any: any) => any;
  110512. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110513. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110514. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110515. webkitGetGamepads(): Gamepad[];
  110516. msGetGamepads(): Gamepad[];
  110517. webkitGamepads(): Gamepad[];
  110518. }
  110519. interface HTMLVideoElement {
  110520. mozSrcObject: any;
  110521. }
  110522. interface Math {
  110523. fround(x: number): number;
  110524. imul(a: number, b: number): number;
  110525. }
  110526. interface WebGLProgram {
  110527. context?: WebGLRenderingContext;
  110528. vertexShader?: WebGLShader;
  110529. fragmentShader?: WebGLShader;
  110530. isParallelCompiled: boolean;
  110531. onCompiled?: () => void;
  110532. }
  110533. interface WebGLRenderingContext {
  110534. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  110535. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  110536. vertexAttribDivisor(index: number, divisor: number): void;
  110537. createVertexArray(): any;
  110538. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  110539. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  110540. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  110541. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  110542. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  110543. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  110544. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  110545. // Queries
  110546. createQuery(): WebGLQuery;
  110547. deleteQuery(query: WebGLQuery): void;
  110548. beginQuery(target: number, query: WebGLQuery): void;
  110549. endQuery(target: number): void;
  110550. getQueryParameter(query: WebGLQuery, pname: number): any;
  110551. getQuery(target: number, pname: number): any;
  110552. MAX_SAMPLES: number;
  110553. RGBA8: number;
  110554. READ_FRAMEBUFFER: number;
  110555. DRAW_FRAMEBUFFER: number;
  110556. UNIFORM_BUFFER: number;
  110557. HALF_FLOAT_OES: number;
  110558. RGBA16F: number;
  110559. RGBA32F: number;
  110560. R32F: number;
  110561. RG32F: number;
  110562. RGB32F: number;
  110563. R16F: number;
  110564. RG16F: number;
  110565. RGB16F: number;
  110566. RED: number;
  110567. RG: number;
  110568. R8: number;
  110569. RG8: number;
  110570. UNSIGNED_INT_24_8: number;
  110571. DEPTH24_STENCIL8: number;
  110572. /* Multiple Render Targets */
  110573. drawBuffers(buffers: number[]): void;
  110574. readBuffer(src: number): void;
  110575. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  110576. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  110577. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  110578. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  110579. // Occlusion Query
  110580. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  110581. ANY_SAMPLES_PASSED: number;
  110582. QUERY_RESULT_AVAILABLE: number;
  110583. QUERY_RESULT: number;
  110584. }
  110585. interface WebGLBuffer {
  110586. references: number;
  110587. capacity: number;
  110588. is32Bits: boolean;
  110589. }
  110590. interface WebGLProgram {
  110591. transformFeedback?: WebGLTransformFeedback | null;
  110592. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  110593. }
  110594. interface EXT_disjoint_timer_query {
  110595. QUERY_COUNTER_BITS_EXT: number;
  110596. TIME_ELAPSED_EXT: number;
  110597. TIMESTAMP_EXT: number;
  110598. GPU_DISJOINT_EXT: number;
  110599. QUERY_RESULT_EXT: number;
  110600. QUERY_RESULT_AVAILABLE_EXT: number;
  110601. queryCounterEXT(query: WebGLQuery, target: number): void;
  110602. createQueryEXT(): WebGLQuery;
  110603. beginQueryEXT(target: number, query: WebGLQuery): void;
  110604. endQueryEXT(target: number): void;
  110605. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  110606. deleteQueryEXT(query: WebGLQuery): void;
  110607. }
  110608. interface WebGLUniformLocation {
  110609. _currentState: any;
  110610. }
  110611. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  110612. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  110613. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  110614. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110615. interface WebGLRenderingContext {
  110616. readonly RASTERIZER_DISCARD: number;
  110617. readonly DEPTH_COMPONENT24: number;
  110618. readonly TEXTURE_3D: number;
  110619. readonly TEXTURE_2D_ARRAY: number;
  110620. readonly TEXTURE_COMPARE_FUNC: number;
  110621. readonly TEXTURE_COMPARE_MODE: number;
  110622. readonly COMPARE_REF_TO_TEXTURE: number;
  110623. readonly TEXTURE_WRAP_R: number;
  110624. readonly HALF_FLOAT: number;
  110625. readonly RGB8: number;
  110626. readonly RED_INTEGER: number;
  110627. readonly RG_INTEGER: number;
  110628. readonly RGB_INTEGER: number;
  110629. readonly RGBA_INTEGER: number;
  110630. readonly R8_SNORM: number;
  110631. readonly RG8_SNORM: number;
  110632. readonly RGB8_SNORM: number;
  110633. readonly RGBA8_SNORM: number;
  110634. readonly R8I: number;
  110635. readonly RG8I: number;
  110636. readonly RGB8I: number;
  110637. readonly RGBA8I: number;
  110638. readonly R8UI: number;
  110639. readonly RG8UI: number;
  110640. readonly RGB8UI: number;
  110641. readonly RGBA8UI: number;
  110642. readonly R16I: number;
  110643. readonly RG16I: number;
  110644. readonly RGB16I: number;
  110645. readonly RGBA16I: number;
  110646. readonly R16UI: number;
  110647. readonly RG16UI: number;
  110648. readonly RGB16UI: number;
  110649. readonly RGBA16UI: number;
  110650. readonly R32I: number;
  110651. readonly RG32I: number;
  110652. readonly RGB32I: number;
  110653. readonly RGBA32I: number;
  110654. readonly R32UI: number;
  110655. readonly RG32UI: number;
  110656. readonly RGB32UI: number;
  110657. readonly RGBA32UI: number;
  110658. readonly RGB10_A2UI: number;
  110659. readonly R11F_G11F_B10F: number;
  110660. readonly RGB9_E5: number;
  110661. readonly RGB10_A2: number;
  110662. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  110663. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  110664. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  110665. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  110666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  110667. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110668. 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;
  110669. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110670. readonly TRANSFORM_FEEDBACK: number;
  110671. readonly INTERLEAVED_ATTRIBS: number;
  110672. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110673. createTransformFeedback(): WebGLTransformFeedback;
  110674. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110675. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110676. beginTransformFeedback(primitiveMode: number): void;
  110677. endTransformFeedback(): void;
  110678. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  110679. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110680. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110681. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110682. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  110683. }
  110684. interface ImageBitmap {
  110685. readonly width: number;
  110686. readonly height: number;
  110687. close(): void;
  110688. }
  110689. interface WebGLQuery extends WebGLObject {
  110690. }
  110691. declare var WebGLQuery: {
  110692. prototype: WebGLQuery;
  110693. new(): WebGLQuery;
  110694. };
  110695. interface WebGLSampler extends WebGLObject {
  110696. }
  110697. declare var WebGLSampler: {
  110698. prototype: WebGLSampler;
  110699. new(): WebGLSampler;
  110700. };
  110701. interface WebGLSync extends WebGLObject {
  110702. }
  110703. declare var WebGLSync: {
  110704. prototype: WebGLSync;
  110705. new(): WebGLSync;
  110706. };
  110707. interface WebGLTransformFeedback extends WebGLObject {
  110708. }
  110709. declare var WebGLTransformFeedback: {
  110710. prototype: WebGLTransformFeedback;
  110711. new(): WebGLTransformFeedback;
  110712. };
  110713. interface WebGLVertexArrayObject extends WebGLObject {
  110714. }
  110715. declare var WebGLVertexArrayObject: {
  110716. prototype: WebGLVertexArrayObject;
  110717. new(): WebGLVertexArrayObject;
  110718. };
  110719. // Type definitions for WebVR API
  110720. // Project: https://w3c.github.io/webvr/
  110721. // Definitions by: six a <https://github.com/lostfictions>
  110722. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110723. interface VRDisplay extends EventTarget {
  110724. /**
  110725. * Dictionary of capabilities describing the VRDisplay.
  110726. */
  110727. readonly capabilities: VRDisplayCapabilities;
  110728. /**
  110729. * z-depth defining the far plane of the eye view frustum
  110730. * enables mapping of values in the render target depth
  110731. * attachment to scene coordinates. Initially set to 10000.0.
  110732. */
  110733. depthFar: number;
  110734. /**
  110735. * z-depth defining the near plane of the eye view frustum
  110736. * enables mapping of values in the render target depth
  110737. * attachment to scene coordinates. Initially set to 0.01.
  110738. */
  110739. depthNear: number;
  110740. /**
  110741. * An identifier for this distinct VRDisplay. Used as an
  110742. * association point in the Gamepad API.
  110743. */
  110744. readonly displayId: number;
  110745. /**
  110746. * A display name, a user-readable name identifying it.
  110747. */
  110748. readonly displayName: string;
  110749. readonly isConnected: boolean;
  110750. readonly isPresenting: boolean;
  110751. /**
  110752. * If this VRDisplay supports room-scale experiences, the optional
  110753. * stage attribute contains details on the room-scale parameters.
  110754. */
  110755. readonly stageParameters: VRStageParameters | null;
  110756. /**
  110757. * Passing the value returned by `requestAnimationFrame` to
  110758. * `cancelAnimationFrame` will unregister the callback.
  110759. * @param handle Define the hanle of the request to cancel
  110760. */
  110761. cancelAnimationFrame(handle: number): void;
  110762. /**
  110763. * Stops presenting to the VRDisplay.
  110764. * @returns a promise to know when it stopped
  110765. */
  110766. exitPresent(): Promise<void>;
  110767. /**
  110768. * Return the current VREyeParameters for the given eye.
  110769. * @param whichEye Define the eye we want the parameter for
  110770. * @returns the eye parameters
  110771. */
  110772. getEyeParameters(whichEye: string): VREyeParameters;
  110773. /**
  110774. * Populates the passed VRFrameData with the information required to render
  110775. * the current frame.
  110776. * @param frameData Define the data structure to populate
  110777. * @returns true if ok otherwise false
  110778. */
  110779. getFrameData(frameData: VRFrameData): boolean;
  110780. /**
  110781. * Get the layers currently being presented.
  110782. * @returns the list of VR layers
  110783. */
  110784. getLayers(): VRLayer[];
  110785. /**
  110786. * Return a VRPose containing the future predicted pose of the VRDisplay
  110787. * when the current frame will be presented. The value returned will not
  110788. * change until JavaScript has returned control to the browser.
  110789. *
  110790. * The VRPose will contain the position, orientation, velocity,
  110791. * and acceleration of each of these properties.
  110792. * @returns the pose object
  110793. */
  110794. getPose(): VRPose;
  110795. /**
  110796. * Return the current instantaneous pose of the VRDisplay, with no
  110797. * prediction applied.
  110798. * @returns the current instantaneous pose
  110799. */
  110800. getImmediatePose(): VRPose;
  110801. /**
  110802. * The callback passed to `requestAnimationFrame` will be called
  110803. * any time a new frame should be rendered. When the VRDisplay is
  110804. * presenting the callback will be called at the native refresh
  110805. * rate of the HMD. When not presenting this function acts
  110806. * identically to how window.requestAnimationFrame acts. Content should
  110807. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110808. * asynchronously from other displays and at differing refresh rates.
  110809. * @param callback Define the eaction to run next frame
  110810. * @returns the request handle it
  110811. */
  110812. requestAnimationFrame(callback: FrameRequestCallback): number;
  110813. /**
  110814. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110815. * Repeat calls while already presenting will update the VRLayers being displayed.
  110816. * @param layers Define the list of layer to present
  110817. * @returns a promise to know when the request has been fulfilled
  110818. */
  110819. requestPresent(layers: VRLayer[]): Promise<void>;
  110820. /**
  110821. * Reset the pose for this display, treating its current position and
  110822. * orientation as the "origin/zero" values. VRPose.position,
  110823. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110824. * updated when calling resetPose(). This should be called in only
  110825. * sitting-space experiences.
  110826. */
  110827. resetPose(): void;
  110828. /**
  110829. * The VRLayer provided to the VRDisplay will be captured and presented
  110830. * in the HMD. Calling this function has the same effect on the source
  110831. * canvas as any other operation that uses its source image, and canvases
  110832. * created without preserveDrawingBuffer set to true will be cleared.
  110833. * @param pose Define the pose to submit
  110834. */
  110835. submitFrame(pose?: VRPose): void;
  110836. }
  110837. declare var VRDisplay: {
  110838. prototype: VRDisplay;
  110839. new(): VRDisplay;
  110840. };
  110841. interface VRLayer {
  110842. leftBounds?: number[] | Float32Array | null;
  110843. rightBounds?: number[] | Float32Array | null;
  110844. source?: HTMLCanvasElement | null;
  110845. }
  110846. interface VRDisplayCapabilities {
  110847. readonly canPresent: boolean;
  110848. readonly hasExternalDisplay: boolean;
  110849. readonly hasOrientation: boolean;
  110850. readonly hasPosition: boolean;
  110851. readonly maxLayers: number;
  110852. }
  110853. interface VREyeParameters {
  110854. /** @deprecated */
  110855. readonly fieldOfView: VRFieldOfView;
  110856. readonly offset: Float32Array;
  110857. readonly renderHeight: number;
  110858. readonly renderWidth: number;
  110859. }
  110860. interface VRFieldOfView {
  110861. readonly downDegrees: number;
  110862. readonly leftDegrees: number;
  110863. readonly rightDegrees: number;
  110864. readonly upDegrees: number;
  110865. }
  110866. interface VRFrameData {
  110867. readonly leftProjectionMatrix: Float32Array;
  110868. readonly leftViewMatrix: Float32Array;
  110869. readonly pose: VRPose;
  110870. readonly rightProjectionMatrix: Float32Array;
  110871. readonly rightViewMatrix: Float32Array;
  110872. readonly timestamp: number;
  110873. }
  110874. interface VRPose {
  110875. readonly angularAcceleration: Float32Array | null;
  110876. readonly angularVelocity: Float32Array | null;
  110877. readonly linearAcceleration: Float32Array | null;
  110878. readonly linearVelocity: Float32Array | null;
  110879. readonly orientation: Float32Array | null;
  110880. readonly position: Float32Array | null;
  110881. readonly timestamp: number;
  110882. }
  110883. interface VRStageParameters {
  110884. sittingToStandingTransform?: Float32Array;
  110885. sizeX?: number;
  110886. sizeY?: number;
  110887. }
  110888. interface Navigator {
  110889. getVRDisplays(): Promise<VRDisplay[]>;
  110890. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110891. }
  110892. interface Window {
  110893. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110894. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110895. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110896. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110897. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110898. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110899. }
  110900. interface Gamepad {
  110901. readonly displayId: number;
  110902. }
  110903. interface XRDevice {
  110904. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110905. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110906. }
  110907. interface XRSession {
  110908. getInputSources(): Array<any>;
  110909. baseLayer: XRWebGLLayer;
  110910. requestFrameOfReference(type: string): Promise<void>;
  110911. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110912. end(): Promise<void>;
  110913. requestAnimationFrame: Function;
  110914. addEventListener: Function;
  110915. }
  110916. interface XRSessionCreationOptions {
  110917. outputContext?: WebGLRenderingContext | null;
  110918. immersive?: boolean;
  110919. environmentIntegration?: boolean;
  110920. }
  110921. interface XRLayer {
  110922. getViewport: Function;
  110923. framebufferWidth: number;
  110924. framebufferHeight: number;
  110925. }
  110926. interface XRView {
  110927. projectionMatrix: Float32Array;
  110928. }
  110929. interface XRFrame {
  110930. getDevicePose: Function;
  110931. getInputPose: Function;
  110932. views: Array<XRView>;
  110933. baseLayer: XRLayer;
  110934. }
  110935. interface XRFrameOfReference {
  110936. }
  110937. interface XRWebGLLayer extends XRLayer {
  110938. framebuffer: WebGLFramebuffer;
  110939. }
  110940. declare var XRWebGLLayer: {
  110941. prototype: XRWebGLLayer;
  110942. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110943. };